Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/bytecomp/matching.ml b/bytecomp/matching.ml
- index afec0f5..94797d8 100644
- --- a/bytecomp/matching.ml
- +++ b/bytecomp/matching.ml
- @@ -2484,21 +2484,44 @@ and compile_no_test divide up_ctx repr partial ctx to_match =
- (* The entry points *)
- (*
- - If there is a guard in a matching, then
- - set exhaustiveness info to Partial.
- - (because of side effects in guards, assume the worst)
- + If there is a guard in a matching or a lazy pattern,
- + then set exhaustiveness info to Partial.
- + (because of side effects, assume the worst)
- *)
- -let check_partial pat_act_list partial =
- +let rec is_lazy p = match p.pat_desc with
- +| Tpat_alias (p, _ ,_ ) ->
- + is_lazy p
- +| Tpat_tuple pats ->
- + List.exists is_lazy pats
- +| Tpat_record (lpats,_) ->
- + List.exists
- + (fun (_, _, p) -> is_lazy p)
- + lpats
- +| Tpat_construct (_, _, pats,_) ->
- + List.exists is_lazy pats
- +| Tpat_array pats ->
- + List.exists is_lazy pats
- +| Tpat_variant (_, Some p, _) ->
- + is_lazy p
- +| Tpat_or (p, q, _) ->
- + is_lazy p || is_lazy q
- +| Tpat_lazy p -> true
- +| Tpat_constant _ | Tpat_var _
- +| Tpat_any | Tpat_variant (_,None,_) -> false
- +
- +let check_partial is_lazy pat_act_list partial =
- if
- List.exists
- - (fun (_,lam) -> is_guarded lam)
- + (fun (pats, lam) -> is_guarded lam || is_lazy pats)
- pat_act_list
- then begin
- Partial
- end else
- partial
- +let check_partial_list = check_partial (List.exists is_lazy)
- +let check_partial = check_partial is_lazy
- (* have toplevel handler when appropriate *)
- @@ -2561,7 +2584,7 @@ let for_let loc param pat body =
- (* Easy case since variables are available *)
- let for_tupled_function loc paraml pats_act_list partial =
- - let partial = check_partial pats_act_list partial in
- + let partial = check_partial_list pats_act_list partial in
- let raise_num = next_raise_count () in
- let omegas = [List.map (fun _ -> omega) paraml] in
- let pm =
Add Comment
Please, Sign In to add comment