Subject: | Fireworks on overridden CORE::GLOBAL::bless combined with $INC{"Moose.pm"} |
For unrelated reasons I need to hook CORE::GLOBAL::bless in my test suite in order to validate a particular condition during CI.
The failure can be reduced to the below, note how both the lack of Moose and the lack of the ->isa check make the problem disappear:
~$ perl -e '
BEGIN {
*CORE::GLOBAL::bless = sub {
my $obj = CORE::bless( $_[0], (@_ > 1) ? $_[1] : CORE::caller() );
# without this - no issues
if( $obj->isa("Foo") ) { my $do = "some stuff in the future" }
$obj;
};
}
# without this - no issues either
BEGIN { require Moose }
use Moo;
'
and results in:
Can't locate object method "install_delayed" via package "Method::Generate::Constructor" at /home/rabbit/perl5/perlbrew/perls/5.22.1/lib/site_perl/5.22.1/Moo.pm line 218.
BEGIN failed--compilation aborted at /home/rabbit/perl5/perlbrew/perls/5.22.1/lib/site_perl/5.22.1/Method/Generate/Constructor.pm line 8.
Compilation failed in require at /home/rabbit/perl5/perlbrew/perls/5.22.1/lib/site_perl/5.22.1/Moo.pm line 161.
BEGIN failed--compilation aborted at -e line 16.