|
2021-06-19
| ||
| 20:50 | • Closed ticket [b80ccfcf32]: a coroutine calls yieldto to yieldto itself, and los... artifact: b54adf045b user: pooryorick | |
| 20:37 | • Ticket [b80ccfcf32]: 3 changes artifact: 5c116979b4 user: dkf | |
| 20:23 | • Ticket [b80ccfcf32]: 3 changes artifact: 240a17a55f user: dkf | |
| 17:05 | • Ticket [b80ccfcf32]: 3 changes artifact: 9e116fed4f user: pooryorick | |
| 17:01 | • Ticket [b80ccfcf32]: 3 changes artifact: bec28492c2 user: pooryorick | |
| 16:58 | • New ticket [b80ccfcf32]. artifact: d0917825c8 user: pooryorick | |
a coroutine calls yieldto to yieldto itself, and loses control
proc p0 {} {
coroutine c2 p1
error {error after returning from c2}
}
proc p1 {} {
yieldto yieldto [list [info coroutine]]
}
coroutine c1 p0
puts {no error}
Output:
no error
Do the c1 and c2 coroutines exist afterwards? If they do, can you probe them to see what they're doing?
c2 doesn't exist; c1 does exist, and is suspended within the call to coroutine
% coroprobe c1 info frame 0
type proc line 2 cmd {coroutine c2 p1} proc ::p0 level 0
Resuming c1 runs the call to error. Neither coroutine exists afterwards.
I'm not sure that this is anything but correct. It's weird, but yielding to a yieldto is weird.
I see now that the example script is doing the right thing. First c2 yields, and the second yieldto then takes place in the context of c1, causing c1 to yield back to c2. c1 is then no longer on the stack, so when p1 returns, it's no longer returning to p0, which is part of thce c1 context. Instead it returns to the caller of c1, as expected.