develooper Front page | perl.perl5.porters | Postings from September 2018

[perl #133503] regression in list assignment with undef in listcontext

Thread Next
From:
Wolf-Dietrich Moeller
Date:
September 7, 2018 15:48
Subject:
[perl #133503] regression in list assignment with undef in listcontext
Message ID:
rt-4.0.24-28059-1536335308-774.133503-75-0@perl.org
# New Ticket Created by  Wolf-Dietrich Moeller 
# Please include the string:  [perl #133503]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133503 >


The documentation on assignments in perlop reads:
"a list assignment in list context produces the
 list of lvalues assigned to"

The following program shows a regression,
when the "list assigned to" contains "undef".
(tested with two old versions available to me:
- Strawberry Perl Portable 5.22.3.1-32bit
- Strawberry Perl Portable 5.26.2.1-32bit)

The newer version 5.26 (and also 5.28) works correctly if the
third element in the list assigned to is a variable (test 3),
but ignores the third element if it is undef.
Thus @s in test 4 only has 2 elements instead of 3.

#### test program
my ($y, @s);
my $x = 5;
print 'test 1: ',scalar (@s = (($y) = (8,9))),' ',$y,' ',$x//'undef',"\n";
my $x = 5;
print 'test 2: ',scalar (@s = (($y,undef) = (8,9))),' ',$y,'
',$x//'undef',"\n";
my $x = 5;
print 'test 3: ',scalar (@s = (($y,undef,$x) = (8,9))),' ',$y,'
',$x//'undef',"\n";
my $x = 5;
print 'test 4: ',scalar (@s = (($y,undef,undef) = (8,9))),' ',$y,'
',$x//'undef',"\n";
#### end test program

Result in 5.22 (correct, @s == 3):
test 1: 1 8 5
test 2: 2 8 5
test 3: 3 8 undef
test 4: 3 8 5

Result in 5.26 (test 4 incorrect, @s == 2):
test 1: 1 8 5
test 2: 2 8 5
test 3: 3 8 undef
test 4: 2 8 5


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About