Fix readline overriden with a constant
authorFather Chrysostomos <sprout@cpan.org>
Tue, 5 Nov 2013 21:02:36 +0000 (13:02 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 6 Nov 2013 13:56:03 +0000 (05:56 -0800)
commita93a1bfd14dd3999c151fe1931d06a570700eb5c
tree8fb1c7e76b3f02aeb411c4f4aaf087d38ee065d7
parent6041797116255448479c592eb33e3a41ef2f59dc
Fix readline overriden with a constant

<> doesn’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::readline"} = \&{"foo"}; 1}
warn <a>
__END__
Warning: something's wrong at - line 3.

use constant foo=>1;
BEGIN { *{"CORE::GLOBAL::readline"} = \&foo; 1}
warn <a>
__END__
Too many arguments for main::foo 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, the first of which triggers an optimisation.

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