diff --git a/src/ocaml/typing/ctype.ml b/src/ocaml/typing/ctype.ml index cdfa58f48..263f29838 100644 --- a/src/ocaml/typing/ctype.ml +++ b/src/ocaml/typing/ctype.ml @@ -209,20 +209,23 @@ let create_scope () = level let wrap_end_def f = Misc.try_finally f ~always:end_def -let wrap_end_def_new_pool f = - wrap_end_def (fun _ -> with_new_pool ~level:!current_level f) (* [with_local_level_gen] handles both the scoping structure of levels and automatic generalization through pools (cf. btype.ml) *) let with_local_level_gen ~begin_def ~structure ?before_generalize f = begin_def (); let level = !current_level in - let result, pool = wrap_end_def_new_pool f in - Option.iter (fun g -> g result) before_generalize; + let result, pool = + with_new_pool ~level:!current_level begin fun () -> + let result = wrap_end_def f in + Option.iter (fun g -> g result) before_generalize; + result + end + in simple_abbrevs := Mnil; - (* Nodes in [pool] were either created by the above call to [f], - or they were created before, generalized, and then added to - the pool by [update_level]. + (* Nodes in [pool] were either created by the above calls to [f] + and [before_generalize], or they were created before, generalized, + and then added to the pool by [update_level]. In the latter case, their level was already kept for backtracking by a call to [set_level] inside [update_level]. Since backtracking can only go back to a snapshot taken before [f] was diff --git a/upstream/ocaml_503/base-rev.txt b/upstream/ocaml_503/base-rev.txt index 8d00851f3..09f82c268 100644 --- a/upstream/ocaml_503/base-rev.txt +++ b/upstream/ocaml_503/base-rev.txt @@ -1 +1 @@ -630a342bf2b033a1be1c8746cbd34d0c63801ded +bc5083c1d3b773fc3198355494afd2fb4628ff0e diff --git a/upstream/ocaml_503/typing/ctype.ml b/upstream/ocaml_503/typing/ctype.ml index 692c4da3c..c54a2b7a2 100644 --- a/upstream/ocaml_503/typing/ctype.ml +++ b/upstream/ocaml_503/typing/ctype.ml @@ -192,20 +192,23 @@ let create_scope () = level let wrap_end_def f = Misc.try_finally f ~always:end_def -let wrap_end_def_new_pool f = - wrap_end_def (fun _ -> with_new_pool ~level:!current_level f) (* [with_local_level_gen] handles both the scoping structure of levels and automatic generalization through pools (cf. btype.ml) *) let with_local_level_gen ~begin_def ~structure ?before_generalize f = begin_def (); let level = !current_level in - let result, pool = wrap_end_def_new_pool f in - Option.iter (fun g -> g result) before_generalize; + let result, pool = + with_new_pool ~level:!current_level begin fun () -> + let result = wrap_end_def f in + Option.iter (fun g -> g result) before_generalize; + result + end + in simple_abbrevs := Mnil; - (* Nodes in [pool] were either created by the above call to [f], - or they were created before, generalized, and then added to - the pool by [update_level]. + (* Nodes in [pool] were either created by the above calls to [f] + and [before_generalize], or they were created before, generalized, + and then added to the pool by [update_level]. In the latter case, their level was already kept for backtracking by a call to [set_level] inside [update_level]. Since backtracking can only go back to a snapshot taken before [f] was