Subject: | Forbid recursive runtime role application |
I *think* this should be a bug as I can't find a use case for it and
it's bitten me pretty hard. For any role, do this:
MyRole->meta->apply($foo) while 1;
Eventually you will get fun errors such as:
Deep recursion on subroutine "MRO::Compat::__get_linear_isa_dfs" at
/home/poec01/trunk/Pips3/deps/lib/perl5/MRO/Compat.pm line 123.
Deep recursion on subroutine
"Class::MOP::Class::class_precedence_list" at
/home/poec01/trunk/Pips3/deps/lib/perl5/i86pc-solaris-thread-multi/Class/MOP/Class.pm
line 613.
Deep recursion on subroutine "MRO::Compat::__get_linear_isa_dfs" at
/home/poec01/trunk/Pips3/deps/lib/perl5/MRO/Compat.pm line 123.
Deep recursion on subroutine "MRO::Compat::__get_linear_isa_dfs" at
/home/poec01/trunk/Pips3/deps/lib/perl5/MRO/Compat.pm line 123.
Deep recursion on subroutine "MRO::Compat::__get_linear_isa_dfs" at
/home/poec01/trunk/Pips3/deps/lib/perl5/MRO/Compat.pm line 123.
Deep recursion on subroutine "MRO::Compat::__get_linear_isa_dfs" at
/home/poec01/trunk/Pips3/deps/lib/perl5/MRO/Compat.pm line 123.
Deep recursion on subroutine
"Class::MOP::Class::class_precedence_list" at
/home/poec01/trunk/Pips3/deps/lib/perl5/i86pc-solaris-thread-multi/Class/MOP/Class.pm
line 613.
Deep recursion on subroutine "MRO::Compat::__get_linear_isa_dfs" at
/home/poec01/trunk/Pips3/deps/lib/perl5/MRO/Compat.pm line 123.
Recursive inheritance detected while looking for method '()' in
package 'Foo' at
/home/poec01/trunk/Pips3/deps/lib/perl5/i86pc-solaris-thread-multi/Class/MOP/Instance.pm
line 157.
Recursive inheritance detected while looking for method '()' in
package 'Foo'.
Reapplying a role at runtime to an instance should probably be fatal (I
think).
This came up as we have test code which fetches a singleton (yeah, I
know) and applies a role to that.
Cheers,
Ovid