Closed GoogleCodeExporter closed 9 years ago
The statemachine generates
case 1:
throw 2;
$state = 5;
break;
it seems like it should be sufficient to set the state before the throw?
Original comment by arv@chromium.org
on 10 Feb 2013 at 10:26
Using the example above, that would generate something like:
1
caught exception: 2
3
So we still 'yield 3' when the generator should have already exited.
----
Another problem is that in the normal case when you 'throw' from inside
a 'try', the generated code actually relies upon the "early exit"
behavior that you noted with:
try {
case 1:
throw 2;
$state = 5;
break;
// ...
} catch(e) {
// ....
case 1: // "mirror image" on the 'catch' side.
// when something gets thrown while in state 1, do this
$state = ...;
}
----
The problem as I currently understand it is that the "mirror image"
is only generated for states inside a catch, when it should really be
generated wherever a 'throw' occurs. So there are actually more mirror
images created than are strictly necessary. The fix I currently have
doesn't fix that bug; it just fills in the missing mirror images, along
with making sure that we're in the end state before doing the final
throw that exits the generator.
I'll have the tentative patch up within an hour; just checking to see
that I didn't make any facepalm errors.
Original comment by usrbi...@yahoo.com
on 11 Feb 2013 at 12:36
https://code.google.com/p/traceur-compiler/source/detail?r=9bddf900b716f0bcb0a2a
0a1dd3aef6934815040
Original comment by arv@google.com
on 11 Feb 2013 at 10:48
Original issue reported on code.google.com by
usrbi...@yahoo.com
on 10 Feb 2013 at 10:19