This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop ck_rvconst from treating GV constants as strings
authorFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 05:31:10 +0000 (22:31 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 05:49:19 +0000 (22:49 -0700)
commitacb187b49e0841a5b6410cfd34d77b8e8a6c242c
tree2642dc35b054071d40c312906d896f67a0e0c23a
parenteff754733a9f186c56767f2a49ab50e67600d3de
Stop ck_rvconst from treating GV constants as strings

sub foo { 42 }
use constant bar => *foo;
BEGIN { undef *foo }
warn &{+bar};
warn bar->();

Obviously the last two lines should print the same thing, because they
both call the value of the ‘bar’ constant as a suroutine.

But op.c:ck_rvconst messes up the ‘bar->()’ at compile time, treating
the bar glob (a copy of the original *foo glob, and not the *foo glob
itself, which has since been undefined) as a string and using it to
look up a glob.

ck_rvconst should not do anything if the constant’s value is a glob.
op.c
t/op/gv.t