Skip to content
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

return in a NEXT phaser in a loop outside of any routine aborts the iteration in Rakudo #3668

Closed
p6rt opened this issue Feb 5, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Feb 5, 2015

Migrated from rt.perl.org#123732 (status was 'resolved')

Searchable as RT123732$

@p6rt
Copy link
Author

p6rt commented Feb 5, 2015

From @masak

<masak> m​: for ^5 { .say; NEXT { return } }
<camelia> rakudo-moar 613c0b​: OUTPUT«0␤1␤2␤3␤4␤»
<masak> that last one, besides wrongly compiling (IMO), did not have
the wrong runtime semantics I expected it to.
<masak> m​: say "A"; return; say "B"
<camelia> rakudo-moar 613c0b​: OUTPUT«A␤»
<masak> m​: for ^5 { say "A"; return; say "B" }
<camelia> rakudo-moar 613c0b​: OUTPUT«A␤»
<masak> ok, `return` should not bind to `NEXT` phasers
<masak> m​: for ^5 { .say; NEXT { say "A" }; NEXT { return } }
<camelia> rakudo-moar 613c0b​: OUTPUT«0␤1␤2␤3␤4␤»
<masak> seems it's worse than that​: `return` in a `NEXT` binds to the iteration.
* masak submits rakudobug for `return` in a `NEXT` working at all
outside of a routine
<masak> m​: sub foo { for ^3 { NEXT { return $_ } }; return 42 }; say foo
<camelia> rakudo-moar 613c0b​: OUTPUT«0␤»
<masak> ...but *inside* a routine it seems to do the right thing. weird.

Point of order. We have a separate ticket (RT #​122504) for `return`
dynamically outside of a routine; this ticket is not about that.

This ticket is about `return` having some unexpected/unwanted behavior
inside of a `NEXT` in a loop outside of a routine. Even here, it
should fail (preferably statically, at the very least dynamically).
The current (wrong) behavior of `return` outside of a routine is to
exit the program. *This* `return` inside a `NEXT` exits the iteration.

Ideally, the resolution of #​122504 will also fix this ticket.
Reporting this just in case, because the wrong behavior is different.

@p6rt
Copy link
Author

p6rt commented Dec 1, 2015

From @jnthn

On Wed Feb 04 18​:18​:09 2015, masak wrote​:

<masak> m​: for ^5 { .say; NEXT { return } }
<camelia> rakudo-moar 613c0b​: OUTPUT«0␤1␤2␤3␤4␤»
<masak> that last one, besides wrongly compiling (IMO), did not have
the wrong runtime semantics I expected it to.
<masak> m​: say "A"; return; say "B"
<camelia> rakudo-moar 613c0b​: OUTPUT«A␤»
<masak> m​: for ^5 { say "A"; return; say "B" }
<camelia> rakudo-moar 613c0b​: OUTPUT«A␤»
<masak> ok, `return` should not bind to `NEXT` phasers
<masak> m​: for ^5 { .say; NEXT { say "A" }; NEXT { return } }
<camelia> rakudo-moar 613c0b​: OUTPUT«0␤1␤2␤3␤4␤»
<masak> seems it's worse than that​: `return` in a `NEXT` binds to the
iteration.
* masak submits rakudobug for `return` in a `NEXT` working at all
outside of a routine

Now it complains about return outside of routine. Tests in S32-exceptions/misc.t, where there were various other return outside of routine tests for cases that did already work.

@p6rt
Copy link
Author

p6rt commented Dec 1, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 1, 2015

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 1, 2015
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant