Question regarding duplicate computed __proto__ properties
Fred Schott
fkschott at gmail.com
Sun Jan 4 21:06:56 PST 2015
In Section B.3.1 on "__proto__ Property Names in Object Initializers"
<http://people.mozilla.org/~jorendorff/es6-draft.html#sec-__proto__-property-names-in-object-initializers>
there is a paragraph explaining when duplicate properties will result in a
syntax error. It says:
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* .
>
Where *PropertyName *is defined as:
PropertyName[Yield,GeneratorParameter] :
> LiteralPropertyName
> [+GeneratorParameter] ComputedPropertyName
> [~GeneratorParameter] ComputedPropertyName[?Yield]
>
> LiteralPropertyName :
> IdentifierName
> StringLiteral
> NumericLiteral
That paragraph (using the definitions provided) seems to assert that it is
a syntax error if there are any duplicate uses of __proto__ with an
IdentifierName, StringLiteral, or ComputedPropertyName. To translate this
into an example, it seems to assert that in ES6 this is not valid:
var obj = {
> __proto__: somePrototype,
> ["__proto__"]: somePrototype
> }
// Error: SyntaxError
Is that correct? Step 6 of Section B.3.1 explicitly states that the
computed ["__proto__"] does not have the same special behavior as the
literal property. But from my understanding of other es-discuss topics &
resources, the restriction on duplicate "__proto__" properties also does
not apply to computed properties. If that is true, then the quoted
paragraph above seems to be incorrect or misleading.
Can anyone clarify this? I may just be misunderstanding the docs and/or the
recent discussions. Or it could be that the definition has changed around
that quoted paragraph and it needs to be updated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150104/f5e0bd94/attachment-0001.html>
More information about the es-discuss
mailing list