Skip to content

Fix tests for nested loops and labeled last #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

usev6
Copy link
Contributor

@usev6 usev6 commented Feb 15, 2025

As pointed out by @niner++ the old version assumed that the loops were not lazy. But as mentioned in the comment the old design docs suggested that the used syntax (having the loop inside parens) would make the loop lazy -- at least if the loop is the final statement of a statement list.

This behavior is currently neither fully specced nor implemented by Rakudo. The tests weren't meant to specify the non-lazy evaluation. They only purpose was to make sure that the code doesn't crash and that the label is taken into account.

As pointed out by @niner++ the old version assumed that the loops were
not lazy. But as mentioned in the comment the old design docs suggested
that the used syntax (having the loop inside parens) would make the
loop lazy -- at least if the loop is the final statement of a statement
list.

This behavior is currently neither fully specced nor implemented by
Rakudo. The tests weren't meant to specify the non-lazy evaluation.
They only purpose was to make sure that the code doesn't crash and that
the label is taken into account.
@usev6
Copy link
Contributor Author

usev6 commented Feb 16, 2025

There is a problem when running with RAKUDO_RAKUAST=1 with one of the tests:

$ RAKULIB=lib RAKUDO_RAKUAST=1 ./rakudo-m t/spec/S04-statements/label.t
[...]
not ok 9 - no crash: nested loops and labeled last (1)
# Failed test 'no crash: nested loops and labeled last (1)'
# at t/spec/S04-statements/label.t line 118
# expected: $[1, 3, 5, 7]
#      got: $[1, 5]
[...]
WARNING: unhandled Failure detected in DESTROY. If you meant to ignore it, you can mark it as handled by calling .Bool, .so, .not, or .defined methods. The Failure was:
Index out of range. Is: 2, should be in 0..0
  in block <unit> at t/spec/S04-statements/label.t line 117

WARNING: unhandled Failure detected in DESTROY. If you meant to ignore it, you can mark it as handled by calling .Bool, .so, .not, or .defined methods. The Failure was:
Index out of range. Is: 2, should be in 0..0
  in block <unit> at t/spec/S04-statements/label.t line 115

The Failure seems to happen, because no Seq is returned with RAKUDO_RAKUAST=1:

$ ./rakudo-m -e 'dd sub () { (L: while True { last L }) }()'
(Label.new(name => "L", file => "-e", line => 1),).Seq
$ RAKUDO_RAKUAST=1 ./rakudo-m -e 'dd sub () { (L: while True { last L }) }()'
Label.new(name => "L", file => "-e", line => 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant