Fix readpipe overriden with a constant
authorFather Chrysostomos <sprout@cpan.org>
Tue, 5 Nov 2013 05:49:27 +0000 (21:49 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 5 Nov 2013 14:15:15 +0000 (06:15 -0800)
commit952ad5fef90a698364a2c483108893d79afc5645
tree657f1f804544ef5309849a84ad1048bef98db75c
parent53eda0bff2fe09151fa42625b5e16ba2307a8b9b
Fix readpipe overriden with a constant

qx and `` don’t take into account that some subs are stored in a more
lightweight form than usual.  These two programs should behave the
same way, but, as you can see below the __END__ markers, the output is
different:

use constant foo=>1;
BEGIN { *{"CORE::GLOBAL::readpipe"} = \&{"foo"}; 1}
warn ``
__END__
Warning: something's wrong at - line 3.

use constant foo=>1; BEGIN { *{"CORE::GLOBAL::readpipe"} = \&{"foo"}; 1} warn ``
__END__
Too many arguments for CORE::GLOBAL::readpipe at - line 3, at end of line
Execution of -e aborted due to compilation errors.

The latter is the correct behaviour.¹  The only different is \&{"foo"}
vs \&foo, which triggers an optimisation.

S_readpipe_override in toke.c needs to take the optimisation into
account (that stash entries are not necessarily globs but can be
upgraded to such).

¹ Except that the sub name reported is unexpected.  Non-threaded
  builds give me that; threaded builds give me main::foo.  But that is
  a separate bug.
t/op/override.t
toke.c