summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2020-08-11 13:58:51 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2021-01-06 17:39:25 +0000
commitb802abc5f61d1342b480ab2dcad2eb9f8d28ca43 (patch)
tree3db19d8a6e11124e62d593b96809c634dad1c61c
parent1da7e62b5d41e8aff3a324906226a6b22ba7fce9 (diff)
downloadperl-b802abc5f61d1342b480ab2dcad2eb9f8d28ca43.tar.gz
list assign in list context: honour LHS undef
GH #16685 In @a = ($x, undef, undef) = (1)) @a should have 3 elements. v5.25.6-79-gb09ed995ad broke this and was returning one element. The fix is simple: that previous commit made it so that elements were pushed back onto the stack only if they weren't immortal, so &PL_sv_undef was getting skipped. Make it so they always are. (cherry picked from commit 282d9dfeb4cea3c2d0335ba78faa3a9db931f1ec)
-rw-r--r--pp_hot.c2
-rw-r--r--t/op/aassign.t10
2 files changed, 10 insertions, 2 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 004dfba6b0..95f6d64411 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2738,8 +2738,8 @@ PP(pp_aassign)
if (!SvIMMORTAL(lsv)) {
sv_set_undef(lsv);
SvSETMAGIC(lsv);
- *relem++ = lsv;
}
+ *relem++ = lsv;
break;
} /* switch */
} /* while */
diff --git a/t/op/aassign.t b/t/op/aassign.t
index 9128f9fd98..aa1f2c722c 100644
--- a/t/op/aassign.t
+++ b/t/op/aassign.t
@@ -595,7 +595,7 @@ SKIP: {
}
{
- # GH #17816
+ # GH #16685
# don't use the "1-arg on LHS can't be common" optimisation
# when there are undef's there
my $x = 1;
@@ -603,5 +603,13 @@ SKIP: {
is("@a", "2 1", "GH #17816");
}
+{
+ # GH #17816
+ # honour trailing undef's in list context
+ my $x = 1;
+ my @a = (($x, undef, undef) = (1));
+ is(scalar @a, 3, "GH #17816");
+}
+
done_testing();