WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
164830
Web Inspector: Update Esprima to support new features / syntax (**, async/await, trailing comma)
https://bugs.webkit.org/show_bug.cgi?id=164830
Summary
Web Inspector: Update Esprima to support new features / syntax (**, async/awa...
Joseph Pecoraro
Reported
2016-11-16 12:27:47 PST
Summary: Update Esprima to support new features / syntax (**, async/await, trailing comma) Currently we fail to parse / pretty print code that has ES2017 features which JavaScriptCore supports: * Exponentiation operators (**, **=) * async/await functions * Trailing commas All of which are supported in Esprima trunk (4.0.0-dev after its latest release 3.1.1).
Attachments
[PATCH] Proposed Fix
(486.98 KB, patch)
2016-11-16 12:39 PST
,
Joseph Pecoraro
joepeck
: review-
joepeck
: commit-queue-
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(494.46 KB, patch)
2016-11-16 13:18 PST
,
Joseph Pecoraro
timothy
: review+
joepeck
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2016-11-16 12:30:45 PST
<
rdar://problem/29293814
>
Joseph Pecoraro
Comment 2
2016-11-16 12:39:25 PST
Created
attachment 294963
[details]
[PATCH] Proposed Fix
Joseph Pecoraro
Comment 3
2016-11-16 12:42:04 PST
Comment on
attachment 294963
[details]
[PATCH] Proposed Fix Err some tests need an update.
Joseph Pecoraro
Comment 4
2016-11-16 13:18:32 PST
Created
attachment 294969
[details]
[PATCH] Proposed Fix
Saam Barati
Comment 5
2016-11-16 13:42:36 PST
Comment on
attachment 294969
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=294969&action=review
> LayoutTests/inspector/formatting/resources/javascript-tests/classes-expected.js:121 > + async a()
what about adding tests for: 1. async computed properties 2. async string literal methods 3. async number literal methods also, all of the above, but in an object literal instead of a class.
> Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js:-537 > - defaults: node.defaults.map(this._createInternalSyntaxTree, this),
Why did this go away?
> Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js:-682 > - defaults: node.defaults.map(this._createInternalSyntaxTree, this),
Ditto. Was this replaced with something else?
Joseph Pecoraro
Comment 6
2016-11-16 14:09:26 PST
Comment on
attachment 294969
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=294969&action=review
>> Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js:-682 >> - defaults: node.defaults.map(this._createInternalSyntaxTree, this), > > Ditto. Was this replaced with something else?
Yes this was mentioned in the ChangeLog. Now, `params` has an AssignmentPattern if there are default values, instead of this separate, out of flow `defaults` list.
Joseph Pecoraro
Comment 7
2016-11-17 11:31:56 PST
> What about adding tests for: > > 1. async computed properties > 2. async string literal methods > 3. async number literal methods
It turns out Esprima fails to parse each of these obscure cases. I filed:
https://github.com/jquery/esprima/issues/1626
Joseph Pecoraro
Comment 8
2016-11-17 11:33:18 PST
Comment on
attachment 294969
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=294969&action=review
> Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:220 > + if (tokenValue === "async" && node.parent.type === "Property" && node.parent.value.async && token.range[1] !== node.range[1])
I made an adjustment and dropped the node.parent.value.async case in order to handle this case properly: o = { async "foo": function(){} } I'll likewise add a test for it.
Joseph Pecoraro
Comment 9
2016-11-17 11:35:01 PST
(In reply to
comment #8
)
> Comment on
attachment 294969
[details]
> [PATCH] Proposed Fix > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=294969&action=review
> > > Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:220 > > + if (tokenValue === "async" && node.parent.type === "Property" && node.parent.value.async && token.range[1] !== node.range[1]) > > I made an adjustment and dropped the node.parent.value.async case in order > to handle this case properly: > > o = { async "foo": function(){} }
Err on second thought this should not be valid.
Joseph Pecoraro
Comment 10
2016-11-17 11:37:13 PST
Comment on
attachment 294969
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=294969&action=review
>>> Source/WebInspectorUI/UserInterface/Workers/Formatter/EsprimaFormatter.js:220 >>> + if (tokenValue === "async" && node.parent.type === "Property" && node.parent.value.async && token.range[1] !== node.range[1]) >> >> I made an adjustment and dropped the node.parent.value.async case in order to handle this case properly: >> >> o = { async "foo": function(){} } >> >> I'll likewise add a test for it. > > Err on second thought this should not be valid.
Esprima incorrectly allows: o = {async foo:function(){}} So I'll revert back to what was in this patch.
Joseph Pecoraro
Comment 11
2016-12-07 16:02:06 PST
Went with: Esprima@7219731 which fixed a few issues around async function syntax.
Joseph Pecoraro
Comment 12
2016-12-07 16:04:57 PST
https://trac.webkit.org/changeset/209491
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug