Skip to content

Instantly share code, notes, and snippets.

@ufobat
Created May 10, 2016 20:17
Show Gist options
  • Save ufobat/b32e882564057ead07de146b51672a9f to your computer and use it in GitHub Desktop.
Save ufobat/b32e882564057ead07de146b51672a9f to your computer and use it in GitHub Desktop.
class Strange {
has $.env is rw;
method reset($env) {
$.env = $env ;
}
}
class Context {
has $!env;
has $.strange = Strange.new;
method env {
Proxy.new(
FETCH => { $!env },
STORE => -> $, $value {
# reset response to default
$!env = $value;
$!strange.reset($!env);
},
);
}
}
my %env = (1 => 2, 3 => 4);
my $c = Context.new;
sub dispatch($v) {
$c.env = $v;
}
dispatch(%env);
dispatch(%env);
@ufobat
Copy link
Author

ufobat commented May 11, 2016

Cannot assign to a readonly variable or a value
in method reset at Strange.pm line 4
in block at Strange.pm line 18

@ufobat
Copy link
Author

ufobat commented May 11, 2016

m: class Strange { has $.env is rw; method reset($env) { $.env = $env } }; my $s = Strange.new; my %env = (1 => 2, 3 => 4); $s.reset(%env); $s.reset(%env)
rakudo-moar 9c8989: OUTPUT«Cannot assign to a readonly variable or a value␤ in method reset at /tmp/plljs3r5Zt line 1␤ in block at /tmp/plljs3r5Zt line 1␤␤»
soo, it's a bug?
pretty sure it is, yes
care to submit it? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment