Skip to content

Version 11.1.2-rc.1 #6812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 16, 2024
Prev Previous commit
Next Next commit
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
  • Loading branch information
cristianoc authored and cknitt committed Jun 16, 2024
commit e079313b1ad64eea733b1e1aef2a8266e6bc71f3
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

# 11.1.2-rc.1

#### :bug: Bug Fix

- Fix location of let bindings with attributes. https://github.com/rescript-lang/rescript-compiler/pull/6791

# 11.1.1

#### :bug: Bug Fix
Expand Down
7 changes: 3 additions & 4 deletions jscomp/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2555,8 +2555,7 @@ and parseAttributesAndBinding (p : Parser.t) =
| _ -> []

(* definition ::= let [rec] let-binding { and let-binding } *)
and parseLetBindings ~attrs p =
let startPos = p.Parser.startPos in
and parseLetBindings ~attrs ~startPos p =
Parser.optional p Let |> ignore;
let recFlag =
if Parser.optional p Token.Rec then Asttypes.Recursive
Expand Down Expand Up @@ -3222,7 +3221,7 @@ and parseExprBlockItem p =
let loc = mkLoc startPos p.prevEndPos in
Ast_helper.Exp.open_ ~loc od.popen_override od.popen_lid blockExpr
| Let ->
let recFlag, letBindings = parseLetBindings ~attrs p in
let recFlag, letBindings = parseLetBindings ~attrs ~startPos p in
parseNewlineOrSemicolonExprBlock p;
let next =
if Grammar.isBlockExprStart p.Parser.token then parseExprBlock p
Expand Down Expand Up @@ -5639,7 +5638,7 @@ and parseStructureItemRegion p =
let loc = mkLoc startPos p.prevEndPos in
Some (Ast_helper.Str.open_ ~loc openDescription)
| Let ->
let recFlag, letBindings = parseLetBindings ~attrs p in
let recFlag, letBindings = parseLetBindings ~attrs ~startPos p in
parseNewlineOrSemicolonStructure p;
let loc = mkLoc startPos p.prevEndPos in
Some (Ast_helper.Str.value ~loc recFlag letBindings)
Expand Down