-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support optional try/catch binding as added in Node 10 & V8 6.6 #1953
Comments
Hi @Avuxo, thanks for the report. For a new language feature, we usually need more details, see this guide. For some examples, see e.g. #1550. Please review the issue description to include the necessary information. |
This syntax has been supported in browsers for nearly a year! Lets see what we can do to move this forward. |
ES2019 Feature: Optional catch binding: Tracking IssueSyntax:try { } catch { } New production for Catch[Yield, Await, Return]:
catch ( CatchParameter[?Yield, ?Await] ) Block[?Yield, ?Await, ?Return]
+ catch Block[?Yield, ?Await, ?Return] Spec:https://github.com/tc39/proposal-optional-catch-binding Remaining Tasks:
Additional considerations
|
This was added to ESTree for ES2019: This document specifies the extensions to the core ESTree AST types to support the ES2019 grammar. StatementsCatchClauseextend interface CatchClause {
param: Pattern | null;
} The |
…eatures https://bugs.webkit.org/show_bug.cgi?id=200796 Reviewed by Ross Kirsling. Source/WebInspectorUI: Use a fork of Esprima to support modern JavaScript language features while going through the process to upstream support: ES2018 Feature: Async Iteration (for-await-of) jquery/esprima#1990 ES2019 Feature: Numeric Separator jquery/esprima#1989 ES2019 Feature: Optional catch binding jquery/esprima#1953 ES2020 Feature: BigInt jquery/esprima#1988 ESTree compatible AST changes are summarized as: - CatchClause `param` property is now nullable - ForOfStatement now has a boolean `await` property - Literal can be a `"bigint"` type (works if the environment has BigInt or not) The pretty printer only needed to have additional handling for `for-await-of`. * UserInterface/External/Esprima/esprima.js: New version. Typescript output expects a modern JavaScript environment instead of just ES6. * Tools/Formatting/index.html: Update the formatting tool for easier use in case of errors. * UserInterface/Models/ScriptSyntaxTree.js: (WI.ScriptSyntaxTree.prototype._createInternalSyntaxTree): * UserInterface/Test/TestHarness.js: (TestHarness.prototype.passOrFail): Convenience for pass/fail with the same message based on a condition. * UserInterface/Workers/Formatter/EsprimaFormatter.js: (EsprimaFormatter.prototype._handleTokenAtNode): Ensure a space after `await` in `for await` syntax. LayoutTests: * inspector/formatting/resources/javascript-tests/classes-expected.js: * inspector/formatting/resources/javascript-tests/classes.js: * inspector/formatting/resources/javascript-tests/for-statements-expected.js: * inspector/formatting/resources/javascript-tests/for-statements.js: * inspector/formatting/resources/javascript-tests/generators-expected.js: * inspector/formatting/resources/javascript-tests/generators.js: * inspector/formatting/resources/javascript-tests/numbers-expected.js: Added. * inspector/formatting/resources/javascript-tests/numbers.js: Added. * inspector/formatting/resources/javascript-tests/try-catch-finally-statements-expected.js: * inspector/formatting/resources/javascript-tests/try-catch-finally-statements.js: * inspector/formatting/resources/javascript-tests/unary-binary-expressions-expected.js: * inspector/formatting/resources/javascript-tests/unary-binary-expressions.js: Test formatting of new JavaScript language features. * inspector/formatting/formatting-css-expected.txt: * inspector/formatting/formatting-javascript-expected.txt: * inspector/formatting/formatting-javascript.html: * inspector/formatting/resources/utilities.js: (TestPage.registerInitializer.async.runFormattingTest): (TestPage.registerInitializer.window.addFormattingTests): (TestPage.registerInitializer): Cleaner output and better handling for debugging failures. * inspector/model/parse-script-syntax-tree.html: Test new AST permutations. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@248760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Thanks for adding some more important details @JosephPecoraro! |
Any update on this? It still seems to be invalid on the demo page: https://esprima.org/demo/parse.html?code=try%20%7B%7D%20catch%20%7B%7D We would really appreciate this fix! Thanks! |
Support for this ECMAScript Stage 4 proposal. This has already been implemented in v8 6.6 and as a result is already implemented in new versions of Google Chrome/Chromium and Node.js 10. This language feature is used in the Node.js `assert' standard library, so any users who attempt to apply the parser to that file will encounter this error.
Previously, try/catch statements required a binding to be syntactically valid. However, with this change they are no longer a requirement as the binding is now optional.
This issue would be a fairly simple implementation and would likely not add any significant overhead to the parsing process.
Steps to reproduce
Expected output
Actual output
Relevant references
The text was updated successfully, but these errors were encountered: