This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Normative: close underlying iterators when return is called before next #267
Merged
Conversation
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
Any chance you could provide a test case that fails without this PR? |
Something along the lines of let returnCalls = 0;
let it = {
__proto__: Iterator.prototype,
next() {},
return() {
++returnCalls;
},
};
let mapped = it.map(() => {});
mapped.return();
assert(returnCalls === 1); // would be 0 without this PR
mapped.return();
assert(returnCalls === 1); // only gets called the first time |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
ljharb
reviewed
Feb 16, 2023
ljharb
added a commit
to es-shims/iterator-helpers
that referenced
this pull request
Feb 16, 2023
ljharb
approved these changes
Feb 16, 2023
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've implemented and tested the changes in my polyfill, works as advertised.
ljharb
added a commit
to es-shims/iterator-helpers
that referenced
this pull request
Mar 21, 2023
michaelficarra
approved these changes
Mar 30, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #266 (cc @syg).
Note that we'll need consensus from committee before merging.
(The slot has to be named
[[UnderlyingIterator]]
instead of[[Iterated]]
because we use[[Iterated]]
for the name of a slot on%WrapForValidIteratorPrototype%
objects, and we don't want to accidentally make iterator helper objects valid.call
targets for%WrapForValidIteratorPrototype%.next
.)