[Webkit-unassigned] [Bug 142895] New: ES6: Allow duplicate property names

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Mar 19 20:19:19 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=142895

            Bug ID: 142895
           Summary: ES6: Allow duplicate property names
    Classification: Unclassified
           Product: WebKit
           Version: 528+ (Nightly build)
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: joepeck at webkit.org
                CC: ggaren at apple.com, rniwa at webkit.org

* SUMMARY
ES6 allows duplicate property names where ES5 (strict mode) did not:
<https://people.mozilla.org/~jorendorff/es6-draft.html#sec-additions-and-changes-that-introduce-incompatibilities-with-prior-editions>

> Annex E: Additions and Changes That Introduce Incompatibilities with Prior Editions
> 12.2.5.1: In Edition 6, it is no longer an early error to have duplicate property names in Object Initializers.

> July 18, 2014 Draft Rev 26
> Eliminated duplicate property name restrictions on object literals and class definitions

> Deleted:
> ObjectLiteral : { PropertyDefinitionList }
> ObjectLiteral : { PropertyDefinitionList , }
> 
> <#>It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate entries, unless one of the following conditions aretrueforeachduplicateentry: 
> <#>The source code corresponding to PropertyDefinitionList is not strict code and all occurrences in the list of the duplicated entry were obtained from productions of the form PropertyDefinition : PropertyName : AssignmentExpression.
> <#>The duplicated entry occurs exactly twice in the list and one occurrence was obtained from a get accessor MethodDefinition and the other occurrence was obtained from a set accessor MethodDefinition.



Removing duplicate detection offers us an opportunity to also fix these cases:


* TESTS

/* Test 1 - ensure computed property eliminates the getter, and then the setter eliminates the property */
x = 0;
var o = {
    ["foo"]:++x,
    get foo() { return -2; },
    ["foo"]:++x,
    set foo(x) { return 0; },
};
console.log(Object.getOwnPropertyDescriptor(o)); // only setter
console.log(o.foo); // undefined
console.log(x); // 2

/* Test 2 - ensure getter doesn't get erased when setting setter*/
x = 0;
var o = {    
    ["foo"]:++x,
    get foo() { return -2; },
    set foo(x) { return 0; },
};

console.log(Object.getOwnPropertyDescriptor(o)); // getter and setter
console.log(o.foo); // -2
console.log(x); // 1


/* Test 3 - ensure getter doesn't get erased */
x = 0;
var o = {
    ["foo"]:++x,
    get foo() { return -2; },
    set foo(x) { return 0; },
    foo:99,
};

console.log(Object.getOwnPropertyDescriptor(o)); // value
console.log(o.foo); // 99
console.log(x); // 1

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150320/06f6e1b3/attachment-0002.html>


More information about the webkit-unassigned mailing list