Skip to content

Commit e12db8d

Browse files
committed
Fix issue with function definitions that use labeled arguments.
1 parent a9de07c commit e12db8d

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

analysis/src/SemanticTokens.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,8 @@ let emitLongident ?(backwards = false) ?(jsx = false)
136136
else loop pos segments
137137

138138
let emitVariable ~id ~debug ~loc emitter =
139-
emitter
140-
|> emitLongident
141-
~pos:(Utils.tupleOfLexing loc.Location.loc_start)
142-
~lid:(Longident.Lident id) ~debug
139+
if debug then Printf.printf "Variable: %s %s\n" id (locToString loc);
140+
emitter |> emitFromLoc ~loc ~type_:Variable
143141

144142
let emitJsxOpen ~lid ~debug ~loc emitter =
145143
emitter
@@ -188,8 +186,9 @@ let parser ~debug ~emitter ~path =
188186
in
189187
let pat (mapper : Ast_mapper.mapper) (p : Parsetree.pattern) =
190188
match p.ppat_desc with
191-
| Ppat_var {loc; txt = id} ->
192-
if isLowercaseId id then emitter |> emitVariable ~id ~debug ~loc;
189+
| Ppat_var {txt = id} ->
190+
if isLowercaseId id then
191+
emitter |> emitVariable ~id ~debug ~loc:p.ppat_loc;
193192
Ast_mapper.default_mapper.pat mapper p
194193
| Ppat_record (cases, _) ->
195194
cases

analysis/tests/src/Parser.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ module T = {
6666
}
6767

6868
let foo = x => x.T.someField
69+
70+
let add = (~hello, ~world) => hello + world

analysis/tests/src/expected/Parser.res.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Parse tests/src/Parser.res
2-
structure items:17 diagnostics:0
2+
structure items:18 diagnostics:0
33
Lident: M (0,7) Namespace
44
Lident: C (1,9) Namespace
55
Lident: Component (1,13) Namespace
66
Lident: Component (4,10) Namespace
7-
Lident: _c (4,4) Variable
7+
Variable: _c (4,4)->(4,6)
88
Ldot: M (6,11) Namespace
99
Lident: C (6,13) Namespace
10-
Lident: _mc (6,4) Variable
10+
Variable: _mc (6,4)->(6,7)
1111
Lident: div (8,10) JsxTag
12-
Lident: _d (8,4) Variable
12+
Variable: _d (8,4)->(8,6)
1313
Lident: div (11,3) JsxTag
1414
Lident: div (16,4) JsxTag
1515
Ldot: React (12,5) Namespace
@@ -22,7 +22,7 @@ Ldot: React (14,5) Namespace
2222
Lident: string (14,11) Variable
2323
Ldot: React (15,5) Namespace
2424
Lident: string (15,11) Variable
25-
Lident: _d2 (10,4) Variable
25+
Variable: _d2 (10,4)->(10,7)
2626
Type: pair (18,5)->(18,9)
2727
Type: looooooooooooooooooooooooooooooooooooooong_int (20,5)->(20,51)
2828
Type: int (20,54)->(20,57)
@@ -66,6 +66,12 @@ Lident: C (64,26) EnumMember
6666
Ldot: T (67,17) Namespace
6767
Lident: someField (67,19) Property
6868
Lident: x (67,15) Variable
69-
Lident: x (67,10) Variable
70-
Lident: foo (67,4) Variable
69+
Variable: x (67,10)->(67,11)
70+
Variable: foo (67,4)->(67,7)
71+
BinaryExp: (69,36)->(69,37)
72+
Lident: hello (69,30) Variable
73+
Lident: world (69,38) Variable
74+
Variable: world (69,19)->(69,25)
75+
Variable: hello (69,11)->(69,17)
76+
Variable: add (69,4)->(69,7)
7177

0 commit comments

Comments
 (0)