Skip to content

Commit

Permalink
Update the interpreter to handle optional otherwise branches
Browse files Browse the repository at this point in the history
  • Loading branch information
sonmarcho committed Dec 13, 2023
1 parent 2200954 commit bfa83d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/InterpreterStatements.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down

0 comments on commit bfa83d9

Please sign in to comment.