Skip Menu |

Date: Sun, 05 Jun 2016 13:46:11 -0400
To: rakudobug [...]
From: Mathieu Gagnon <mathieu [...]>
Subject: assignment of array and hash on dot twigil
Download (untitled) / with headers
text/plain 657b
Hello, $ perl6 --version This is Rakudo version 2016.04 built on MoarVM version 2016.04 implementing Perl 6.c. Reading suggests that the dot twigil provides read-only access to the attribute. But it is possible to change Array and Hash: $ perl6 -e 'class A { has $.wut = [] }; my $a =; $a.wut = [1,2,3]; dd $a;' A $a = => $[1, 2, 3]) I was expecting something like 'Cannot modify an immutable Array' $ perl6 -e 'class A { has $.wut = set() }; my $a =; $a.wut = set(1,2,3); dd $a;' Cannot modify an immutable Set in block <unit> at -e line 1
Yes, this looks like a bug. Possibly related to ticket #128124.
Download (untitled) / with headers
text/plain 463b
This happens with subroutines too. Seems for any item with things inside, those things remain modifiable: <Zoffix> m: sub foo ( $array, $hash, $set ) { $array[0] = 'edited'; $hash<foo> = 'edited'; $set<edited> = True; }; my @a = ^3; my %hash = :42foo; my $set = ^3 .SetHash; foo @a, %hash, $set; dd @a, %hash, $set <camelia> rakudo-moar f583f2: OUTPUT«Array @a = ["edited", 1, 2]␤Hash %hash = {:foo("edited")}␤SetHash $set ="edited",0,1,2)␤»

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at