Skip to content

Commit 2180602

Browse files
committed
Fix location of let bindings with attributes
The location of let bindings did not include annotations attached to the binding (for the first binding in a sequence). This would show up in actions for dead code elimination in the editor tooling, which would remove everything but the annotation: rescript-lang/rescript-vscode#991
1 parent cc40042 commit 2180602

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#### :house: Internal
2020

2121
- Convert OCaml codebase to snake case style. https://github.com/rescript-lang/rescript-compiler/pull/6702
22+
- Fix location of let bindings with attributes. https://github.com/rescript-lang/rescript-compiler/pull/6791
2223

2324
#### :boom: Breaking Change
2425

Diff for: jscomp/syntax/src/res_core.ml

+3-4
Original file line numberDiff line numberDiff line change
@@ -2574,8 +2574,7 @@ and parse_attributes_and_binding (p : Parser.t) =
25742574
| _ -> []
25752575

25762576
(* definition ::= let [rec] let-binding { and let-binding } *)
2577-
and parse_let_bindings ~attrs p =
2578-
let start_pos = p.Parser.start_pos in
2577+
and parse_let_bindings ~attrs ~start_pos p =
25792578
Parser.optional p Let |> ignore;
25802579
let rec_flag =
25812580
if Parser.optional p Token.Rec then Asttypes.Recursive
@@ -3249,7 +3248,7 @@ and parse_expr_block_item p =
32493248
let loc = mk_loc start_pos p.prev_end_pos in
32503249
Ast_helper.Exp.open_ ~loc od.popen_override od.popen_lid block_expr
32513250
| Let ->
3252-
let rec_flag, let_bindings = parse_let_bindings ~attrs p in
3251+
let rec_flag, let_bindings = parse_let_bindings ~attrs ~start_pos p in
32533252
parse_newline_or_semicolon_expr_block p;
32543253
let next =
32553254
if Grammar.is_block_expr_start p.Parser.token then parse_expr_block p
@@ -5693,7 +5692,7 @@ and parse_structure_item_region p =
56935692
let loc = mk_loc start_pos p.prev_end_pos in
56945693
Some (Ast_helper.Str.open_ ~loc open_description)
56955694
| Let ->
5696-
let rec_flag, let_bindings = parse_let_bindings ~attrs p in
5695+
let rec_flag, let_bindings = parse_let_bindings ~attrs ~start_pos p in
56975696
parse_newline_or_semicolon_structure p;
56985697
let loc = mk_loc start_pos p.prev_end_pos in
56995698
Some (Ast_helper.Str.value ~loc rec_flag let_bindings)

0 commit comments

Comments
 (0)