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

Likely bug with anon state var #8

Open
zoffixznet opened this issue Jun 25, 2018 · 1 comment
Open

Likely bug with anon state var #8

zoffixznet opened this issue Jun 25, 2018 · 1 comment

Comments

@zoffixznet
Copy link

Haven't run the code and just spotted this while reviewing some ecosystem code.

The {$++}" on this line needs to be changed to $($++)" or to " ~ $++:

name => "eval_{$++}",

With original version, the state var is in its own block, which gets cloned when the outer block is entered, so the var ends up always being set to 1.

m: for ^3 { say "and {++$}"; }
rakudo-moar e9351cbaa: OUTPUT: «and 1␤and 1␤and 1␤»

m: for ^3 { say "and $(++$)"; }
rakudo-moar e9351cbaa: OUTPUT: «and 1␤and 2␤and 3␤»
m: for ^3 { say "and " ~ ++$; }
rakudo-moar e9351cbaa: OUTPUT: «and 1␤and 2␤and 3␤»
@zoffixznet zoffixznet changed the title Likely buy with anon state var Likely bug with anon state var Jun 25, 2018
@zoffixznet
Copy link
Author

Same issue on this line:

$*CU = SAST::CompUnit.new(name => "eval_{$++}", block => $new);

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

No branches or pull requests

1 participant