Skip to content

Disallow decorator in array pattern#17159

Merged
JLHwung merged 5 commits intobabel:mainfrom
JLHwung:disallow-decorator-in-array-pattern
Mar 2, 2025
Merged

Disallow decorator in array pattern#17159
JLHwung merged 5 commits intobabel:mainfrom
JLHwung:disallow-decorator-in-array-pattern

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Mar 2, 2025

Q                       A
Fixed Issues? When using legacy decorators, Babel parses var [@foo foo ] = foo; as decorator within an array pattern, which is not allowed.
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Spot this issue when browsing through the lval implementation.

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories pkg: parser Spec: Decorators (Legacy) labels Mar 2, 2025
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Mar 2, 2025

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

@@ -0,0 +1 @@
var [@foo foo ] = foo;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For stage 3 decorators, currently Babel throws a recoverable error message "Decorators cannot be used to decorate parameters.", which is quite confusing. Here we throw an unrecoverable error since we already do that for object patterns.

@JLHwung JLHwung force-pushed the disallow-decorator-in-array-pattern branch from d2701df to eda0d82 Compare March 2, 2025 03:17
@JLHwung JLHwung merged commit 62ed12a into babel:main Mar 2, 2025
@JLHwung JLHwung deleted the disallow-decorator-in-array-pattern branch March 2, 2025 16:23
laine-hallot pushed a commit to laine-hallot/uwu-parser that referenced this pull request Mar 31, 2025
* type cleanup

* fix: disallow decorator in array pattern

* copy test cases to stage 3 decorators

* rename parseAssignableListItem to parseBindingElement

* incorrect test setup
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 2, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories Spec: Decorators (Legacy)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants