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
'my ($a is readonly) = 5' should be allowed, but assigning to it afterward should be disallowed; '(my $a is readonly) = 5' should also be disallowed... in Rakudo #1008
Comments
From @masak<masak> rakudo: my ($a is readonly) = 5; say $a; $a = 42; say $a |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S06-traits/is-readonly.t commit 60eb8fe4fe2597318596142bd3268ad9d4b49033 [t/spec] Test for RT #65900 Inline Patchdiff --git a/t/spec/S06-traits/is-readonly.t b/t/spec/S06-traits/is-readonly.t
index 0774abd..389f8a7 100644
--- a/t/spec/S06-traits/is-readonly.t
+++ b/t/spec/S06-traits/is-readonly.t
@@ -4,7 +4,7 @@ use Test;
# L<S06/"Parameter traits"/"=item is readonly">
# should be moved with other subroutine tests?
-plan 9;
+plan *;
{
my $a is readonly := 42;
@@ -40,4 +40,16 @@ plan 9;
ok (try { VAR($a).defined }), ".VAR on a plain normal initialized variable returns true";
}
+# RT #65900
+{
+ my ($rt65900 is readonly) = 5;
+ is $rt65900, 5, 'my ($x is readonly) can take assignment';
+ dies_ok { $rt65900 = 'ro' }, 'dies on assignment to readonly variable';
+
+ dies_ok { (my $rt65900 is readonly) = 5 },
+ 'dies on assignment to (my $x is readonly)';
+}
+
+done_testing;
+
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @bbkr$ perl6 -e 'my ($a is readonly) = 5; say $a; $a = 42; say $a' So it dies properly now. But test file is not working due to := not implemented in earlier tests. |
From @cokeOn Wed Jun 30 07:14:21 2010, bbkr wrote:
Good news: fudged the test and added it to t/spectest.data so it's run. Bad news: I had to fudge these tests too. -- |
From @usev6Things have changed and infix:<::=> is used instead of a variable trait "is readonly". The tests for this ticket are gone with this commit: Raku/roast@253242f
I think the last one should also result in a compile time error. But I don't know how to fix it. |
1 similar comment
From @usev6Things have changed and infix:<::=> is used instead of a variable trait "is readonly". The tests for this ticket are gone with this commit: Raku/roast@253242f
I think the last one should also result in a compile time error. But I don't know how to fix it. |
From @usev6On Wed Oct 01 13:03:29 2014, bartolin@gmx.de wrote:
AFAIU this doesn't die because '($a is readonly)' is parsed as a signature and is not checked as strictly as the assignments (see e.g. https://rt-archive.perl.org/perl6/Ticket/Display.html?id=74664#txn-686876). So, we're back to 'things have changed and infix:<::=> is used instead of a variable trait "is readonly"'. To be sure that the right exception is thrown when someone uses the old "is readonly", I added two tests to S03-binding/ro.t with commit Raku/roast@8a07d59e32. If I'm not mistaken, there is nothing else to do in this context. If that's not the case, please reopen the ticket. |
1 similar comment
From @usev6On Wed Oct 01 13:03:29 2014, bartolin@gmx.de wrote:
AFAIU this doesn't die because '($a is readonly)' is parsed as a signature and is not checked as strictly as the assignments (see e.g. https://rt-archive.perl.org/perl6/Ticket/Display.html?id=74664#txn-686876). So, we're back to 'things have changed and infix:<::=> is used instead of a variable trait "is readonly"'. To be sure that the right exception is thrown when someone uses the old "is readonly", I added two tests to S03-binding/ro.t with commit Raku/roast@8a07d59e32. If I'm not mistaken, there is nothing else to do in this context. If that's not the case, please reopen the ticket. |
@usev6 - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#65900 (status was 'resolved')
Searchable as RT65900$
The text was updated successfully, but these errors were encountered: