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

result of "return" method in IteratorClose #294

Closed
GeorgNeis opened this Issue Jan 18, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@GeorgNeis
Contributor

GeorgNeis commented Jan 18, 2016

7.4.6 IteratorClose enforces that the result of the return method is an object:

8. If Type(innerResult.[[value]]) is not Object, throw a TypeError exception.
9. Return Completion(completion).

This seems strange as the result is not used. What's the reason for this check?

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Jan 18, 2016

Member

It's defined by user code, so it might return a primitive - and given that it's an iterator result, its return value must conform with the contract. See step 3 in http://tc39.github.io/ecma262/#sec-iteratornext and step 1 in http://tc39.github.io/ecma262/#sec-iteratorcomplete and http://tc39.github.io/ecma262/#sec-iteratorvalue.

Member

ljharb commented Jan 18, 2016

It's defined by user code, so it might return a primitive - and given that it's an iterator result, its return value must conform with the contract. See step 3 in http://tc39.github.io/ecma262/#sec-iteratornext and step 1 in http://tc39.github.io/ecma262/#sec-iteratorcomplete and http://tc39.github.io/ecma262/#sec-iteratorvalue.

@bterlson bterlson closed this Feb 18, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment