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

new Iterator() should throw TypeError? #4068

Closed
sosukesuzuki opened this issue Apr 28, 2024 · 2 comments
Closed

new Iterator() should throw TypeError? #4068

sosukesuzuki opened this issue Apr 28, 2024 · 2 comments

Comments

@sosukesuzuki
Copy link
Contributor

The following assertion is included in the file /test/built-ins/Iterator/newtarget-or-active-function-object.js:

assert.throws(TypeError, () => {
  new Iterator();
});

Is this correct?

According to section 3.1.1.1 of the proposed specification 1,

it is designed to be subclassable. It may be used as the value of an extends clause of a class definition.

However, section 3.1.1.1.1 2 states:

  1. Return ? OrdinaryCreateFromConstructor(NewTarget, "%Iterator.prototype%").

This does not mention throwing a TypeError.

Should a call to new Iterator() throw a TypeError, or should it return a value that inherits from Iterator.prototype?

Footnotes

  1. https://tc39.es/proposal-iterator-helpers/#sec-iterator-constructor

  2. https://tc39.es/proposal-iterator-helpers/#sec-iterator

@nicolo-ribaudo
Copy link
Member

When you do new Iterator, NewTarget and "the active function object" are equal (both Iterator) and so step 1 of 3.1.1.1.1 throws.

@sosukesuzuki
Copy link
Contributor Author

Ahh I got it.., thanks

@sosukesuzuki sosukesuzuki closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2024
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

No branches or pull requests

2 participants