daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/bytecomp/matching.ml b/bytecomp/matching.ml
  2. index afec0f5..94797d8 100644
  3. --- a/bytecomp/matching.ml
  4. +++ b/bytecomp/matching.ml
  5. @@ -2484,21 +2484,44 @@ and compile_no_test divide up_ctx repr partial ctx to_match =
  6.  (* The entry points *)
  7.  
  8.  (*
  9. -   If there is a guard in a matching, then
  10. -   set exhaustiveness info to Partial.
  11. -   (because of side effects in guards, assume the worst)
  12. +   If there is a guard in a matching or a lazy pattern,
  13. +   then set exhaustiveness info to Partial.
  14. +   (because of side effects, assume the worst)
  15.  *)
  16.  
  17. -let check_partial pat_act_list partial =
  18. +let rec is_lazy p = match p.pat_desc with
  19. +| Tpat_alias (p, _ ,_ ) ->
  20. +    is_lazy p
  21. +| Tpat_tuple pats ->
  22. +    List.exists is_lazy pats
  23. +| Tpat_record (lpats,_) ->
  24. +    List.exists
  25. +      (fun (_, _, p) -> is_lazy p)
  26. +      lpats
  27. +| Tpat_construct (_, _, pats,_) ->
  28. +    List.exists is_lazy pats
  29. +| Tpat_array pats ->
  30. +    List.exists is_lazy pats
  31. +| Tpat_variant (_, Some p, _) ->
  32. +    is_lazy p
  33. +| Tpat_or (p, q, _) ->
  34. +    is_lazy p || is_lazy q
  35. +| Tpat_lazy p -> true
  36. +| Tpat_constant _ | Tpat_var _
  37. +| Tpat_any | Tpat_variant (_,None,_) -> false
  38. +
  39. +let check_partial is_lazy pat_act_list partial =
  40.    if
  41.      List.exists
  42. -      (fun (_,lam) -> is_guarded lam)
  43. +      (fun (pats, lam) -> is_guarded lam || is_lazy pats)
  44.         pat_act_list
  45.    then begin
  46.      Partial
  47.    end else
  48.      partial
  49.  
  50. +let check_partial_list = check_partial (List.exists is_lazy)
  51. +let check_partial = check_partial is_lazy
  52.  
  53.  (* have toplevel handler when appropriate *)
  54.  
  55. @@ -2561,7 +2584,7 @@ let for_let loc param pat body =
  56.  
  57.  (* Easy case since variables are available *)
  58.  let for_tupled_function loc paraml pats_act_list partial =
  59. -  let partial = check_partial pats_act_list partial in
  60. +  let partial = check_partial_list pats_act_list partial in
  61.    let raise_num = next_raise_count () in
  62.    let omegas = [List.map (fun _ -> omega) paraml] in
  63.    let pm =
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top