This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse join("", pos) correctly
authorFather Chrysostomos <sprout@cpan.org>
Wed, 15 Oct 2014 05:52:29 +0000 (22:52 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 15 Oct 2014 05:52:29 +0000 (22:52 -0700)
commit3b4e2a4d1bc00f57f5befb2896b89b65ab4688d1
treefeb37aa059ed10b3239a8fd69c44ada42e2b69d4
parente791f90a39908c06e138681e3ceb8504cf71c52b
Deparse join("", pos) correctly

I optimised join into stringify if it had a list of one scalar-
returning op.

$ ./perl -Ilib -MO=Deparse -e '$_ = join $foo, $bar'
$_ = "$bar";
-e syntax OK

The problem, though, is that we now create op trees that didn’t happen
before,* and B::Deparse can’t handle them correctly:

$ ./perl -Ilib -MO=Deparse -e '$_ = join $foo, pos'
$_ = "pos($_)";
-e syntax OK

So we need to turn that into:

$_ = join('???', pos);

* Actually, in 5.8 it was possible to interpolate arbitrary expres-
sions after ‘$_[0]->’:

$_ = "\n,rekcah lreP rehtona tsuJ"; sub a{chop}
print "${[bless[]]}[0]->a . reverse $_";

And that, consequently, did not deparse properly.
lib/B/Deparse.pm
lib/B/Deparse.t