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

add tests for "iterator helpers close receiver on argument validation failure" #4350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bakkot
Copy link
Contributor

@bakkot bakkot commented Dec 15, 2024

Tests for tc39/ecma262#3467, which has consensus and is just waiting for tests.

No existing tests were invalidated as far as I can tell (presumably because if we'd thought to test this behavior then we'd have updated the proposal instead of needing the PR).

@bakkot bakkot requested a review from a team as a code owner December 15, 2024 05:14
Comment on lines +20 to +27
return() {
closed = true;
},
};

assert.throws(RangeError, function() {
closable.take();
});
Copy link
Contributor

@sosukesuzuki sosukesuzuki Dec 15, 2024

Choose a reason for hiding this comment

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

Since the return value of return is not an object, wouldn't TypeError be thrown before RangeError due to step 7 of IteratorClose?

Copy link
Contributor

Choose a reason for hiding this comment

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

Both Iterator#map and Iterator#filter, etc pass the tests, but they probably do not behave as intended. In all tests, the return method of closable should return an object, I think.

Copy link
Contributor

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

Implementing this normative change is likely to cause https://github.com/tc39/test262/blob/main/test/built-ins/Iterator/prototype/reduce/non-callable-reducer.js to start failing, because the underlying iterator will already be closed during the second call to reduce.

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.

2 participants