This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Move the awaiting (back) into yield #102
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
428bd9b
Move the awaiting (back) into yield/return
domenic e5d1388
Handle return unwrapping better inside AsyncGeneratoResumeNext
domenic 7b33721
Move it around so it works in all cases
domenic 8901758
Don't let the queue advance while awaiting a return
domenic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h2>Syntax</h2> | ||
<emu-grammar> | ||
ReturnStatement[Yield, Await] : | ||
`return` `;` | ||
`return` [no LineTerminator here] Expression[+In, ?Yield, ?Await] `;` | ||
</emu-grammar> | ||
<emu-note> | ||
<p>A `return` statement causes a function to cease execution and return a value to the caller. If |Expression| is omitted, the return value is *undefined*. Otherwise, the return value is the value of |Expression|.</p> | ||
</emu-note> | ||
|
||
<!-- es6num="13.10.1" --> | ||
<emu-clause id="sec-return-statement-runtime-semantics-evaluation"> | ||
<h1>Runtime Semantics: Evaluation</h1> | ||
<emu-grammar>ReturnStatement : `return` `;`</emu-grammar> | ||
<emu-alg> | ||
1. Return Completion{[[Type]]: ~return~, [[Value]]: *undefined*, [[Target]]: ~empty~}. | ||
</emu-alg> | ||
<emu-grammar>ReturnStatement : `return` Expression `;`</emu-grammar> | ||
<emu-alg> | ||
1. Let _exprRef_ be the result of evaluating |Expression|. | ||
1. Let _exprValue_ be ? GetValue(_exprRef_). | ||
1. <ins>If ! GetGeneratorKind() is ~async~, set _exprValue_ to ? Await(_exprValue_).</ins> | ||
1. Return Completion{[[Type]]: ~return~, [[Value]]: _exprValue_, [[Target]]: ~empty~}. | ||
</emu-alg> | ||
</emu-clause> |
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.
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.
I believe at this point, it's still possible to resolve an unwrapped promise.
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.
Oops, this comment isn't quite right. If you add a return statement between the 2 yields, though, and add an extra .next() call before the .return() call, I believe it is still not unwrapping the promise.
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.
I suppose the correct fix is to just move all of this block of changes to line 108, replacing the "AsyncGeneratorResolve" call.
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.
Great catch, that makes perfect sense.