|
2020-07-05
| ||
| 14:26 | • Ticket [ba6ab5eb7b] return -code behaviour depends on how coroutine was starte... artifact: 20dd04dfc0 user: aspect | |
| 13:41 | • New ticket [ba6ab5eb7b]. artifact: f986157749 user: aspect | |
[return -code] behaviour depends on how coroutine was started
Openba6ab5eb7be965011159dc04a57820b69877ef16Created 6 years agoUpdated 6 years ago
Descriptionplain2020-07-05 13:41:16
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.
aspectplain2020-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
Log in (anonymous is fine) to add a comment.