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

[Merged by Bors] - Implement async arrow functions #2393

Closed
wants to merge 1 commit into from

Conversation

raskad
Copy link
Member

@raskad raskad commented Oct 30, 2022

This Pull Request fixes #1805.

It changes the following:

  • Implement async arrow function parsing and execution.
  • Handle special case when a function expressions binding identifier need to be bound in the function body.
  • Implement special silent ignored assignment for the above case.
  • Fix issue with getting the correct promise capability for function returns.
  • Complete function object toString todo.

I will fix the two failing assignmenttargettype tests in a follow up PR.

@raskad raskad added enhancement New feature or request parser Issues surrounding the parser execution Issues or PRs related to code execution labels Oct 30, 2022
@raskad raskad added this to the v0.17.0 milestone Oct 30, 2022
@github-actions
Copy link

github-actions bot commented Oct 30, 2022

Test262 conformance changes

Test result main count PR count difference
Total 93,789 93,789 0
Passed 69,328 69,513 +185
Ignored 18,352 18,352 0
Failed 6,109 5,924 -185
Panics 0 0 0
Conformance 73.92% 74.12% +0.20%
Fixed tests (187):
test/built-ins/GeneratorFunction/is-a-constructor.js [strict mode] (previously Failed)
test/built-ins/GeneratorFunction/is-a-constructor.js (previously Failed)
test/built-ins/AsyncGeneratorFunction/is-a-constructor.js [strict mode] (previously Failed)
test/built-ins/AsyncGeneratorFunction/is-a-constructor.js (previously Failed)
test/built-ins/AsyncFunction/is-a-constructor.js [strict mode] (previously Failed)
test/built-ins/AsyncFunction/is-a-constructor.js (previously Failed)
test/built-ins/Object/seal/seal-asyncarrowfunction.js [strict mode] (previously Failed)
test/built-ins/Object/seal/seal-asyncarrowfunction.js (previously Failed)
test/built-ins/AsyncArrowFunction/is-a-constructor.js [strict mode] (previously Failed)
test/built-ins/AsyncArrowFunction/is-a-constructor.js (previously Failed)
test/language/statements/function/S13_A3_T1.js [strict mode] (previously Failed)
test/language/statements/function/S13_A3_T1.js (previously Failed)
test/language/statements/function/S14_A2.js [strict mode] (previously Failed)
test/language/statements/function/S14_A2.js (previously Failed)
test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/statements/class/cpn-class-decl-fields-methods-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/statements/class/cpn-class-decl-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/statements/class/cpn-class-decl-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/statements/class/cpn-class-decl-fields-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/statements/class/cpn-class-decl-accessors-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/statements/class/elements/private-field-as-async-arrow-function.js [strict mode] (previously Failed)
test/language/statements/class/elements/private-field-as-async-arrow-function.js (previously Failed)
test/language/statements/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/statements/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/statements/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/statements/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/statements/class/elements/async-private-method/returns-async-arrow.js [strict mode] (previously Failed)
test/language/statements/class/elements/async-private-method/returns-async-arrow.js (previously Failed)
test/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/statements/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/statements/class/elements/async-private-method-static/returns-async-arrow.js [strict mode] (previously Failed)
test/language/statements/class/elements/async-private-method-static/returns-async-arrow.js (previously Failed)
test/language/statements/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/statements/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/statements/class/async-method/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/statements/class/async-method/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/statements/class/async-method/returns-async-arrow.js [strict mode] (previously Failed)
test/language/statements/class/async-method/returns-async-arrow.js (previously Failed)
test/language/statements/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/statements/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/statements/class/async-method-static/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/statements/class/async-method-static/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/statements/class/async-method-static/returns-async-arrow.js [strict mode] (previously Failed)
test/language/statements/class/async-method-static/returns-async-arrow.js (previously Failed)
test/language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/statements/async-function/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/statements/async-function/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/statements/async-function/returns-async-arrow.js [strict mode] (previously Failed)
test/language/statements/async-function/returns-async-arrow.js (previously Failed)
test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body.js [strict mode] (previously Failed)
test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body.js (previously Failed)
test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-eval.js [strict mode] (previously Failed)
test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-eval.js (previously Failed)
test/language/expressions/async-generator/named-strict-error-reassign-fn-name-in-body-in-arrow.js [strict mode] (previously Failed)
test/language/expressions/async-generator/named-no-strict-reassign-fn-name-in-body-in-arrow.js (previously Failed)
test/language/expressions/function/named-strict-error-reassign-fn-name-in-body.js [strict mode] (previously Failed)
test/language/expressions/function/scope-name-var-open-strict.js [strict mode] (previously Failed)
test/language/expressions/function/named-no-strict-reassign-fn-name-in-body.js (previously Failed)
test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-eval.js [strict mode] (previously Failed)
test/language/expressions/function/scope-name-var-close.js [strict mode] (previously Failed)
test/language/expressions/function/scope-name-var-close.js (previously Failed)
test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-eval.js (previously Failed)
test/language/expressions/function/named-strict-error-reassign-fn-name-in-body-in-arrow.js [strict mode] (previously Failed)
test/language/expressions/function/named-no-strict-reassign-fn-name-in-body-in-arrow.js (previously Failed)
test/language/expressions/function/scope-name-var-open-non-strict.js (previously Failed)
test/language/expressions/object/cpn-obj-lit-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/expressions/object/cpn-obj-lit-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/expressions/object/method-definition/async-returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/async-returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/expressions/object/method-definition/async-returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/async-returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/expressions/object/method-definition/async-returns-async-arrow.js [strict mode] (previously Failed)
test/language/expressions/object/method-definition/async-returns-async-arrow.js (previously Failed)
test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body.js [strict mode] (previously Failed)
test/language/expressions/generators/scope-name-var-open-strict.js [strict mode] (previously Failed)
test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body.js (previously Failed)
test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-eval.js [strict mode] (previously Failed)
test/language/expressions/generators/scope-name-var-close.js [strict mode] (previously Failed)
test/language/expressions/generators/scope-name-var-close.js (previously Failed)
test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-eval.js (previously Failed)
test/language/expressions/generators/named-strict-error-reassign-fn-name-in-body-in-arrow.js [strict mode] (previously Failed)
test/language/expressions/generators/named-no-strict-reassign-fn-name-in-body-in-arrow.js (previously Failed)
test/language/expressions/generators/scope-name-var-open-non-strict.js (previously Failed)
test/language/expressions/async-arrow-function/name.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/name.js (previously Failed)
test/language/expressions/async-arrow-function/eval-var-scope-syntax-err.js (previously Failed)
test/language/expressions/async-arrow-function/try-return-finally-return.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-return-finally-return.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-arg-val-undefined.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-arg-val-undefined.js (previously Failed)
test/language/expressions/async-arrow-function/try-reject-finally-return.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-reject-finally-return.js (previously Failed)
test/language/expressions/async-arrow-function/try-reject-finally-throw.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-reject-finally-throw.js (previously Failed)
test/language/expressions/async-arrow-function/try-throw-finally-throw.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-throw-finally-throw.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-ref-prior.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-ref-prior.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-ref-later.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-ref-later.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-arg-val-not-undefined.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-arg-val-not-undefined.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-trailing-comma.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-trailing-comma.js (previously Failed)
test/language/expressions/async-arrow-function/try-throw-finally-reject.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-throw-finally-reject.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-ref-self.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-ref-self.js (previously Failed)
test/language/expressions/async-arrow-function/params-trailing-comma-single.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/params-trailing-comma-single.js (previously Failed)
test/language/expressions/async-arrow-function/arrow-returns-promise.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/arrow-returns-promise.js (previously Failed)
test/language/expressions/async-arrow-function/try-return-finally-reject.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-return-finally-reject.js (previously Failed)
test/language/expressions/async-arrow-function/try-return-finally-throw.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-return-finally-throw.js (previously Failed)
test/language/expressions/async-arrow-function/try-reject-finally-reject.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-reject-finally-reject.js (previously Failed)
test/language/expressions/async-arrow-function/try-throw-finally-return.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/try-throw-finally-return.js (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-abrupt.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/dflt-params-abrupt.js (previously Failed)
test/language/expressions/async-arrow-function/params-trailing-comma-multiple.js [strict mode] (previously Failed)
test/language/expressions/async-arrow-function/params-trailing-comma-multiple.js (previously Failed)
test/language/expressions/async-arrow-function/forbidden-ext/b1/async-arrow-function-forbidden-ext-direct-access-prop-arguments.js (previously Failed)
test/language/expressions/async-arrow-function/forbidden-ext/b1/async-arrow-function-forbidden-ext-direct-access-prop-caller.js (previously Failed)
test/language/expressions/async-arrow-function/forbidden-ext/b2/async-arrow-function-forbidden-ext-indirect-access-own-prop-caller-value.js (previously Failed)
test/language/expressions/async-arrow-function/forbidden-ext/b2/async-arrow-function-forbidden-ext-indirect-access-own-prop-caller-get.js (previously Failed)
test/language/expressions/async-arrow-function/forbidden-ext/b2/async-arrow-function-forbidden-ext-indirect-access-prop-caller.js (previously Failed)
test/language/expressions/class/cpn-class-expr-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/expressions/class/cpn-class-expr-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/expressions/class/heritage-async-arrow-function.js [strict mode] (previously Failed)
test/language/expressions/class/heritage-async-arrow-function.js (previously Failed)
test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/expressions/class/cpn-class-expr-fields-methods-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/expressions/class/cpn-class-expr-accessors-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-async-arrow-function-expression.js [strict mode] (previously Failed)
test/language/expressions/class/cpn-class-expr-fields-computed-property-name-from-async-arrow-function-expression.js (previously Failed)
test/language/expressions/class/heritage-arrow-function.js [strict mode] (previously Failed)
test/language/expressions/class/heritage-arrow-function.js (previously Failed)
test/language/expressions/class/elements/private-field-as-async-arrow-function.js [strict mode] (previously Failed)
test/language/expressions/class/elements/private-field-as-async-arrow-function.js (previously Failed)
test/language/expressions/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/expressions/class/elements/async-private-method/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/expressions/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/expressions/class/elements/async-private-method/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/expressions/class/elements/async-private-method/returns-async-arrow.js [strict mode] (previously Failed)
test/language/expressions/class/elements/async-private-method/returns-async-arrow.js (previously Failed)
test/language/expressions/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/expressions/class/elements/async-private-method-static/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/expressions/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/expressions/class/elements/async-private-method-static/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/expressions/class/elements/async-private-method-static/returns-async-arrow.js [strict mode] (previously Failed)
test/language/expressions/class/elements/async-private-method-static/returns-async-arrow.js (previously Failed)
test/language/expressions/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/expressions/class/async-method/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/expressions/class/async-method/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/expressions/class/async-method/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/expressions/class/async-method/returns-async-arrow.js [strict mode] (previously Failed)
test/language/expressions/class/async-method/returns-async-arrow.js (previously Failed)
test/language/expressions/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/expressions/class/async-method-static/returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/expressions/class/async-method-static/returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/expressions/class/async-method-static/returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/expressions/class/async-method-static/returns-async-arrow.js [strict mode] (previously Failed)
test/language/expressions/class/async-method-static/returns-async-arrow.js (previously Failed)
test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body.js [strict mode] (previously Failed)
test/language/expressions/async-function/named-returns-async-arrow.js [strict mode] (previously Failed)
test/language/expressions/async-function/named-returns-async-arrow.js (previously Failed)
test/language/expressions/async-function/named-reassign-fn-name-in-body.js (previously Failed)
test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-eval.js [strict mode] (previously Failed)
test/language/expressions/async-function/named-reassign-fn-name-in-body-in-arrow.js (previously Failed)
test/language/expressions/async-function/named-returns-async-arrow-returns-newtarget.js [strict mode] (previously Failed)
test/language/expressions/async-function/named-returns-async-arrow-returns-newtarget.js (previously Failed)
test/language/expressions/async-function/named-strict-error-reassign-fn-name-in-body-in-arrow.js [strict mode] (previously Failed)
test/language/expressions/async-function/named-returns-async-arrow-returns-arguments-from-parent-function.js [strict mode] (previously Failed)
test/language/expressions/async-function/named-returns-async-arrow-returns-arguments-from-parent-function.js (previously Failed)
test/language/destructuring/binding/syntax/destructuring-array-parameters-function-arguments-length.js [strict mode] (previously Failed)
test/language/destructuring/binding/syntax/destructuring-array-parameters-function-arguments-length.js (previously Failed)
test/language/destructuring/binding/syntax/destructuring-object-parameters-function-arguments-length.js [strict mode] (previously Failed)
test/language/destructuring/binding/syntax/destructuring-object-parameters-function-arguments-length.js (previously Failed)
Broken tests (2):
test/language/expressions/assignmenttargettype/direct-asyncarrowfunction-1.js [strict mode] (previously Passed)
test/language/expressions/assignmenttargettype/direct-asyncarrowfunction-1.js (previously Passed)

@codecov
Copy link

codecov bot commented Oct 30, 2022

Codecov Report

Merging #2393 (c88ae45) into main (49a5867) will decrease coverage by 0.26%.
The diff coverage is 20.05%.

@@            Coverage Diff             @@
##             main    #2393      +/-   ##
==========================================
- Coverage   39.07%   38.80%   -0.27%     
==========================================
  Files         311      313       +2     
  Lines       23669    23897     +228     
==========================================
+ Hits         9248     9274      +26     
- Misses      14421    14623     +202     
Impacted Files Coverage Δ
boa_ast/src/expression/mod.rs 30.23% <0.00%> (+0.11%) ⬆️
boa_ast/src/function/async_arrow_function.rs 0.00% <0.00%> (ø)
boa_ast/src/function/async_function.rs 35.48% <0.00%> (+1.00%) ⬆️
boa_ast/src/function/async_generator.rs 7.14% <0.00%> (+3.29%) ⬆️
boa_ast/src/function/generator.rs 3.57% <0.00%> (-0.28%) ⬇️
boa_ast/src/operations.rs 25.24% <0.00%> (-0.04%) ⬇️
boa_ast/src/visitor.rs 20.00% <ø> (-20.00%) ⬇️
boa_engine/src/builtins/function/mod.rs 22.91% <0.00%> (+0.46%) ⬆️
boa_engine/src/environments/compile.rs 44.00% <0.00%> (-1.21%) ⬇️
...rser/expression/assignment/async_arrow_function.rs 0.00% <0.00%> (ø)
... and 53 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@jasonwilliams jasonwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me! :)

@raskad
Copy link
Member Author

raskad commented Nov 4, 2022

bors r+

bors bot pushed a commit that referenced this pull request Nov 4, 2022
This Pull Request fixes #1805.

It changes the following:

- Implement async arrow function parsing and execution.
- Handle special case when a function expressions binding identifier need to be bound in the function body.
- Implement special silent ignored assignment for the above case.
- Fix issue with getting the correct promise capability for function returns.
- Complete function object `toString` todo.

I will fix the two failing assignmenttargettype tests in a follow up PR.
@bors
Copy link

bors bot commented Nov 4, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Implement async arrow functions [Merged by Bors] - Implement async arrow functions Nov 4, 2022
@bors bors bot closed this Nov 4, 2022
@bors bors bot deleted the async-arrow-parse branch November 4, 2022 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request execution Issues or PRs related to code execution parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Async Arrow Function parsing
4 participants