Skip to content

Commit 9ff1285

Browse files
committed
Add special case for labels in type enclosing logic
1 parent 0110c6a commit 9ff1285

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/analysis/type_enclosing.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ let from_reconstructed ~nodes ~cursor ~verbosity exprs =
102102
let ppf, to_string = Format.to_string () in
103103
Type_utils.print_constr ~verbosity env ppf cd;
104104
Some (loc, String (to_string ()), `No)
105+
| Some (Context.Label { lbl_name; lbl_arg; _ }) ->
106+
log ~title:"from_reconstructed" "ctx: label %s" lbl_name;
107+
let ppf, to_string = Format.to_string () in
108+
Type_utils.print_type_with_decl ~verbosity env ppf lbl_arg;
109+
Some (loc, String (to_string ()), `No)
105110
| Some Context.Constant -> None
106111
| _ ->
107112
let context = Option.value ~default:Context.Expr context in

tests/test-dirs/type-enclosing/issue1564.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ Verbosity 0 should stop at Kind.t
2929
"Kind.t"
3030

3131
On `let y = x.k|ind`
32-
FIXME Verbosity 1 should show the actual type definition of Kind.t
32+
Verbosity 1 should show the actual type definition of Kind.t
3333
$ $MERLIN single type-enclosing -position 8:11 -verbosity 1 \
3434
> -filename ./main.ml < ./main.ml | tr '\r\n' ' ' | jq ".value[0].type"
35-
"Kind.t"
35+
"type t = A | B"
3636

3737
On `let z = { kind = B }.k|ind`
3838
Verbosity 0 should stop at Kind.t
@@ -53,7 +53,7 @@ Verbosity 0 should stop at Kind.t
5353
"Kind.t"
5454

5555
On `let x = { k|ind = A }`
56-
FIXME Verbosity 1 should show the actual type definition of Kind.t
56+
Verbosity 1 should show the actual type definition of Kind.t
5757
$ $MERLIN single type-enclosing -position 7:12 -verbosity 1 \
5858
> -filename ./main.ml < ./main.ml | tr '\r\n' ' ' | jq ".value[0].type"
59-
"Kind.t"
59+
"type t = A | B"

tests/test-dirs/type-enclosing/record.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ FIXME: The following results are not entirely satisfying (`foo.Bar -> foo` could
231231
"line": 12,
232232
"col": 18
233233
},
234-
"type": "unit",
234+
"type": "type unit = ()",
235235
"tail": "no"
236236
},
237237
{

0 commit comments

Comments
 (0)