Bug 142353

Summary: ES6: Object Literal Extensions - Shorthand Properties (Identifiers)
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: JavaScriptCoreAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, buildbot, commit-queue, ggaren, joepeck, rniwa, ysuzuki
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[PATCH] Proposed Fix
joepeck: commit-queue-
Archive of layout-test-results from ews100 for mac-mavericks
none
Archive of layout-test-results from ews105 for mac-mavericks-wk2
none
[PATCH] Proposed Fix
none
Archive of layout-test-results from ews105 for mac-mavericks-wk2
none
Archive of layout-test-results from ews101 for mac-mavericks
none
[PATCH] Proposed Fix none

Description Joseph Pecoraro 2015-03-05 12:01:15 PST
* SUMMARY
Object Literal Extensions - Shorthand Properties (Identifiers).

ES6 Allows Identifiers in Object Literal Construction.
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer

>   ObjectLiteral[Yield] :
>       { }
>       { PropertyDefinitionList[?Yield] }
>       { PropertyDefinitionList[?Yield] , }
>   
>   PropertyDefinitionList[Yield] :
>       PropertyDefinition[?Yield]
>       ...
>   
>   PropertyDefinition[Yield] :
>       IdentifierReference[?Yield]
>       ...

Works by using the identifier name as the property name and identifier value as property value:

    var x = {foo};
    // is equivalent to:
    var x = {foo: foo};
Comment 1 Joseph Pecoraro 2015-03-05 12:01:44 PST
I have a fix, just need to write tests.
Comment 2 Yusuke Suzuki 2015-03-05 12:05:22 PST
really great! Since ArrayIterator, StringIterator.prototype.next have { done:done, value: value } JS code, we can apply this enhancement to them :D
Comment 3 Joseph Pecoraro 2015-03-05 12:15:14 PST
(In reply to comment #2)
> really great! Since ArrayIterator, StringIterator.prototype.next have {
> done:done, value: value } JS code, we can apply this enhancement to them :D

Yep! And the Inspector has ~168 occurrences of this pattern.
Comment 4 Joseph Pecoraro 2015-03-05 13:42:18 PST
Created attachment 247994 [details]
[PATCH] Proposed Fix
Comment 5 Joseph Pecoraro 2015-03-05 13:46:11 PST
Comment on attachment 247994 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=247994&action=review

> LayoutTests/js/object-literal-shorthand-construction-expected.txt:57
> +PASS ({get}) threw exception SyntaxError: Unexpected token '}'.
> +PASS ({set}) threw exception SyntaxError: Unexpected token '}'.

This may be wrong. Firefox allows it, Chrome does not. Let me re-read and confirm correct behavior. My guess would be this is supposed to work.
Comment 6 Build Bot 2015-03-05 14:04:51 PST
Comment on attachment 247994 [details]
[PATCH] Proposed Fix

Attachment 247994 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/6125427387006976

New failing tests:
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8_T2.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8.1_T1.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8_T3.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.4_The_for_in_Statement/S12.6.4_A15.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8.1_T2.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8.1_T3.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8_T1.html
sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1.html
sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T2.html
Comment 7 Build Bot 2015-03-05 14:04:54 PST
Created attachment 247998 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 8 Build Bot 2015-03-05 14:25:59 PST
Comment on attachment 247994 [details]
[PATCH] Proposed Fix

Attachment 247994 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4755122366185472

New failing tests:
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8_T2.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8.1_T1.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8_T3.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.4_The_for_in_Statement/S12.6.4_A15.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8.1_T2.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8.1_T3.html
sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A8_T1.html
sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1.html
sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T2.html
Comment 9 Build Bot 2015-03-05 14:26:01 PST
Created attachment 248001 [details]
Archive of layout-test-results from ews105 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 10 Joseph Pecoraro 2015-03-05 15:08:07 PST
Created attachment 248006 [details]
[PATCH] Proposed Fix

- Rebases the sputnik tests that are now expected to fail due to the new syntax with failing results. (Some of the error messages are slightly worse, but not sure we can improve that).
- Now allows {get}/{set} expansion to {get:get}/etc.
Comment 11 Joseph Pecoraro 2015-03-05 15:11:14 PST
Comment on attachment 248006 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=248006&action=review

> Source/JavaScriptCore/parser/Parser.cpp:1949
> +        currentScope()->useVariable(ident, m_vm->propertyNames->eval == *ident);

I'm not 100% certain what this isEval is for. The only other use of useVariable(), parsePrimaryExpression, does this, so I matched it since I assume if "x = eval" sets the flag then "x = {eval}" should as well.
Comment 12 Build Bot 2015-03-05 15:43:20 PST
Comment on attachment 248006 [details]
[PATCH] Proposed Fix

Attachment 248006 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6644674437578752

New failing tests:
js/basic-computed-property-name.html
js/property-getters-and-setters.html
js/array-from.html
Comment 13 Build Bot 2015-03-05 15:43:23 PST
Created attachment 248012 [details]
Archive of layout-test-results from ews105 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 14 Build Bot 2015-03-05 16:01:37 PST
Comment on attachment 248006 [details]
[PATCH] Proposed Fix

Attachment 248006 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/6518302004215808

New failing tests:
js/basic-computed-property-name.html
js/property-getters-and-setters.html
js/array-from.html
Comment 15 Build Bot 2015-03-05 16:01:41 PST
Created attachment 248014 [details]
Archive of layout-test-results from ews101 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 16 Joseph Pecoraro 2015-03-05 16:06:32 PST
Comment on attachment 248006 [details]
[PATCH] Proposed Fix

Broke getter/setter syntax with non-identifier names:

  get 42() {}
  get 'prop'() {}
Comment 17 Joseph Pecoraro 2015-03-05 16:20:37 PST
Created attachment 248016 [details]
[PATCH] Proposed Fix

Even simpler now. Take 3!
Comment 18 Geoffrey Garen 2015-03-05 16:29:39 PST
Comment on attachment 248016 [details]
[PATCH] Proposed Fix

r=me
Comment 19 WebKit Commit Bot 2015-03-05 17:16:51 PST
Comment on attachment 248016 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 248016

Committed r181121: <http://trac.webkit.org/changeset/181121>
Comment 20 WebKit Commit Bot 2015-03-05 17:16:56 PST
All reviewed patches have been landed.  Closing bug.
Comment 21 Joseph Pecoraro 2015-03-05 19:31:46 PST
Looks like this is failing some JSC tests on the bots because:

> -PASS equivalent({eval}, {eval: window.eval}) is true
> +FAIL equivalent({eval}, {eval: window.eval}) should be true. Threw exception ReferenceError: Can't find variable: window

I'll just remove window.
Comment 22 Joseph Pecoraro 2015-03-05 19:47:35 PST
Attempted to fix the bots with:
<http://trac.webkit.org/changeset/181130>