Summary: | ES6: Object Literal Methods toString is missing method name | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Joseph Pecoraro <joepeck> | ||||
Component: | JavaScriptCore | Assignee: | Joseph Pecoraro <joepeck> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | commit-queue, ggaren, joepeck | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Attachments: |
|
Description
Joseph Pecoraro
2015-03-23 15:45:25 PDT
Function.prototype.string: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-function.prototype.tostring Note that the output can, and should be, the syntax of a `MethodDefinition`, not `FunctionDeclaration FunctionExpression` in this case. I'm not sure what would be best for computed method names: o = { ['method'](a,b){} }; o.method.name; // "" o.method.toString(); // => ??? That is a MethodDefinition. Firefox outputs "function (a,b){}" in that case, which I think makes some sense. Wow, I didn't realize this, but this was in my test and failing: =( LayoutTests/js/object-literal-methods.html (In reply to comment #2) > Wow, I didn't realize this, but this was in my test and failing: =( > LayoutTests/js/object-literal-methods.html Oh, never mind. This broke with r181810! <https://webkit.org/b/142853> Function.prototype.toString should not decompile the AST It looks like Firefox strigifies by concatenating "function " + function.name + [all text from opening paren to closing brace], with a separate code path for arrow functions. I think that's a reasonable solution. (In reply to comment #4) > It looks like Firefox strigifies by concatenating "function " + > function.name + [all text from opening paren to closing brace], with a > separate code path for arrow functions. I think that's a reasonable solution. This will add back the space for an anonymous function: (function(a,b){}).toString(); // Currently : "function(a,b){}" // Always Space: "function (a,b){}" But this does match Firefox, always adding the space. So I'll go that route. Created attachment 249305 [details]
[PATCH] Proposed Fix
I want this to run through all tests on EWS because I only did a subset based on what the previous change had changed.
Comment on attachment 249305 [details]
[PATCH] Proposed Fix
r=me
Comment on attachment 249305 [details] [PATCH] Proposed Fix Clearing flags on attachment: 249305 Committed r181901: <http://trac.webkit.org/changeset/181901> All reviewed patches have been landed. Closing bug. |