-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Editorial: Fix return value logic for async arrow functions #1406
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug with the current specification, correct?
@zenparsing Yes I believe so |
I wonder if a better approach to fix this issue is to add a new runtime semantics to evaluate AssignmentExpressions for arrow-function like contexts. 14.2.15 Runtime Semantics: EvaluateBody has:
which is exactly what we need here for async arrow functions, i.e. evaluate an AssignmentExpression and then convert the result into a Return completion. (Plus it also handles GetValue which also seems to be missing for async arrow functions.). The same steps are executed in the class fields proposal at https://tc39.github.io/proposal-class-fields/#runtime-semantics-class-public-field-definition-evaluation, so we soon have three places which could use a single shared definition. I haven't verified if this works, but the quick'n dirty approach to get this working may be to add a wrapper around AssignmentExpression, so we get:
with:
|
22aef2b
to
2022cb9
Compare
@anba I went with your approach. @tc39/ecma262-editors please take a look. |
@TimothyGu can you rebase this and resolve the conflicts? |
2022cb9
to
1feb3d8
Compare
@ljharb Rebased |
ping @waldemarhorwat |
spec.html
Outdated
</emu-grammar> | ||
<emu-alg> | ||
1. Return the result of EvaluateBody of |AsyncFunctionBody| passing _functionObject_ and _argumentsList_ as the arguments. | ||
</emu-alg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Musing: I wonder if we should have ecmarkup auto-generate chain production expansions somehow so the reader can get a clickable link for the RHS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically possible, but I think it would go substantially beyond ecmarkup's current capabilities just to deduce the chain rules that have been left implicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubberstamp based on existing approvals.
Introduce a new production ExpressionBody for both plain and async arrow functions, and allow correctly handling return value logic for both. Currently, AsyncFunctionStart does not correctly handle the return value of async arrow functions correctly.
1feb3d8
to
a879fd5
Compare
- Fix a 'use' production for AsyncConciseBody to match the new defining production. - Add an <emu-prodref> for ExpressionBody to Annex A.
- Fix a 'use' production for AsyncConciseBody to match the new defining production. - Add an <emu-prodref> for ExpressionBody to Annex A.
- Fix a 'use' production for AsyncConciseBody to match the new defining production. - Add an <emu-prodref> for ExpressionBody to Annex A.
- Fix a 'use' production for AsyncConciseBody to match the new defining production. - Add an <emu-prodref> for ExpressionBody to Annex A.
- Fix a 'use' production for AsyncConciseBody to match the new defining production. - Add an <emu-prodref> for ExpressionBody to Annex A.
- Fix a 'use' production for AsyncConciseBody to match the new defining production. - Add an <emu-prodref> for ExpressionBody to Annex A.
- insert space before paren in clause heading - eliminate grammatical parameters from non-defining production - Add 4 <emu-prodref> elements to Annex A - tweak syntax in algorithms - eliminate accidental ambiguity in Punctuator PR tc39#1646 introduced an ambiguity to the lexical grammar: Punctuator derives OtherPunctuator in two different ways -- directly, and indirectly via OptionalChainingPunctuator. It doesn't make sense for OptionalChainingPunctuator to derive OtherPunctuator, so I've eliminated that alternative. - minor grammar refactoring re Punctuator Move the Punctuator production back to its former position. (Grammars are generally written top-down.) - Fix a 'use' production for AsyncConciseBody to match the new defining production - Add an <emu-prodref> for ExpressionBody to Annex A
Introduce a new production ExpressionBody for both plain and async arrow functions, and allow correctly handling return value logic for both. Currently, AsyncFunctionStart does not correctly handle the return value of async arrow functions correctly.