__proto__-duplicate-computed.js (1361B)
1 // Copyright (C) 2017 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-__proto__-property-names-in-object-initializers 5 es6id: B.3.1 6 description: > 7 The syntax error for duplicate `__proto__` property is not valid if the duplicate is a 8 ComputedPropertyName 9 info: | 10 B.3.1__proto__ Property Names in Object Initializers 11 12 It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate 13 entries for "__proto__" and at least two of those entries were obtained from productions of 14 the form 15 PropertyDefinition : PropertyName : AssignmentExpression . 16 17 12.2.6.6 Static Semantics: PropertyNameList 18 19 ... 20 3. Append PropName of PropertyDefinition to the end of list. 21 ... 22 23 12.2.6.5 Static Semantics: PropName 24 25 ComputedPropertyName : [ AssignmentExpression ] 26 1. Return empty. 27 ---*/ 28 29 var obj; 30 var proto = {}; 31 var ownProp = {}; 32 33 obj = { 34 __proto__: proto, 35 ['__proto__']: {}, 36 ['__proto__']: ownProp 37 }; 38 39 assert.sameValue( 40 Object.getPrototypeOf(obj), 41 proto, 42 'prototype is defined' 43 ); 44 45 assert( 46 Object.prototype.hasOwnProperty.call(obj, '__proto__'), 47 'has own property __proto__' 48 ); 49 50 assert.sameValue( 51 obj.__proto__, 52 ownProp, 53 'own property value' 54 ); 55 56 reportCompare(0, 0);