summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSon Ho2023-12-13 10:57:49 +0100
committerSon Ho2023-12-13 10:57:49 +0100
commitbfa83d948aff5ad0ec298836bf9f0be58a62d542 (patch)
treecc2d4c58c2b616966905db3bb3495225f8112f2b /compiler
parent22009543d86895b9f680d3a4abdea00302ad5f1e (diff)
Update the interpreter to handle optional otherwise branches
Diffstat (limited to '')
-rw-r--r--compiler/InterpreterStatements.ml5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/InterpreterStatements.ml b/compiler/InterpreterStatements.ml
index 66b8492a..30b7b333 100644
--- a/compiler/InterpreterStatements.ml
+++ b/compiler/InterpreterStatements.ml
@@ -1125,7 +1125,10 @@ and eval_switch (config : config) (switch : switch) : st_cm_fun =
let dv = Option.get adt.variant_id in
(* Find the branch, evaluate and continue *)
match List.find_opt (fun (svl, _) -> List.mem dv svl) stgts with
- | None -> eval_statement config otherwise cf ctx
+ | None -> (
+ match otherwise with
+ | None -> raise (Failure "No otherwise branch")
+ | Some otherwise -> eval_statement config otherwise cf ctx)
| Some (_, tgt) -> eval_statement config tgt cf ctx)
| VSymbolic sv ->
(* Expand the symbolic value - may lead to branching *)