Skip to content

fix: start recovered AssignmentPattern at the property key - #18603

Merged
JLHwung merged 1 commit into
mainfrom
jlhwung/fix-parser-recovery-assignment-pattern-start
Nov 12, 2026
Merged

JLHwung merged 1 commit into
mainfrom
jlhwung/fix-parser-recovery-assignment-pattern-start

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Invalid AssignmentPattern start location when errorRecovery is true
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
Need backport? No
License MIT

When errorRecovery is true, class C m({a=1}) {} produces an ObjectProperty whose AssignmentPattern starts from the token "=".

An assignment pattern should start from the object property name a, here it started from "=" because the startLoc was only updated when refExpressionsErrors are non-null. parseMaybeDefault then fallback to start the AssignmentPattern at the current token "=" position.

Always record the property start so the pattern starts at the key, as it already did for ({a=1}), f({a=1}) and [{a=1}].

Assisted-by: Claude Fable 5.1

When errorRecovery is true, `class C m({a=1})` produces an ObjectProperty whose AssignmentPattern starts from the token "=".

An assignment pattern should start from the object property name `a`, here it started from "=" because the startLoc was only updated when refExpressionsErrors are null. parseMaybeDefault then fallback to start the AssignmentPattern at the current token "=" position.

Always record the property start so the pattern starts at the key, as it
already did for `({a=1})`, `f({a=1})` and `[{a=1}]`.

Assisted-by: Claude Fable 5.1
@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser 7.x: needs backport labels Nov 12, 2026
@babel-bot

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/63257

@JLHwung JLHwung changed the title fix(parser): start recovered AssignmentPattern at the property key fix: start recovered AssignmentPattern at the property key Nov 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 6c7b163

@JLHwung
JLHwung added this pull request to stack #18605 November 12, 2026 02:47
@JLHwung
JLHwung added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 676fa93 Nov 12, 2026
68 checks passed
@JLHwung
JLHwung deleted the jlhwung/fix-parser-recovery-assignment-pattern-start branch November 12, 2026 14:27
@babel-bot

Copy link
Copy Markdown
Collaborator

Backported to 7.x in #18609.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants