-
Notifications
You must be signed in to change notification settings - Fork 1
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
Scoping issue with unsignatured $_ #3226
Comments
From @lizmat[23:44:41] <lizmat> r: my %e; (%e{$_.WHICH} //= ($_ => 0)).value++ for <a b b c c c>; say %e.perl # scoping issue? |
From @diakopternew behavior: 15:07 <diakopter> m: my %e; (%e{$_.WHICH} //= ($_ => 0)).value++ for <a b b c c c>; say %e.perl │······························· |
The RT System itself - Status changed from 'new' to 'open' |
From @smls@lizmat, @FROGGS: Do you know how the original scoping issue reported in this RT, was fixed? #122709 and #126569 suffer from similar scoping bugs involving $_ inside parens under a statement-modifier, and *haven't* been fixed yet. @matthew: That new behavior is to be expected. It's a result of the fact that unlike hashes, pairs no longer automatically containerize their values. And the ++ operator does not work on objects of type Int (those are immutable!), it only works on a Scalar container which happens to *contain* an Int. For example: say 0.VAR.^name; # Int In order to make your example work, you'd have to manually containerize the values of the keys you construct: my %e; (%e{$_.WHICH} //= ($_ => (my $ = 0))).value++ for <a b b c c c>; say %e.perl Or use a Hash of Arrays, instead of a Hash of Pairs. |
@smls - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#119609 (status was 'resolved')
Searchable as RT119609$
The text was updated successfully, but these errors were encountered: