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

fix: Replace IteratorStep with NextMethod #44

Merged
merged 1 commit into from
Dec 21, 2023
Merged

Conversation

js-choi
Copy link
Collaborator

@js-choi js-choi commented Dec 2, 2023

Fixes #33.
Prevents an infinite loop caused by IteratorStep(iteratorRecord) not actually flagging termination when IteratorRecord is async. Instead, we will directly call iteratorStep.[[NextMethod]], like how for await does. Uses the patch suggested by @bakkot.

Fixes #33.
Prevents an infinite loop caused by IteratorStep(iteratorRecord) not actually flagging termination when IteratorRecord is async. Instead, we will directly call iteratorStep.[[NextMethod]], like how `for await` does.

Co-Authored-By: Kevin Gibbons <bakkot@gmail.com>
@js-choi js-choi added the bug Something isn't working label Dec 2, 2023
Copy link

@mgaudet mgaudet left a comment

Choose a reason for hiding this comment

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

For my part, this LGTM

@js-choi js-choi merged commit 689d0d4 into main Dec 21, 2023
@js-choi js-choi deleted the replace-iterator-step branch December 21, 2023 17:52
1. Set _nextResult_ to ? Await(_nextResult_).
1. If _nextResult_ is not an Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_nextResult_).
1. If _done_ is *true*,
1. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _A_, [[Target]]: ~empty~ }.
1. Let _nextValue_ be ? IteratorValue(_next_).

Choose a reason for hiding this comment

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

Hey! Sorry for the post-merge review comment, but should this now be IteratorValue(_nextResult_)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You’re right. Thank you for spotting this. I opened #45 and plan to merge it in a few days if nobody else spots any more problems.

js-choi added a commit that referenced this pull request Dec 24, 2023
Finish #44’s change, which fixes #33.

Co-Authored-By: Kevin Gibbons <bakkot@gmail.com>
#44 renamed _next_ to _nextResult_ but one reference was left unchanged. Spotted by @trflynn89.
js-choi added a commit that referenced this pull request Dec 24, 2023
Finish #44’s change, which fixes #33.

Co-Authored-By: Kevin Gibbons <bakkot@gmail.com>
#44 renamed _next_ to _nextResult_ but one reference was left unchanged. Spotted by @trflynn89.
js-choi added a commit that referenced this pull request Dec 27, 2023
Finish #44’s change, which fixes #33.

Co-Authored-By: Kevin Gibbons <bakkot@gmail.com>
#44 renamed _next_ to _nextResult_ but one reference was left unchanged. Spotted by @trflynn89.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spec Issue: IteratorStep returns a promise for async iterators, leading to an infinite loop
3 participants