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

Make sync and async generators restore the initialization context #61

Merged
merged 5 commits into from
Aug 8, 2023

Conversation

andreubotella
Copy link
Member

Closes #18.

Copy link
Member

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Had to work through the spec, but this looks perfect.

1. Push _genContext_ onto the execution context stack; _genContext_ is now the running execution context.
1. <emu-meta effects="user-code">Resume the suspended evaluation of _genContext_</emu-meta> using NormalCompletion(_value_) as the result of the operation that suspended it. Let _result_ be the value returned by the resumed computation.
1. Assert: When we return here, _genContext_ has already been removed from the execution context stack and _methodContext_ is the currently running execution context.
1. <ins>AsyncContextSwap(_asyncContextMapping_).</ins>
Copy link
Member

@littledan littledan Aug 2, 2023

Choose a reason for hiding this comment

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

Nit: Write this as "Perform AsyncContextSwap(asyncContextMapping)."

Copy link
Member

Choose a reason for hiding this comment

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

Actually we should probably follow this with an assert that it doesn't matter whether we are discarding or saving/restoring.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are steps that just do "AsyncContextSwap(previousMapping)" in the existing spec text.

I will add that assertion though.

@jridgewell jridgewell merged commit 27e5abe into tc39:master Aug 8, 2023
@andreubotella andreubotella deleted the generators branch August 9, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specifying (async) generator behavior
4 participants