Question regarding duplicate computed __proto__ properties

# Fred Schott (10 years ago)

In Section B.3.1 on "proto Property Names in Object Initializers" 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.

# Allen Wirfs-Brock (10 years ago)

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

# Fred Schott (10 years ago)

Filed as Bug 3510. Thanks for the confirmation, Allen.

— Sent from Mailbox