Closed
Bug 1380881
Opened 8 years ago
Closed 7 years ago
Implement optional catch binding proposal
Categories
(Core :: JavaScript Engine, enhancement, P3)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla58
People
(Reporter: bakkot, Assigned: bakkot)
References
(Blocks 2 open bugs)
Details
(Keywords: dev-doc-complete)
Attachments
(1 file, 2 obsolete files)
13.05 KB,
patch
|
bakkot
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Steps to reproduce:
At the July meeting of TC39, a proposal to make the binding to a 'catch' optional, in which case the exception is silently dropped. See https://github.com/michaelficarra/optional-catch-binding-proposal/
This extends the syntax of try/catch statements to allow `try {} catch {}` and `try {} catch {} finally {}`, with no `(e)` (or other binding form) after the `catch`.
I've attached a patch implementing this proposal. As it hasn't even achieved stage 1 as of this writing, this probably shouldn't be merged yet. I'll update after the meeting.
Updated•8 years ago
|
Attachment #8886432 -
Attachment is patch: true
Attachment #8886432 -
Attachment mime type: text/x-patch → text/plain
Comment 2•7 years ago
|
||
Comment on attachment 8886432 [details] [diff] [review]
0001-Implement-optional-catch-binding.patch
Review of attachment 8886432 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me.
Bakkot, when you upload a new patch with the nits fixed, please carry the r=shu and mark this bug as checkin-needed, thanks!
::: js/src/frontend/BytecodeEmitter.cpp
@@ +6916,4 @@
> EmitterScope emitterScope(this);
> ScopeKind kind;
> if (body->isKind(PNK_CATCH))
> + kind = (!body->pn_kid1 || body->pn_kid1->isKind(PNK_NAME)) ? ScopeKind::SimpleCatch : ScopeKind::Catch;
Nit: >100 chars.
::: js/src/frontend/Parser.cpp
@@ +7045,3 @@
> * where lhs is a name or a destructuring left-hand side.
> + * The second is legal only #ifdef JS_HAS_CATCH_GUARD,
> + * the third is a proposed feature from TC39.
Seems like a shoo-in to become part of the spec at this point. I think it's safe to omit the "the third is ..." sentence.
::: js/src/tests/ecma_2018/Syntax/omitted-catch-binding.js
@@ +32,5 @@
> +}
> +assertEq(reached, true);
> +
> +if (typeof reportCompare === "function")
> + reportCompare(0, 0);
I don't mind having this test in js/src/tests, but it seems like it would be superseded by a test262 test right quick. Do you have upstream test262 PRs for this feature?
Attachment #8886432 -
Flags: review+
Comment 3•7 years ago
|
||
WRT tests, I am sending an update with test262 tests for this soon (Monday, probably).
Comment 4•7 years ago
|
||
Anything holding up landing this?
Assignee: nobody → bakkot
Severity: normal → enhancement
Status: UNCONFIRMED → ASSIGNED
status-firefox57:
--- → wontfix
status-firefox58:
--- → fix-optional
Ever confirmed: true
Priority: -- → P3
Sorry I lost track of this. Patch got stale in the mean time; here's a new version with nits addressed.
Not sure if I'm doing the review thing right, or how to mark this as checkin-needed.
Attachment #8886432 -
Attachment is obsolete: true
Attachment #8927064 -
Flags: review+
Whoops, wrong version of patch file... Sigh.
Attachment #8927064 -
Attachment is obsolete: true
Attachment #8927101 -
Flags: review+
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/8cbd780d86fc
Implement optional catch binding proposal. r=shu
Thanks for your patch! I just pushed this myself after resolving a trivial merge conflict and fixing the commit message. You can request check-in by setting "checkin-needed" in the keywords field.
Keywords: checkin-needed
Updated•7 years ago
|
Keywords: checkin-needed
Comment 9•7 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Updated•7 years ago
|
Keywords: dev-doc-needed
Comment 10•7 years ago
|
||
I've added a bit of documentation to the "try...catch" MDN article here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#The_exception_identifier
Updated•7 years ago
|
Blocks: es-proposals-stage-3
Comment 11•7 years ago
|
||
Thanks, I've also added this to Fx58 for developers
https://developer.mozilla.org/en-US/Firefox/Releases/58#JavaScript
And to our compat data:
https://github.com/mdn/browser-compat-data/pull/1152
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•