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

Read-only $obj.attr accessor can be assigned to if the attribute $.attr contains an Array or Hash #5359

Open
p6rt opened this issue Jun 5, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 5, 2016

Migrated from rt.perl.org#128324 (status was 'open')

Searchable as RT128324$

@p6rt
Copy link
Author

p6rt commented Jun 5, 2016

From mathieu@gagnon.name

Hello,

  $ perl6 --version
  This is Rakudo version 2016.04 built on MoarVM version 2016.04
  implementing Perl 6.c.

Reading http://doc.perl6.org/language/classtut
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.new; $a.wut =
[1,2,3]; dd $a;'
  A $a = A.new(wut => $[1, 2, 3])

I was expecting something like 'Cannot modify an immutable Array'

  $ perl6 -e 'class A { has $.wut = set() }; my $a = A.new; $a.wut =
set(1,2,3); dd $a;'
  Cannot modify an immutable Set
  in block <unit> at -e line 1

@p6rt
Copy link
Author

p6rt commented Jun 12, 2016

From @smls

Yes, this looks like a bug.

Possibly related to ticket #​128124.

@p6rt
Copy link
Author

p6rt commented Jun 12, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 9, 2016

From @zoffixznet

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 = SetHash.new("edited",0,1,2)␤»

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant