develooper Front page | perl.perl5.porters | Postings from January 2020

Re: Bug in format introduced in 5.27.6

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
January 21, 2020 13:35
Subject:
Re: Bug in format introduced in 5.27.6
Message ID:
20200121143455.518b2cdd@pc09.procura.nl
On Tue, 21 Jan 2020 12:49:16 +0100, "H.Merijn Brand"
<h.m.brand@xs4all.nl> wrote:

> perl -le '$~ = "L02"; { local $~ = "$~h"; print $~; }'
> 
> up to and including perl-5.27.5, this would print "L02h"
> as of 5.27.6 this prints "h"
> 
> this breaks production code :(

bisect.pl --start=v5.27.5 --end=v5.27.6 -- ./perl -Ilib -e '$~="A";{local$~="$~A";print $~;exit($~ ne"AA")}'

→

e839e6ed99c6b25aee589f56bb58de2f8fa00f41 is the first bad commit
commit e839e6ed99c6b25aee589f56bb58de2f8fa00f41
Author: David Mitchell <davem@iabyn.com>
Date:   Tue Aug 8 18:42:14 2017 +0100

    Add OP_MULTICONCAT op

    Allow multiple OP_CONCAT, OP_CONST ops, plus optionally an OP_SASSIGN
    or OP_STRINGIFY, to be combined into a single OP_MULTICONCAT op, which can
    make things a *lot* faster: 4x or more.


Is this an indication that there might be more breakage or will $~ be
the exception to the rule?

Looks like (at least) $^ (expected), $^O and $\ are also affected

--8<---
my @p = qw( 5.26.2 5.28.2 );
say join "\t" => "Var", @p;
foreach my $v ( "~", "^", "ARGV", '"', "0", ";", "a", "^O", "^X",
		",", "/", "\\", "^L", ":", "\@") {

    print "\$$v\t";

    open my $fh, ">", "x.pl";
    say $fh qq{#!/pro/bin/perl};
    say $fh qq{use 5.12.0;};
    say $fh qq{use warnings;};
    say $fh qq{\$$v = "A";};
    say $fh qq{{ local \$$v = \$$v . "A"; say \$$v }};
    close $fh;

    foreach my $p (qw( 5.26.2 5.28.2 )) {
	chomp (my $o = `perl$p x.pl`);
	print "$o\t";
	}
    say "";
    }
-->8---

Var     5.26.2  5.28.2
$~      AA      A
$^      AA      A
$ARGV   AA      AA
$"      AA      AA
$0      AA      AA
$;      AA      AA
$a      AA      AA
$^O     AA      Use of uninitialized value in concatenation (.) or string at x.pl line 5.
A
$^X     AA      AA
$,      AA      AA
$/      AA      AA
$\      AA      Use of uninitialized value in concatenation (.) or string at x.pl line 5.
A
$^L     AA      AA
$:      AA      AA
$@      AA      AA

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.31      porting perl5 on HP-UX, AIX, and Linux
https://useplaintext.email  https://tux.nl  http://www.test-smoke.org
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous | 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