Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

is default on a hash prevents autovivification, but doesn't work on its own either #5872

Open p6rt opened 7 years ago

p6rt commented 7 years ago

Migrated from rt.perl.org#130293 (status was 'new')

Searchable as RT130293$

p6rt commented 7 years ago

From @moritz

moritz​: m​: my %h is default([]); %h\.push​: 1; %h\.push​: 2; say %h camelia​: rakudo-moar 2d0198​: OUTPUT«{}␤» moritz​: m​: my %h; %h\.push​: 1; %h\.push​: 2; say %h camelia​: rakudo-moar 2d0198​: OUTPUT«{a => [1], b => [2]}␤» moritz​: does this look like a bug to anybody else? babydrop​: yeah moritz​: I was curious whether it created two distinct arrays, but   didn't expect to see %h empty * moritz rakudos submitbug

I expected the output from the first to be {a => [1, 2], b => [1, 2]}, or if 'is default' clones the value, {a => [1], b => [2]}.

-- Moritz Lenz https://deploybook.com/ -- https://perlgeek.de/ -- https://perl6.org/