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
chained array item assignment leaves one item undefined #2292
Comments
From @moritz12:05 < moritz_> rakudo: my @a = 1, 2, 3; my @b; my $c = @b[0] = @a[1]; both should be 2 12:04 < moritz_> rakudo: my @b; my $c = @b[0] = 1; say $c; say @b[0]; ... and it works fine if the right-most term is not an array item, but Found while pursuing masak's coding contest, problem 5. Cheers, |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in S03-operators/assign.t commit 1e438c8bafa5b88fce0181dc64484a423b2ca433 [assign] Test for RT 80614: chained array item assignment Inline Patchdiff --git a/S03-operators/assign.t b/S03-operators/assign.t
index 0386e26..53e30c1 100644
--- a/S03-operators/assign.t
+++ b/S03-operators/assign.t
@@ -6,7 +6,7 @@ use Test;
# V
# L<S03/Changes to Perl 5 operators/list assignment operator now parses on the right>
-plan 242;
+plan 244;
# tests various assignment styles
@@ -764,4 +764,15 @@ sub l () { 1, 2 };
is $x, 5, '... with correct result';
}
+# RT #80614
+{
+ my @a = 1,2,3;
+ my @b;
+ my $rt80614 = @b[0] = @a[1];
+
+ is $rt80614, 2, 'assignment to scalar via array item from array item';
+ #?rakudo todo 'RT 80614'
+ is @b[0], 2, 'assignment to array item from array item to scalar';
+}
+
# vim: ft=perl6 |
The RT System itself - Status changed from 'new' to 'open' |
From @cokeOn Sun Dec 12 03:09:07 2010, moritz wrote:
A test for this was added to S03-operators/assign.t - 2 tests in a block - one passes, one fails (and is todo'd) - but if you run that test directly (hoisting it out into its own file), it passes. very odd. -- |
From @usev6I tried to golf this (chained assignment and test failure) a bit and found the following: $ perl6-m -e 'my $x; $x = 1; my @a; my $y = @a[0] = 2; say @a[0]' The following looks weird as well: $ perl6-m -e 'my $y; my @a = (); $y = @a[0] = 2; say @a[0]' |
1 similar comment
From @usev6I tried to golf this (chained assignment and test failure) a bit and found the following: $ perl6-m -e 'my $x; $x = 1; my @a; my $y = @a[0] = 2; say @a[0]' The following looks weird as well: $ perl6-m -e 'my $y; my @a = (); $y = @a[0] = 2; say @a[0]' |
@hoelzro - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#80614 (status was 'resolved')
Searchable as RT80614$
The text was updated successfully, but these errors were encountered: