From b802abc5f61d1342b480ab2dcad2eb9f8d28ca43 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Tue, 11 Aug 2020 13:58:51 +0100 Subject: 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) --- pp_hot.c | 2 +- t/op/aassign.t | 10 +++++++++- 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(); -- cgit v1.2.1