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
Correctly check reserved word for PropertyDefinition: IdentifierReference #11862
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit bdce7c3:
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/26313/ |
I don't think so: the destructuring pattern must match the "AssignmentPattern" production, and: 12.15.7.1 Static Semantics: Early ErrorsAssignmentProperty : IdentifierReference Initializer[opt]
12.1.3 Static Semantics: AssignmentTargetTypeIdentifierReference : Identifier
|
As for destructuring, we will check the BindingIdentifier ReservedWord in babel/packages/babel-parser/src/parser/lval.js Lines 353 to 359 in 2bf38fb
Thus the following test case still throws. "use strict";
const { arguments } = foo(); Since we can not differentiate between |
For object shorthand property, e.g.
({ arguments })
is allowed becauseand
arguments
andeval
is not ReservedWordFor destructuring patterns, e.g.
({ arguments = 1 }) = {}
is allowed (in sloppy mode) becauseIf the fourth argument of
this.checkReservedWord
istrue
, it should be applied on BindingIdentifier, whereeval
andarguments
are forbidden. Therefore the fix here is to align the spec and passfalse
instead.This PR fixes a downstream issue: angular/angular-cli#17439