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
Rakudo still promotes List to Array when assigning to a scalar variable #1037
Comments
From @masak<dakkar> rakudo: constant $ARR = (1,2,3,4);$ARR[1]=4;say $ARR |
From @masak<DanielC> rakudo: my $a = (1,3,4); $a[1] = 8; # BAH! |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S02-builtin_data_types/lists.t commit f875d2ccaeddf929238237855d0f0cc57ec5a1e6 [t/spec] Test for RT #66304: list promoted to array when assigned to scalar Inline Patchdiff --git a/t/spec/S02-builtin_data_types/lists.t b/t/spec/S02-builtin_data_types/lists.t
index f8fdf0d..6eda0bb 100644
--- a/t/spec/S02-builtin_data_types/lists.t
+++ b/t/spec/S02-builtin_data_types/lists.t
@@ -7,7 +7,7 @@ use Test;
# for this test. See
# L<"http://www.nntp.perl.org/group/perl.perl6.language/22924">
-plan 21;
+plan *;
# Indexing lists
{
@@ -144,4 +144,23 @@ plan 21;
is <1 2 3>.rt62836_x, 62836, 'call user-declared method in List:: class';
}
+# RT #66304
+{
+ my $rt66304 = (1, 2, 4);
+ isa_ok $rt66304, List, 'List assigned to scalar is-a List';
+ #?rakudo 3 todo 'RT 66304'
+ is( $rt66304.WHAT, (1, 2, 4).WHAT,
+ 'List.WHAT is the same as .WHAT of list assigned to scalar' );
+ dies_ok { $rt66304[1] = 'ro' }, 'literal List element is immutable';
+ is $rt66304, (1, 2, 4), 'List is not changed by attempted assignment';
+
+ my $x = 44;
+ $rt66304 = ( 11, $x, 22 );
+ lives_ok { $rt66304[1] = 'rw' }, 'variable List element is mutable';
+ #?rakudo todo 'RT 66304'
+ is $x, 'rw', 'variable changed via assignment to list element';
+}
+
+done_testing;
+
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @moritznow stores an immutable Seq, tests are in array-ref.t |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#66304 (status was 'resolved')
Searchable as RT66304$
The text was updated successfully, but these errors were encountered: