Skip Menu |
 

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 59697
Status: rejected
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: bluefeet [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Module::Refresh Errors on Immutable Classes with Roles
Date: Sun, 25 Jul 2010 19:19:43 -0700
To: bug-Class-MOP [...] rt.cpan.org
From: Aran Deltac <bluefeet [...] gmail.com>
Download (untitled) / with headers
text/plain 3.5k
I've tested this on a recent build of Moose/Class::MOP. Here's my test case: test.pl: --------------------------------------- use strict; use warnings; use Foo; use Module::Refresh; my $foo = Foo->new(); foreach (1..10) { Module::Refresh->refresh; $foo->do(); sleep 10; } Foo.pm: --------------------------------------- package Foo; use Moose; with 'Bar'; sub do { print "Do\n"; } __PACKAGE__->meta->make_immutable; 1; Bar.pm: --------------------------------------- package Bar; use Moose::Role; 1; Now, start up test.pl and then modify the print() line in Foo.pm, notice the errors. I get this: Do Subroutine do redefined at Foo.pm line 6. The 'Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)' method cannot be called on an immutable instance at /vcm/home/lib/site_perl/i386-linux-thread-multi/Class/MOP/Class/Immutable/Trait.pm line 32 Class::MOP::Class::Immutable::Trait::_immutable_cannot_call('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)') called at /vcm/home/lib/site_perl/Moose/Meta/Class/Immutable/Trait.pm line 14 Class::MOP::Class:::around('CODE(0x99f538c)', 'Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Moose::Meta::Role=HASH(0x9ce61d0)') called at /vcm/home/lib/site_perl/i386-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 159 Class::MOP::Method::Wrapped::__ANON__('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Moose::Meta::Role=HASH(0x9ce61d0)') called at /vcm/home/lib/site_perl/i386-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 89 Class::MOP::Class::Immutable::Moose::Meta::Class::add_role('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Moose::Meta::Role=HASH(0x9ce61d0)') called at /vcm/home/lib/site_perl/Moose/Meta/Role/Application/ToClass.pm line 33 Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9708fb4)', 'Moose::Meta::Role=HASH(0x9ce61d0)', 'Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)') called at /vcm/home/lib/site_perl/Moose/Meta/Role.pm line 395 Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x9ce61d0)', 'Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)') called at /vcm/home/lib/site_perl/Moose/Util.pm line 121 Moose::Util::_apply_all_roles('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'undef', 'Bar') called at /vcm/home/lib/site_perl/Moose/Util.pm line 84 Moose::Util::apply_all_roles('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Bar') called at /vcm/home/lib/site_perl/Moose.pm line 57 Moose::with('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Bar') called at /vcm/home/lib/site_perl/Moose/Exporter.pm line 288 Moose::with('Bar') called at Foo.pm line 4 require Foo.pm called at /vcm/home/lib/site_perl/Module/Refresh.pm line 119 eval {...} called at /vcm/home/lib/site_perl/Module/Refresh.pm line 119 (unknown)('Module::Refresh', 'Foo.pm') called at /vcm/home/lib/site_perl/Module/Refresh.pm line 96 (unknown)('Module::Refresh', 'Foo.pm') called at /vcm/home/lib/site_perl/Module/Refresh.pm line 79 (unknown)('Module::Refresh') called at test.pl line 10 Compilation failed in require at /vcm/home/lib/site_perl/Module/Refresh.pm line 119. D2o D2o D2o D2o D2o D2o D2o D2o D2o Now, if I remove the `with 'Bar'` line OR the `__PACKAGE__->meta->make_immutable` line the error goes away and everything works as expected. I'm a bit at a loss as to what the issue is. For now I'm just going to remove the make_immutable lines during development. Aran
Download (untitled) / with headers
text/plain 387b
On Sun Jul 25 22:19:53 2010, bluefeet@gmail.com wrote: Show quoted text
> I've tested this on a recent build of Moose/Class::MOP. Here's my > test > case:
I haven't looked at this too deeply, but I suspect that for Moose to work with a module reloader of this sort, there needs to be a hook (in Module::Refresh) for destroying the old metaclass object in the CMOP cache before the module is reloaded.
Is this still an issue? Marking stalled until we find out. -Chris
Download (untitled) / with headers
text/plain 134b
Yeah, there's nothing that Moose can do about this. Try out Class::Refresh if you want something that was designed to work with Moose.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.