diff options
Diffstat (limited to 'lib/syntax/check.ml')
-rw-r--r-- | lib/syntax/check.ml | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/syntax/check.ml b/lib/syntax/check.ml index 3e9d255..3e01e64 100644 --- a/lib/syntax/check.ml +++ b/lib/syntax/check.ml @@ -464,13 +464,19 @@ module Make (A : App) = struct S.pos -> (expression, t) S.clause -> elifs:(expression, t) S.clause list -> - else_:t S.repr list -> + else_:(S.pos * t S.repr list) option -> t S.repr = fun pos clause ~elifs ~else_ report -> (* First, apply the report for all the instructions *) let report, clause = map_clause report clause in let report, elifs = List.fold_left_map elifs ~init:report ~f:map_clause in - let report, else_ = Helper.map_args report else_ in + let report, else_ = + match else_ with + | None -> (report, None) + | Some (pos, instructions) -> + let report, instructions = Helper.map_args report instructions in + (report, Some (pos, instructions)) + in let report = ref report and len = Array.length A.t in let result = @@ -485,9 +491,13 @@ module Make (A : App) = struct let clause = rebuild_clause i instr_witness expr_witness f clause and elifs = List.map elifs ~f:(rebuild_clause i instr_witness expr_witness f) - and elses = Helper.args_i else_ instr_witness i in - - let else_ = List.rev elses.values in + and else_ = + match else_ with + | None -> None + | Some (pos, instructions) -> + let elses = Helper.args_i instructions instr_witness i in + Some (pos, List.rev elses.values) + in let value, r = A.Instruction.if_ pos clause ~elifs ~else_ !report in report := r; |