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
Yielded values stomp on each other from regenerator. #2385
Labels
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
Comments
Just from looking at the generated code, it appears that with this type of expression a combined switch step is produced: var x = regeneratorRuntime.mark(function generator() {
return regeneratorRuntime.wrap(function generator$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
context$1$0.next = 2;
return 1;
case 2:
context$1$0.next = 4;
return 2;
case 4:
context$1$0.t0 = f2 = context$1$0.sent;
(f1 = context$1$0.sent)(context$1$0.t0);
console.log(f1 + " " + f2);
case 7:
case "end":
return context$1$0.stop();
}
}, generator, this);
}); Compare to what happens if you just change it to (f1 = yield 1) + (f2 = yield 2) (another pexression with two yields): var x = regeneratorRuntime.mark(function generator() {
return regeneratorRuntime.wrap(function generator$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
context$1$0.next = 2;
return 1;
case 2:
context$1$0.t0 = f1 = context$1$0.sent;
context$1$0.next = 5;
return 2;
case 5:
context$1$0.t1 = f2 = context$1$0.sent;
context$1$0.t0 + context$1$0.t1;
console.log(f1 + " " + f2);
case 8:
case "end":
return context$1$0.stop();
}
}, generator, this);
}); |
Moving to facebook/regenerator#218. |
Per facebook/regenerator#218 (comment), this will be fixed when #4881 is merged. |
lock
bot
added
the
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
label
May 6, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If we look at the example below:
In node v0.12 (using real generators), the result is:
However, under babel, the result is:
To take a deeper look, we can use two functions:
We'd expect:
But instead get:
The second value stomps on the old.
The text was updated successfully, but these errors were encountered: