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

Code block inside andthen/orelse doesn't close over lexical variables correctly #6625

Closed
p6rt opened this issue Oct 21, 2017 · 4 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 21, 2017

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

Searchable as RT132337$

@p6rt
Copy link
Author

p6rt commented Oct 21, 2017

From @smls

Golfed example​:

  sub foo ($str) {
  { say $str }() orelse Nil
  }

  foo "aa"; # aa
  foo "bb"; # aa

The second call should print "bb", not "aa".

Replacing the `say` with `return`, throws "Attempt to return outside of
any Routine" on the second call (but not the first), indicating that
something is going wrong with cloning the interpolated closure.

@p6rt
Copy link
Author

p6rt commented Jan 26, 2018

From @zoffixznet

On Sat, 21 Oct 2017 06​:23​:40 -0700, smls75@​gmail.com wrote​:

Golfed example​:

 sub foo \($str\) \{
     \{ say $str \}\(\) orelse Nil
 \}

 foo "aa";  \# aa
 foo "bb";  \# aa

The second call should print "bb", not "aa".

Replacing the `say` with `return`, throws "Attempt to return outside of
any Routine" on the second call (but not the first), indicating that
something is going wrong with cloning the interpolated closure.

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@1ee89b54074e80c
Test​: Raku/roast@2f2998733a2d8132c

@p6rt
Copy link
Author

p6rt commented Jan 26, 2018

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

@p6rt
Copy link
Author

p6rt commented Jan 26, 2018

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

@p6rt p6rt closed this as completed Jan 26, 2018
@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