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

Allow destructuring in catch parameter #1628

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Oct 4, 2021

This Pull Request closes #1600.

It changes the following:

  • Allows ObjectBindingPatterns and ArrayBindingPatterns as CatchParameter
  • Checks early errors for Catch production as defined in 14.15.1
    • If this is out of scope of the issue and should be in separate PR, let me know.

Some design decisions that may need revised:

  • I used node::Declaration as CatchParameter (code) since they are almost identical, the only difference being that CatchParameter won't have initialization. Should I define distinct struct for CatchParameter?
  • I adopted 14.5.1 for early errors rather than its counterpart Annex B.3.4, which most widely used JS engines adopt.

@raskad
Copy link
Member

raskad commented Oct 4, 2021

The new failing tests would be fixed in #1391 so we can ignore them.

Test262 conformance changes:

Test result master count PR count difference
Total 80,930 80,930 0
Passed 33,442 33,564 +122
Ignored 15,898 15,898 0
Failed 31,590 31,468 -122
Panics 0 0 0
Conformance 41.32% 41.47% +0.15%
Fixed tests (126):
test/language/statements/try/scope-catch-param-lex-open.js [strict mode] (previously Failed)
test/language/statements/try/scope-catch-param-lex-open.js (previously Failed)
test/language/statements/try/scope-catch-block-lex-open.js [strict mode] (previously Failed)
test/language/statements/try/scope-catch-block-lex-open.js (previously Failed)
test/language/statements/try/early-catch-lex.js [strict mode] (previously Failed)
test/language/statements/try/early-catch-lex.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-undef.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-undef.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-id.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-id.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-val-null.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-val-null.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj-init.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj-value-null.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj-value-null.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary-trailing-comma.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary-trailing-comma.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-elision.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-elision.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-complete.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-complete.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-skipped.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-skipped.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-val.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-val.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init-throws.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init-throws.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-empty.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-empty.js (previously Failed)
test/language/statements/try/dstr/ary-init-iter-get-err-array-prototype.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-init-iter-get-err-array-prototype.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-hole.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-hole.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-list-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-list-err.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-elem-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-elem-init.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary-value-null.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary-value-null.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-ary-rest.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-ary-rest.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-val-null.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-val-null.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-get-value-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-get-value-err.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init-skipped.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init-skipped.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-ary-elem.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-ary-elem.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-exhausted.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-exhausted.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-obj-id.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-obj-id.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-rest-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-rest-init.js (previously Failed)
test/language/statements/try/dstr/ary-init-iter-get-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-init-iter-get-err.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-rest-iter.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-rest-iter.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-unresolvable.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-unresolvable.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary-init.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-step-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-step-err.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-exhausted.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-exhausted.js (previously Failed)
test/language/statements/try/dstr/ary-name-iter-val.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-name-iter-val.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id-init.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-iter-val-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-iter-val-err.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-id-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-id-init.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-rest-getter.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-rest-getter.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init-unresolvable.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init-unresolvable.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-trailing-comma.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-trailing-comma.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-trailing-comma.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-trailing-comma.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-empty-iter.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-empty-iter.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-done.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-done.js (previously Failed)
test/language/statements/try/dstr/obj-init-undefined.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-init-undefined.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-prop-id.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-init-skipped.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-init-skipped.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-direct.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-rest-id-direct.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-init.js (previously Failed)
test/language/statements/try/dstr/obj-init-null.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-init-null.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-elem-iter.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-ary-elem-iter.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj-value-undef.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-obj-value-undef.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-throws.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-init-throws.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-val-undef.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-obj-val-undef.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-ary.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-get-value-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-prop-id-get-value-err.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-init-unresolvable.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-init-unresolvable.js (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-err.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-ptrn-elem-id-iter-val-err.js (previously Failed)
test/language/statements/try/dstr/ary-init-iter-no-close.js [strict mode] (previously Failed)
test/language/statements/try/dstr/ary-init-iter-no-close.js (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-init-throws.js [strict mode] (previously Failed)
test/language/statements/try/dstr/obj-ptrn-id-init-throws.js (previously Failed)
Broken tests (4):
test/annexB/language/statements/try/catch-redeclared-var-statement-captured.js [strict mode] (previously Passed)
test/annexB/language/statements/try/catch-redeclared-var-statement-captured.js (previously Passed)
test/annexB/language/statements/try/catch-redeclared-var-statement.js [strict mode] (previously Passed)
test/annexB/language/statements/try/catch-redeclared-var-statement.js (previously Passed)

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

One suggestion. Otherwise look really nice. Great work!

boa/src/syntax/parser/statement/try_stm/catch.rs Outdated Show resolved Hide resolved
Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

Great work!

@Razican Razican added this to the v0.14.0 milestone Oct 5, 2021
@raskad raskad merged commit 916c9d8 into boa-dev:master Oct 5, 2021
@jedel1043 jedel1043 added ast Issue surrounding the abstract syntax tree enhancement New feature or request labels Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Issue surrounding the abstract syntax tree enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow BindingPattern as CatchParameter
5 participants