72 lines
1.7 KiB
Diff
72 lines
1.7 KiB
Diff
|
From 282d9dfeb4cea3c2d0335ba78faa3a9db931f1ec Mon Sep 17 00:00:00 2001
|
||
|
From: David Mitchell <davem@iabyn.com>
|
||
|
Date: Tue, 11 Aug 2020 13:58:51 +0100
|
||
|
Subject: [PATCH] list assign in list context: honour LHS undef
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
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.
|
||
|
|
||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||
|
---
|
||
|
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 e9f1ffe7a4..3564dd7e12 100644
|
||
|
--- a/pp_hot.c
|
||
|
+++ b/pp_hot.c
|
||
|
@@ -2743,8 +2743,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();
|
||
|
--
|
||
|
2.25.4
|
||
|
|