Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upsemantics of yield* in throw case #293
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zenparsing
Jan 18, 2016
Contributor
It looks to me like this is a spec bug, and 5.b.ii.5.a should just say
- Return ? IteratorValue(innerResult).
|
It looks to me like this is a spec bug, and 5.b.ii.5.a should just say
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Jan 18, 2016
Member
see see https://bugs.ecmascript.org/show_bug.cgi?id=3526
The spec. originally (or at least at one time, read the whole bug thread) had the equivalent to @zenparsing’s proposed change. That was replaced with the current behavior as a fix for Comment #8. This change added both steps 5.b.ii.5.a&b (using the current draft steps) and 5.c.vii.1&2.
But it appears that the 5.b.ii.5.a&b change may have been unnecessary as Comment #8 is about invoking return rather than throw on the outer iterator. Basically that says that the current V8&FF semantics make the most sense and @zenparsing's fix is appropriate. The Edge semantics seem wrong as the exception has already been handle by the inner catch.
But this is all pretty subtle stuff, particularly when you get finally blocks involved. I recall a discussion on either es-discuss or in TC39 meeting notes where the conclusion was that totally transparent delegation via yield* (as originally envisioned) was impossible because of issues related to things like this. I haven't found those notes yet but it would be nice to review them to see if they contain anything that relates to this.
|
see see https://bugs.ecmascript.org/show_bug.cgi?id=3526 The spec. originally (or at least at one time, read the whole bug thread) had the equivalent to @zenparsing’s proposed change. That was replaced with the current behavior as a fix for Comment #8. This change added both steps 5.b.ii.5.a&b (using the current draft steps) and 5.c.vii.1&2. But it appears that the 5.b.ii.5.a&b change may have been unnecessary as Comment #8 is about invoking But this is all pretty subtle stuff, particularly when you get finally blocks involved. I recall a discussion on either es-discuss or in TC39 meeting notes where the conclusion was that totally transparent delegation via yield* (as originally envisioned) was impossible because of issues related to things like this. I haven't found those notes yet but it would be nice to review them to see if they contain anything that relates to this. |
bterlson
referenced this issue
Jan 19, 2016
Closed
Incorrect .throw() result on generator with yield* to another generator with try/catch #137
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Jan 19, 2016
Member
@zenparsing's fix seems good. The old fix to the return path (5.c.vii. 1&2) seems correct. With this fix in place, IIUC, yield* always propagates errors and only propagates returns when .return is called on the outer generator, and otherwise the value is a normal completion with the inner generator's return value.
|
@zenparsing's fix seems good. The old fix to the return path (5.c.vii. 1&2) seems correct. With this fix in place, IIUC, yield* always propagates errors and only propagates returns when .return is called on the outer generator, and otherwise the value is a normal completion with the inner generator's return value. |
bterlson
added
normative change
snapshot blocking
labels
Feb 18, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Feb 18, 2016
Member
Unless anyone objects (even weakly) I'll go ahead and apply @zenparsing's fix here (which is what implementations do anyway, other than Chakra which is bugged in a different way, see Microsoft/ChakraCore#137).
|
Unless anyone objects (even weakly) I'll go ahead and apply @zenparsing's fix here (which is what implementations do anyway, other than Chakra which is bugged in a different way, see Microsoft/ChakraCore#137). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Sounds good to me |
GeorgNeis commentedJan 18, 2016
In the semantics of yield* (14.4.14) in step 5.b.ii.5.b (the throw case), it returns a return completion record.
If I understand correctly, this means that if I define
then I should get the following interaction:
Is this intended?
V8 and Firefox behave as if 5.b.ii.5.b would just return a normal completion (like in 5.a.iii):
Edge does something else entirely: