Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

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

Owner: Nobody in particular
Requestors: bluefeet [...]

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 [...]
From: Aran Deltac <bluefeet [...]>
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: --------------------------------------- use strict; use warnings; use Foo; use Module::Refresh; my $foo = Foo->new(); foreach (1..10) { Module::Refresh->refresh; $foo->do(); sleep 10; } --------------------------------------- package Foo; use Moose; with 'Bar'; sub do { print "Do\n"; } __PACKAGE__->meta->make_immutable; 1; --------------------------------------- package Bar; use Moose::Role; 1; Now, start up and then modify the print() line in, notice the errors. I get this: Do Subroutine do redefined at 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/ 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/ 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/ 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/ 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/ 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/ 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/ 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/ line 84 Moose::Util::apply_all_roles('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Bar') called at /vcm/home/lib/site_perl/ line 57 Moose::with('Class::MOP::Class::Immutable::Moose::Meta::Class=HASH(0x9cc0350)', 'Bar') called at /vcm/home/lib/site_perl/Moose/ line 288 Moose::with('Bar') called at line 4 require called at /vcm/home/lib/site_perl/Module/ line 119 eval {...} called at /vcm/home/lib/site_perl/Module/ line 119 (unknown)('Module::Refresh', '') called at /vcm/home/lib/site_perl/Module/ line 96 (unknown)('Module::Refresh', '') called at /vcm/home/lib/site_perl/Module/ line 79 (unknown)('Module::Refresh') called at line 10 Compilation failed in require at /vcm/home/lib/site_perl/Module/ 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, 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 infrastructure.

Please report any issues with to