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) asserts 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:
// Error: SyntaxError
var obj = {
__proto__: somePrototype,
["__proto__"]: somePrototype
}
Allen Wirfs-Brock Confirmed this as a bug here: https://esdiscuss.org/topic/question-regarding-duplicate-computed-proto-properties
Expected behavior: Computed properties are excempt from duplicate restrictions on __proto__ literal property names.
The PropName of a ComputedPropertyName is **empty**.
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer-static-semantics-propname
Ah, thanks Erik for pointing that out.
So, the spec. is correct, as is.
Fred, thanks any way for bring it up. As often as not, such things actually are bugs.
Ah nice catch Erik, I missed that.
Thanks both of you for taking the time. At least now the issue & es-discuss emails are documented for anyone who comes looking with the same misunderstanding.
I added a NOTE to B.3.1 pointing out that PropertyNameList does not return any ComputerPropertyName valules.