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

Duplicated proto should be checked only for PropertyDefinition with PropertyName #1225

Closed
ariya opened this issue Jul 8, 2015 · 1 comment
Assignees
Labels

Comments

@ariya
Copy link
Contributor

ariya commented Jul 8, 2015

Test case:

> require('esprima').parse('x = { __proto__: null, get __proto__(){} }')

Actual output:

Error: Line 1: Duplicate __proto__ fields are not allowed in object literals

Expected: a parse tree since the code is valid. It is a __proto__ property for the first and a getter function for the second, hence there is no duplicate.

See Annex B.3.1:

It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate entries for __proto__ and at least two of those entries were obtained from productions of the form PropertyDefinition : PropertyName : AssignmentExpression.

Thus, other productions such as MethodDefinition (for methods, setters, getters, generators, ..) should not be checked.

@ariya ariya added the es6 label Jul 8, 2015
@ariya ariya self-assigned this Jul 8, 2015
@michaelficarra
Copy link
Contributor

That test looks familiar. Are you going through Shift tests and seeing if esprima passes them?

ariya added a commit to ariya/esprima that referenced this issue Jul 9, 2015
…ropertyName.

Other PropertyDefinition productions, such as MethodDefinition and
IdentifierReference, should be excluded from duplicated __proto_ checks.

Fixes jquery#1225
@ariya ariya closed this as completed in 495b298 Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants