Skip to content

Commit f8d2f25

Browse files
authored
Merge pull request #1880 from voodoos/503-final
Finish upgrade to 5.3
2 parents 005b42c + 2a5b060 commit f8d2f25

File tree

8 files changed

+87
-20
lines changed

8 files changed

+87
-20
lines changed

src/ocaml/merlin_specific/browse_raw.ml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ let rec of_expression_desc loc = function
360360
| _, None -> id_fold
361361
| _, Some e -> of_expression e)
362362
ls
363-
| Texp_match (e, cs, _, _) -> of_expression e ** list_fold of_case cs
363+
| Texp_match (e, cs, vs, _) ->
364+
of_expression e ** list_fold of_case cs ** list_fold of_case vs
364365
| Texp_try (e, cs, _) -> of_expression e ** list_fold of_case cs
365366
| Texp_tuple es | Texp_construct (_, _, es) | Texp_array es ->
366367
list_fold of_expression es
@@ -560,7 +561,20 @@ let of_node = function
560561
| Pattern { pat_desc; pat_extra = _ } -> of_pattern_desc pat_desc
561562
| Expression { exp_desc; exp_extra = _; exp_loc } ->
562563
of_expression_desc exp_loc exp_desc
563-
| Case { c_lhs; c_guard; c_rhs } ->
564+
| Case { c_lhs; c_cont = Some (id, vd); c_guard; c_rhs } ->
565+
let name = Ident.name id in
566+
let cont_pat =
567+
{ pat_desc = Tpat_var (id, { txt = name; loc = vd.val_loc }, vd.val_uid);
568+
pat_loc = vd.val_loc;
569+
pat_extra = [];
570+
pat_type = vd.val_type;
571+
pat_env = c_rhs.exp_env;
572+
pat_attributes = []
573+
}
574+
in
575+
of_pattern c_lhs ** of_expression c_rhs ** of_pattern cont_pat
576+
** option_fold of_expression c_guard
577+
| Case { c_lhs; c_cont = None; c_guard; c_rhs } ->
564578
of_pattern c_lhs ** of_expression c_rhs ** option_fold of_expression c_guard
565579
| Class_expr { cl_desc } -> of_class_expr_desc cl_desc
566580
| Class_structure { cstr_self; cstr_fields } ->

src/ocaml/typing/ctype.ml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,23 @@ let create_scope () =
209209
level
210210

211211
let wrap_end_def f = Misc.try_finally f ~always:end_def
212-
let wrap_end_def_new_pool f =
213-
wrap_end_def (fun _ -> with_new_pool ~level:!current_level f)
214212

215213
(* [with_local_level_gen] handles both the scoping structure of levels
216214
and automatic generalization through pools (cf. btype.ml) *)
217215
let with_local_level_gen ~begin_def ~structure ?before_generalize f =
218216
begin_def ();
219217
let level = !current_level in
220-
let result, pool = wrap_end_def_new_pool f in
221-
Option.iter (fun g -> g result) before_generalize;
218+
let result, pool =
219+
with_new_pool ~level:!current_level begin fun () ->
220+
let result = wrap_end_def f in
221+
Option.iter (fun g -> g result) before_generalize;
222+
result
223+
end
224+
in
222225
simple_abbrevs := Mnil;
223-
(* Nodes in [pool] were either created by the above call to [f],
224-
or they were created before, generalized, and then added to
225-
the pool by [update_level].
226+
(* Nodes in [pool] were either created by the above calls to [f]
227+
and [before_generalize], or they were created before, generalized,
228+
and then added to the pool by [update_level].
226229
In the latter case, their level was already kept for backtracking
227230
by a call to [set_level] inside [update_level].
228231
Since backtracking can only go back to a snapshot taken before [f] was

src/ocaml/typing/typecore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6144,7 +6144,7 @@ and type_cases
61446144
~type_body:begin
61456145
fun { pc_guard; pc_rhs } pat ~when_env ~ext_env ~cont ~ty_expected
61466146
~ty_infer ~contains_gadt:_ ->
6147-
let cont = Option.map (fun (id,_) -> id) cont in
6147+
(* let cont = Option.map (fun (id,_) -> id) cont in *)
61486148
let guard =
61496149
match pc_guard with
61506150
| None -> None

src/ocaml/typing/typedtree.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ and meth =
159159
and 'k case =
160160
{
161161
c_lhs: 'k general_pattern;
162-
c_cont: Ident.t option;
162+
c_cont: (Ident.t * Types.value_description) option;
163163
c_guard: expression option;
164164
c_rhs: expression;
165165
}

src/ocaml/typing/typedtree.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ and meth =
302302
and 'k case =
303303
{
304304
c_lhs: 'k general_pattern;
305-
c_cont: Ident.t option;
305+
c_cont: (Ident.t * Types.value_description) option;
306306
c_guard: expression option;
307307
c_rhs: expression;
308308
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
$ cat >main.ml <<'EOF'
2+
> type _ eff += E : unit eff
3+
>
4+
> let () =
5+
> Printf.printf "%d\n%!" @@
6+
> match 10 with
7+
> | x -> x
8+
> | effect E, k -> 11
9+
> EOF
10+
11+
$ $MERLIN single errors -filename main.ml <main.ml
12+
{
13+
"class": "return",
14+
"value": [],
15+
"notifications": []
16+
}
17+
18+
$ $MERLIN single type-enclosing -position 7:13 \
19+
> -filename main.ml <main.ml | jq '.value[0]'
20+
{
21+
"start": {
22+
"line": 7,
23+
"col": 13
24+
},
25+
"end": {
26+
"line": 7,
27+
"col": 14
28+
},
29+
"type": "unit eff",
30+
"tail": "no"
31+
}
32+
33+
The continuation is visible to Merlin
34+
$ $MERLIN single type-enclosing -position 7:16 \
35+
> -filename main.ml <main.ml | jq '.value[0]'
36+
{
37+
"start": {
38+
"line": 7,
39+
"col": 16
40+
},
41+
"end": {
42+
"line": 7,
43+
"col": 17
44+
},
45+
"type": "(%eff, int) continuation",
46+
"tail": "no"
47+
}

upstream/ocaml_503/base-rev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
630a342bf2b033a1be1c8746cbd34d0c63801ded
1+
bc5083c1d3b773fc3198355494afd2fb4628ff0e

upstream/ocaml_503/typing/ctype.ml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,23 @@ let create_scope () =
192192
level
193193

194194
let wrap_end_def f = Misc.try_finally f ~always:end_def
195-
let wrap_end_def_new_pool f =
196-
wrap_end_def (fun _ -> with_new_pool ~level:!current_level f)
197195

198196
(* [with_local_level_gen] handles both the scoping structure of levels
199197
and automatic generalization through pools (cf. btype.ml) *)
200198
let with_local_level_gen ~begin_def ~structure ?before_generalize f =
201199
begin_def ();
202200
let level = !current_level in
203-
let result, pool = wrap_end_def_new_pool f in
204-
Option.iter (fun g -> g result) before_generalize;
201+
let result, pool =
202+
with_new_pool ~level:!current_level begin fun () ->
203+
let result = wrap_end_def f in
204+
Option.iter (fun g -> g result) before_generalize;
205+
result
206+
end
207+
in
205208
simple_abbrevs := Mnil;
206-
(* Nodes in [pool] were either created by the above call to [f],
207-
or they were created before, generalized, and then added to
208-
the pool by [update_level].
209+
(* Nodes in [pool] were either created by the above calls to [f]
210+
and [before_generalize], or they were created before, generalized,
211+
and then added to the pool by [update_level].
209212
In the latter case, their level was already kept for backtracking
210213
by a call to [set_level] inside [update_level].
211214
Since backtracking can only go back to a snapshot taken before [f] was

0 commit comments

Comments
 (0)