| Ticket UUID: | ba6ab5eb7be965011159dc04a57820b69877ef16 | ||
| Title: | [return -code] behaviour depends on how coroutine was started | ||
| Type: | Bug | Created on: | 2020-07-05 13:41:16 |
| Submitter: | aspect | Assigned to: | nobody |
| Subsystem: | 60. NRE and coroutines | Severity: | Minor |
| Priority: | 5 Medium | Last modified: | 2020-07-05 14:26:14 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | 8.6.10 | ||
| Description: | ||||
Setup:
% info patch
8.6.10
% proc gen {} {yield; return -code break}
As expected:
% apply {{} {coroutine t1 gen}}
% while 1 t1
Bug:
% coroutine t2 gen
% while 1 t2
invoked "break" outside of a loop
while executing
"gen"
invoked from within
"t2"
("while" body line 1)
invoked from within
"while 1 t2"
As a workaround, using [tailcall break] in place of [return -code break] works.
| ||||
| User Comments: | ||||
aspect added on 2020-07-05 14:26:14:
The plot thickens:
Works as a script:
$ tclsh <(echo 'proc t {} {yield 1 ; tailcall break} ; coroutine t1 t ; while 1 {puts [t1]}')
Fails interactively:
$ tclsh < <(echo 'proc t {} {yield 1 ; tailcall break} ; coroutine t1 t ; while 1 {puts [t1]}')
invoked "break" outside of a loop
| ||||
