Question regarding duplicate computed __proto__ properties
Allen Wirfs-Brock
allen at wirfs-brock.com
Sun Jan 4 21:13:17 PST 2015
On Jan 4, 2015 9:06 PM, Fred Schott <fkschott at gmail.com> wrote:
>
> In Section B.3.1 on "__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
No, this is not supposed to be a syntax error.
>
>
> 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.
The latter. Please file a bug at bugs.ecmascript.org
More information about the es-discuss
mailing list