Skip to content

Commit 14d1873

Browse files
committed
Fix context
1 parent 4b21242 commit 14d1873

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/analysis/context.ml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ type t =
3737
path (cf. #486, #794). *)
3838
| Unknown_constructor
3939
| Expr
40-
| Label of Types.label_description (* Similar to constructors. *)
41-
| Unknown_label
40+
| Label :
41+
'rep Types.gen_label_description * 'rep Types.record_form
42+
-> t (* Similar to constructors. *)
43+
| Unknown_label : 'rep Types.record_form -> t
4244
| Module_path
4345
| Module_type
4446
| Patt
@@ -50,8 +52,11 @@ let to_string = function
5052
| Constructor (cd, _) -> Printf.sprintf "constructor %s" cd.cstr_name
5153
| Unknown_constructor -> Printf.sprintf "unknown constructor"
5254
| Expr -> "expression"
53-
| Label lbl -> Printf.sprintf "record field %s" lbl.lbl_name
54-
| Unknown_label -> Printf.sprintf "record field"
55+
| Label (lbl, Legacy) -> Printf.sprintf "record field %s" lbl.lbl_name
56+
| Unknown_label Legacy -> Printf.sprintf "record field"
57+
| Label (lbl, Unboxed_product) ->
58+
Printf.sprintf "unboxed record field %s" lbl.lbl_name
59+
| Unknown_label Unboxed_product -> Printf.sprintf "unboxed record field"
5560
| Module_path -> "module path"
5661
| Module_type -> "module type"
5762
| Patt -> "pattern"
@@ -67,7 +72,8 @@ let of_locate_context : Query_protocol.Locate_context.t -> t = function
6772
| Type -> Type
6873
| Constant -> Constant
6974
| Constructor -> Unknown_constructor
70-
| Label -> Unknown_label
75+
| Label -> Unknown_label Legacy
76+
| Unboxed_label -> Unknown_label Unboxed_product
7177
| Unknown -> Unknown
7278

7379
(* Distinguish between "Mo[d]ule.something" and "Module.some[t]hing" *)
@@ -158,9 +164,10 @@ let inspect_browse_tree ?let_pun_behavior ~cursor lid browse : t option =
158164
| Module_type _ -> Some Module_type
159165
| Core_type { ctyp_desc = Ttyp_package _; _ } -> Some Module_type
160166
| Core_type _ -> Some Type
161-
| Record_field (_, lbl, _) when Longident.last lid = lbl.lbl_name ->
167+
| Record_field (_, lbl, record_form, _)
168+
when Longident.last lid = lbl.lbl_name ->
162169
(* if we stopped here, then we're on the label itself, and whether or
163170
not punning is happening is not important *)
164-
Some (Label lbl)
171+
Some (Label (lbl, record_form))
165172
| Expression e -> Some (inspect_expression ~cursor ~lid e)
166173
| _ -> Some Unknown)

src/analysis/context.mli

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ type t =
3333
path (cf. #486, #794). *)
3434
| Unknown_constructor
3535
| Expr
36-
| Label of Types.label_description (* Similar to constructors. *)
37-
| Unknown_label
36+
| Label :
37+
'rep Types.gen_label_description * 'rep Types.record_form
38+
-> t (* Similar to constructors. *)
39+
| Unknown_label : 'rep Types.record_form -> t
3840
| Module_path
3941
| Module_type
4042
| Patt

src/frontend/query_protocol.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ module Locate_context = struct
139139
| Constant
140140
| Constructor
141141
| Label
142+
| Unboxed_label
142143
| Unknown
143144

144145
let to_string = function
@@ -150,6 +151,7 @@ module Locate_context = struct
150151
| Constant -> "constant"
151152
| Constructor -> "constructor"
152153
| Label -> "label"
154+
| Unboxed_label -> "unboxed_label"
153155
| Unknown -> "unknown"
154156

155157
let of_string = function
@@ -161,6 +163,7 @@ module Locate_context = struct
161163
| "constant" -> Some Constant
162164
| "constructor" -> Some Constructor
163165
| "label" -> Some Label
166+
| "unboxed_label" -> Some Label
164167
| "unknown" -> Some Unknown
165168
| _ -> None
166169

@@ -173,6 +176,7 @@ module Locate_context = struct
173176
Constant;
174177
Constructor;
175178
Label;
179+
Unboxed_label;
176180
Unknown
177181
]
178182
end

0 commit comments

Comments
 (0)