Bug 142390 - ES6: Object Literal Extensions - Methods
Summary: ES6: Object Literal Extensions - Methods
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-06 01:33 PST by Joseph Pecoraro
Modified: 2015-03-06 14:31 PST (History)
4 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (12.39 KB, patch)
2015-03-06 01:38 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] For Bots (26.18 KB, patch)
2015-03-06 01:39 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix - With Computed Method Names (22.95 KB, patch)
2015-03-06 12:06 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix - With Computed Method Names (23.16 KB, patch)
2015-03-06 13:38 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-03-06 01:33:42 PST
* SUMMARY
Object Literal Extensions - Methods.

> ObjectLiteral[Yield] : {}
>     { PropertyDefinitionList[?Yield] }
>     { PropertyDefinitionList[?Yield] , }
>
> PropertyDefinitionList:
>    PropertyDefinition[?Yield]
>    ...
>
> PropertyDefinition[?Yield]
>    ...
>    MethodDefinition[?Yield]
>
> MethodDefinition[Yield] :
>     PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody }

Example:

  var o = {
    foo() { return 10; },
    bar(a, b) { return a + b; },
    100() { return 100; },
    'method'() { return 0; },
  };

This is pretty much identical to class methods, just for object literals.
Comment 1 Joseph Pecoraro 2015-03-06 01:38:40 PST
Created attachment 248054 [details]
[PATCH] Proposed Fix

Requires a patch not yet landed (the PutType stuff).
Comment 2 Joseph Pecoraro 2015-03-06 01:39:57 PST
Created attachment 248055 [details]
[PATCH] For Bots
Comment 3 Joseph Pecoraro 2015-03-06 10:54:47 PST
It should be trivial to extend this to support computed methods as well:

  var o = {
    ["foo" + "bar"]() { return 10; }
  };
  o.foobar();

Since it is highly related, I'll put up a new patch.
Comment 4 Joseph Pecoraro 2015-03-06 12:06:10 PST
Created attachment 248085 [details]
[PATCH] Proposed Fix - With Computed Method Names

Still requires a previous change, so this won't build on the bots.
Comment 5 Joseph Pecoraro 2015-03-06 13:38:38 PST
Created attachment 248095 [details]
[PATCH] Proposed Fix - With Computed Method Names
Comment 6 Geoffrey Garen 2015-03-06 13:48:00 PST
Comment on attachment 248095 [details]
[PATCH] Proposed Fix - With Computed Method Names

r=me
Comment 7 WebKit Commit Bot 2015-03-06 14:31:54 PST
Comment on attachment 248095 [details]
[PATCH] Proposed Fix - With Computed Method Names

Clearing flags on attachment: 248095

Committed r181183: <http://trac.webkit.org/changeset/181183>
Comment 8 WebKit Commit Bot 2015-03-06 14:31:59 PST
All reviewed patches have been landed.  Closing bug.