# New Ticket Created by Johan Viklund # Please include the string: [perl #57422] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57422 >
On rakudo (rev. 29869) this fails with message "get_pmc_keyed() not implemented in class 'Undef'" class Foo { has %.bar is rw; method set_bar { %.bar<a> = 'baz'; } } my $foo = Foo.new; $foo.set_bar(); Initializing %.bar to () solves this particular problem, but another one appears. Shown below class Foo { has %.bar is rw; method set_bar { %.bar = (); %.bar<a> = 'baz'; } } my $foo = Foo.new; $foo.set_bar(); my %s = $foo.bar; # <- HERE BUG APPEARS Gives this error: "Odd number of elements found where hash expected" And the workaround for this is to declare set_bar like this method set_bar { my %bar_temp; %bar_temp<a> = 'baz'; %.bar = %bar_temp; } For arrays: class Foo { has @.bar is rw; method set_bar { @.bar.push('baz'); } } Gives "Method 'push' not found for invocant of class 'Undef'" Similar workaround as for hash (eg. initialize it first). -- Johan Viklund