Skip to content
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

Add support for optional catch binding syntax #5310

Merged
merged 1 commit into from
Oct 31, 2018

Conversation

zenparsing
Copy link
Contributor

@zenparsing zenparsing commented Jun 13, 2018

Adds support for optional catch binding syntax, now at stage 4 and implemented in V8, SM, and JSC.

This is my first PR; I'll appreciate any and all feedback!

Resolves #5210

@pleath
Copy link
Contributor

pleath commented Jun 13, 2018

Nice! Thanks, @zenparsing . Two things that would be good to confirm are that heap enumeration and F12 debugging can handle this syntax. There are heap enum tests in the full repo and tests in DebuggerCommon in the core repo that you can use as a model for testing F12 enumeration of locals.

try {
throw new Error();
} catch {
throw new Err();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a rethrow syntax as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking a look at the proposal it doesn't look like it. Seems like having throw; would have been interesting (like C# does), but it seems like if you want to rethrow then you'll need the parameter binding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I like that you still have to be explicit if you want to rethrow, I always found throw; in C++ to be kind of obtuse.

@@ -578,6 +578,7 @@ ParseNodeTry::ParseNodeTry(OpCode nop, charcount_t ichMin, charcount_t ichLim)
ParseNodeCatch::ParseNodeCatch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
: ParseNodeStmt(nop, ichMin, ichLim)
{
this->pnodeParam = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm interesting. Could you initialize this at initialization list of the constructor?

@akroshg
Copy link
Contributor

akroshg commented Jun 14, 2018

    Indent(indentAmt);

do you need to update this? try running your scenario with -trace:parse and see everything as expected.


Refers to: lib/Parser/Parse.cpp:13730 in 54695a0. [](commit_id = 54695a0, deletion_comment = False)

@akroshg
Copy link
Contributor

akroshg commented Jun 14, 2018

Thanks for mentioning that. Also I'd like few test to be added with new syntax which are under debugger and heap-enum.


In reply to: 397101019 [](ancestors = 397101019)

@aneeshdk
Copy link
Contributor

Are we not putting this under a flag?

@aneeshdk
Copy link
Contributor

Can you add couple more test cases with eval, var leaking in catch scope, with scope in catch block and function definitions inside catch block?

@akroshg
Copy link
Contributor

akroshg commented Jun 15, 2018

@aneeshdk - we should have flag to on and off this feature. But I'd vote for having this enable by-default ON.

@akroshg
Copy link
Contributor

akroshg commented Jun 15, 2018

@zenparsing are there any test262 tests for this feature and do we know how many pass/fail?

@kfarnung
Copy link
Contributor

@zenparsing @akroshg @aneeshdk What is left to get this landed?

@zenparsing zenparsing force-pushed the optional-catch-binding branch 2 times, most recently from d2464c1 to eca32ed Compare September 21, 2018 20:03
@zenparsing
Copy link
Contributor Author

@kfarnung I've updated tests and rebased, but I have not yet implemented a flag for this feature.

@zenparsing
Copy link
Contributor Author

Do we still want an always-true flag for this? It's been unflagged in v8 for a while now.

@pleath
Copy link
Contributor

pleath commented Oct 12, 2018

If the syntax is sure to stay in the spec, I think we can do without the flag.

Copy link
Contributor

@boingoing boingoing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chakrabot chakrabot merged commit 133f30a into chakra-core:master Oct 31, 2018
chakrabot pushed a commit that referenced this pull request Oct 31, 2018
Merge pull request #5310 from zenparsing:optional-catch-binding

Adds support for [optional catch binding syntax](https://tc39.github.io/proposal-optional-catch-binding), now at stage 4 and implemented in V8, SM, and JSC.

This is my first PR; I'll appreciate any and all feedback!

Resolves #5210
@zenparsing zenparsing deleted the optional-catch-binding branch June 13, 2019 15:11
@thw0rted
Copy link

thw0rted commented Dec 4, 2019

Is this patch never going to reach production because Edge is switching to a Chromium backend now? This SO question leaves devs with the impression that Edge should either support the syntax already, or is going to at some point in the future. Is that still true?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

optional catch binding
9 participants