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

Generator is already finished behaviour #158

Closed
sebmck opened this issue Dec 18, 2014 · 1 comment
Closed

Generator is already finished behaviour #158

sebmck opened this issue Dec 18, 2014 · 1 comment
Labels

Comments

@sebmck
Copy link
Contributor

sebmck commented Dec 18, 2014

I'm trying to find a reference somewhere in the spec that defines this behaviour but I haven't managed to find one. With regenerator the following will throw an error of Generator has already finished:

function* generator(){
  yield 5;
}
var iterator = generator();
console.log(iterator.next());
console.log(iterator.next());
console.log(iterator.next());

While v8 will run it just fine.

{ value: 5, done: false }
{ value: undefined, done: true }
{ value: undefined, done: true }

Is regenerator or v8 the one in the wrong here?

@benjamn
Copy link
Collaborator

benjamn commented Dec 18, 2014

https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume suggests V8 is behaving correctly. I think that's a change in the spec, but I like it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants