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
'is rw' allows constant arguments to change in Rakudo #1060
Comments
From @masakSubmitting the below message as a bug per John's request. ---------- Forwarded message ---------- [...] No, "is rw" does not like immutables. It will cause autovivification <ruoso> rakudo: sub foo($a is rw) { $a += 1; say $a }; foo(1); that directly contradicts S06, which states "Otherwise the signature Somebody who works with rakudo could submit a bug, if it's not in there already? |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in at least one of these files: t/spec/S02-magicals/dollar_bang.t, t/spec/S06-multi/by-trait.t commit a264981ad5f9439aec2e797a9c35b55d354183b1 [t/spec] Tests for RT 66588 Inline Patchdiff --git a/t/spec/S02-magicals/dollar_bang.t b/t/spec/S02-magicals/dollar_bang.t
index 3b33e06..b283493 100644
--- a/t/spec/S02-magicals/dollar_bang.t
+++ b/t/spec/S02-magicals/dollar_bang.t
@@ -40,7 +40,7 @@ ok $!, 'Dividing one by zero sets $!';
sub incr ( $a is rw ) { $a++ };
undefine $!;
try { incr(19) };
-#?rakudo todo 'containers/values'
+#?rakudo todo 'RT 66588: containers/values'
ok $!, 'Modifying a constant sets $!';
try {
diff --git a/t/spec/S06-multi/by-trait.t b/t/spec/S06-multi/by-trait.t
new file mode 100644
index 0000000..45b33df
--- /dev/null
+++ b/t/spec/S06-multi/by-trait.t
@@ -0,0 +1,23 @@
+use v6;
+use Test;
+plan *;
+
+{
+ my $ro_call = 0;
+ my $rw_call = 0;
+ sub uno_mas( Int $ro ) { $ro_call++; return 1 + $ro }
+ sub uno_mas( Int $rw is rw ) { $rw_call++; return ++$rw }
+
+ is uno_mas(42), 43, 'multi works with constant';
+ is $ro_call, 1, 'read-only multi was called';
+
+ my $x = 99;
+ is uno_mas( $x ), 100, 'multi works with variable';
+ #?rakudo 2 todo 'RT 66588: multi dispatch by trait'
+ is $x, 100, 'variable was modified';
+ is $rw_call, 1, 'read-write multi was called';
+}
+
+done_testing;
+
+# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @moritznow fails properly with "Cannot assign to readonly value" |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#66588 (status was 'resolved')
Searchable as RT66588$
The text was updated successfully, but these errors were encountered: