This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
list assign in list context was over-optimising
authorDavid Mitchell <davem@iabyn.com>
Tue, 11 Aug 2020 10:55:46 +0000 (11:55 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 11 Aug 2020 15:14:21 +0000 (16:14 +0100)
commit5b354d2a8a6fea46c62048464c6722560cb1c907
tree3f3defd530bd7ca6b5dec4570e8703edf22ad8bc
parent1ad5a39ccaca372a3b35f5a76e16aa2aacab104a
list assign in list context was over-optimising

GH #17816

This code:

    my $x = 1;
    print (($x, undef) = (2 => $x));

was printing "22" when it should have been printing "21".
An optimisation skips the 'common values on both sides' test
when the LHS of an assign only contains a single var; as the example
above shows, this is not sufficient.

This was broken by v5.23.1-202-g808ce55782

This commit fixes it by counting undef's on the LHS towards the var
count if they don't appear first.
op.c
t/op/aassign.t