You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where the first %s is the class name that constructor is being compiled in, and the second %s contains a whole bunch of code dealing with type constraints, defaults, triggers, etc.
That code potentially contains various Perl built-ins like push. But the class that the constructor is being compiled for might have overridden push, in which case the compiled object initializer will potentially see the overridden push instead of CORE::push.
A quick fix would be something like:
package %s;
sub {
my($meta, $instance, $args, $is_cloning) = @_;
do { package Mouse::Meta::Method::Constructor; %s };
return $instance;
}
This is probably not the only place where this issue occurs, but it's the place that's bitten me.
TLDR:
This warns:
package Foo;
use Mouse;
has bar => ( is => 'ro', trigger => sub {} );
sub push { 1 }
Foo->new( bar => 1 );
This dies:
package Foo;
use Mouse;
use subs 'push';
has bar => ( is => 'ro', trigger => sub {} );
sub push { die; }
Foo->new( bar => 1 );
The text was updated successfully, but these errors were encountered:
In Mouse::Meta::Method::Constructor, the
_generate_initialize_object
method generates a coderef by evaluating a string like:Where the first
%s
is the class name that constructor is being compiled in, and the second%s
contains a whole bunch of code dealing with type constraints, defaults, triggers, etc.That code potentially contains various Perl built-ins like
push
. But the class that the constructor is being compiled for might have overriddenpush
, in which case the compiled object initializer will potentially see the overriddenpush
instead ofCORE::push
.A quick fix would be something like:
This is probably not the only place where this issue occurs, but it's the place that's bitten me.
TLDR:
This warns:
This dies:
The text was updated successfully, but these errors were encountered: