Editorial: non-syntactic async/generator functions use NormalCompletion #3606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This moves the machinery for handling implicit returns in syntactic async/generator functions into the branches for evaluating parse nodes, instead of also using that logic for evaluating Abstract Closures.
It assumes that non-syntactic async/generator functions always internally return ThrowCompletions or NormalCompletions. Right now they can use both ReturnCompletions or NormalCompletions, which provides an unnecessary degree of freedom. The alternative is to enforce that non-syntactic async/generator functions return ThrowCompletions or ReturnCompletions, for which see #3605.
This makes non-syntactic async/generator functions match non-syntactic ordinary functions, which similarly always return ThrowCompletions or NormalCompletions. For that reason, I prefer this PR over #3605. (Edit: in the editor call today, the other editors agreed.)
In addition, it moves the handling of ReturnCompletions in evaluation of ordinary functions to immediately after the evaluation of the function body, to match async/generator functions as of this PR. This means EvaluateBody and its callees now return NormalCompletions.
Commits should be reviewed individually.
(This PR would also require changing the existing built-in generators/async functions to never return ReturnCompletions. I'll push up a commit doing that if we go this route.)