This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
rv2cv hooks should not create 2nd-class subs
authorFather Chrysostomos <sprout@cpan.org>
Fri, 6 Jul 2012 21:19:21 +0000 (14:19 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 7 Jul 2012 05:26:32 +0000 (22:26 -0700)
commit39c012bc2fc2f1cf310f6d4ba499ec58a7bad900
tree5e16f7a8ff0b4817fc15f36c7c9e2a82352bd82c
parenta4fd4a89a854c8ba9dbb6aa0202632e82dadbf84
rv2cv hooks should not create 2nd-class subs

$ perl5.17.2 -Mblib -e 'sub foo{}; foo $bar; use Lexical::Sub baz => sub{}; baz $bar'
Can't call method "baz" on an undefined value at -e line 1.
$ perl5.17.2 -Mblib -e 'sub foo{}; foo bar; use Lexical::Sub baz => sub{}; baz bar'
Can't locate object method "baz" via package "bar" (perhaps you forgot to load "bar"?) at -e line 1.

So if you use Lexical::Sub, your sub doesn’t get to participate in
determining whether ‘foo $bar’ or ‘foo bar’ is a method call.

This is because Lexical::Sub uses an rv2cv hook to intercept sub
lookup.  And toke.c:S_intuit_method thinks there cannot be a CV with-
out a GV (which was the case when it was first written).

Commit f7461760 introduced this rv2cv hooking for bareword lookup, but
failed to update S_intuit_method accordingly.
MANIFEST
ext/XS-APItest/APItest.xs
ext/XS-APItest/t/sym-hook.t [new file with mode: 0644]
toke.c