Skip to content
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

ComputedPropertyName, StringLiteral and NumericLiteral in object destructuring #2467

Closed
nicolo-ribaudo opened this issue Jun 15, 2015 · 1 comment
Labels

Comments

@nicolo-ribaudo
Copy link
Contributor

Consider this (valid) code:

const { ["z"]: a, 1: b, "x": c } = { z: 2, 1: 3, x: 4 };

Errors reported by JSHint:

Expected an identifier and instead saw '['.
Expected ',' and instead saw 'z'.
Expected an identifier and instead saw ']'.
Expected an identifier and instead saw '1'.
Expected an identifier and instead saw 'x'.

Spec:
12.14.5 Destructuring Assignment

AssignmentPattern[Yield] :
  ObjectAssignmentPattern[?Yield]
  ...

ObjectAssignmentPattern[Yield] :
  ...
  { AssignmentPropertyList[?Yield] }
  { AssignmentPropertyList[?Yield] , }

AssignmentPropertyList[Yield] :
  AssignmentProperty[?Yield]
  AssignmentPropertyList[?Yield] , AssignmentProperty[?Yield]

AssignmentProperty[Yield] :
  ...
  PropertyName : AssignmentElement[?Yield]

Definition of PropertyName:
12.2.5 Object Initializer

PropertyName[Yield,GeneratorParameter] :
  LiteralPropertyName
  [+GeneratorParameter] ComputedPropertyName
  [~GeneratorParameter] ComputedPropertyName[?Yield]

LiteralPropertyName :
  IdentifierName
  StringLiteral
  NumericLiteral

@lukeapage lukeapage added the ES6 label Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants