nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

can() doesn't return true for a prototype; #275

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$>perl -e 'package Alice; sub sing; package main; $c = bless {}, 'Alice'; print 
"ok\n" if $c->can("sing")'
ok

$>perlcc -r -e 'package Alice; sub sing; package main; $c = bless {}, 'Alice'; 
print "ok\n" if $c->can("sing")'

So the problem I assume is that B::C can't or chooses not to report that Alice 
has a prototyped subroutine. This might trip up autoload among other things?

NOTE: If this gets fixed, let's make sure this one passes the same as perl too:
$>perlcc -r -e 'package Girl; sub sing; package Alice; @ISA = ("Girl"); package 
main; $c = bless {}, 'Alice'; print "ok\n" if $c->can("sing"); $c->sing()'
Can't locate object method "sing" via package "Alice" at -e line 1.

$>perl -e 'package Girl; sub sing; package Alice; @ISA = ("Girl"); package 
main; $c = bless {}, 'Alice'; print "ok\n" if $c->can("sing"); $c->sing()'
ok
Undefined subroutine &Girl::sing called at -e line 1.

Note that perl seems to know what subroutine it should have called in the 
inheritance path, regardles of whether sing is defined.

Original issue reported on code.google.com by todd.e.rinaldo on 23 Jan 2014 at 10:36

GoogleCodeExporter commented 9 years ago
This is effectively related to the current treatment of empty cv's

Original comment by reini.urban on 28 Jan 2014 at 6:08