Skip to content

Commit

Permalink
matching: use toplevel_handler in for_tupled_function
Browse files Browse the repository at this point in the history
This appears to change the function behavior with respect to the
Unused exception, but we believe that the change is correct. It makes
the code more consistent with other toplevel compilation functions.
  • Loading branch information
gasche committed Nov 18, 2020
1 parent 15b1685 commit 9a57ea4
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions lambda/matching.ml
Expand Up @@ -3662,23 +3662,14 @@ let for_let ~scopes loc param pat body =
(* Easy case since variables are available *)
let for_tupled_function ~scopes loc paraml pats_act_list partial =
let partial = check_partial_list pats_act_list partial in
let raise_num = next_raise_count () in
let omega_params = [ Patterns.omega_list paraml ] in
let pm =
{ cases = pats_act_list;
args = List.map (fun id -> (Lvar id, Strict)) paraml;
default = Default_environment.(cons omega_params raise_num empty)
}
in
try
let lambda, total =
compile_match ~scopes None partial
(Context.start (List.length paraml)) pm
in
check_total ~scopes loc ~failer:Raise_match_failure
total lambda raise_num
with Unused ->
failure_handler ~scopes loc ~failer:Raise_match_failure ()
let args = List.map (fun id -> (Lvar id, Strict)) paraml in
let handler =
toplevel_handler ~scopes loc ~failer:Raise_match_failure
partial args pats_act_list in
handler (fun partial pm ->
compile_match ~scopes None partial
(Context.start (List.length paraml)) pm
)

let flatten_pattern size p =
match p.pat_desc with
Expand Down

0 comments on commit 9a57ea4

Please sign in to comment.