diff --git a/pp.c b/pp.c index be7649d375bb..4016e00cb1be 100644 --- a/pp.c +++ b/pp.c @@ -7516,7 +7516,7 @@ PP(pp_refassign) in leavesub? */ } else - rpp_popfree_to_NN(PL_stack_sp - (extra + 1)); + rpp_popfree_to_NN(PL_stack_sp - (extra + cBOOL(GIMME_V == G_VOID))); return NORMAL; } diff --git a/t/op/lvref.t b/t/op/lvref.t index 14362d57c09f..1435aa9f5125 100644 --- a/t/op/lvref.t +++ b/t/op/lvref.t @@ -5,7 +5,7 @@ BEGIN { set_up_inc("../lib"); } -plan 201; +plan 203; eval '\$x = \$y'; like $@, qr/^Experimental aliasing via reference not enabled/, @@ -225,6 +225,17 @@ package ArrayTest { is \@i, $old, '(\local @a) unwound'; } +# scalar assignment in scalar context +# GH #22710 + +{ + my @a; + my $ra = ["a", "b"]; + my $x = (\@a = $ra); + is \@a, $ra, 'scalar cxt same array'; + is $x, $ra, 'scalar cxt return value same array'; +} + # Test list assignments in both lval and rval list context # # Note that these tests essentially just codify current behaviour.