Guys,

Okay, this has been bugging us for a while now, because we've been
wanting to do some QA on Perl 5.12 with an eye to switching our
production environment to it at some point, but this error has stopped
us.  But I've just now had the opportunity to whittle it down to
something small enough for you guys to chew on.  Here's our example
file (a.k.a. borked.pm):

{
    package SomeRole;
    use Moose::Role;
    requires 'some_method';
}


use MooseX::Declare;

class SomeClass with SomeRole
{

    method some_method
    {
    }
    #method foo {}

}

1;

This seems to be as small as I can possibly make it.  Now, this
compiles just fine on perl 5.8.x, 5.10.x, and 5.12.x.  However, the
problem becomes when we try to include it via Mason.  Take this
simple/stupid template:

<%perl>
  print "Hello World!\n";
</%perl>
<%init>
use borked;
</%init>

This works fine on 5.8.x (where the larger code is in production even
as we speak), and I believe on 5.10.x as well (which we are using for
some of our dev sandboxes).  But not on 5.12.x (I believe we've tried
5.12.0, 5.12.1, and now 5.12.2).  There, you get this error (here I'm
using masonsh from MasonX::Shell, but this happens on Apache restart
with normal Mason):

Error during compilation of <anonymous component>:
'SomeRole' requires the method 'some_method' to be implemented by
'SomeClass' at /usr/local/lib/perl5/site_perl/5.12.2/i686-l
inux/Moose/Meta/Role/Application.pm line 77
        
Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0xa392ff8)',
'Moose::Meta::Role=H
ASH(0x9e47ff8)', 'Moose::Meta::Class=HASH(0xa41c068)') called at
/usr/local/lib/perl5/site_perl/5.12.2/i686-linux/Moose/Meta/
Role/Application/ToClass.pm line 31
        
Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0xa392ff8)',
'Moose::Met
a::Role=HASH(0x9e47ff8)', 'Moose::Meta::Class=HASH(0xa41c068)',
'HASH(0xa46ba80)') called at /usr/local/lib/perl5/site_perl/5
.12.2/i686-linux/Moose/Meta/Role.pm line 416
        Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x9e47ff8)',
'Moose::Meta::Class=HASH(0xa41c068)') called at
/usr/local/lib/perl5/site_perl/5.12.2/i686-linux/Moose/Util.pm line
133
        Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0xa41c068)',
undef, 'SomeRole') called at
/usr/local/lib/perl5/site_perl/5.12.2/i686-linux/Moose/Util.pm line 87
        Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0xa41c068)',
'SomeRole') called at borked.pm line 19
        require borked.pm called at <anonymous component> line 5
        HTML::Mason::Commands::BEGIN() called at borked.pm line 0
        eval {...} called at borked.pm line 0
        eval 'package HTML::Mason::Commands;
use strict;
use vars qw($m);
HTML::Mason::Component->new(
\'code\' => sub {
$m->debug_hook( $m->current_comp->path ) if (
HTML::Mason::Compiler::IN_PERL_DB() );

#line 4 "<anonymous component>"

use borked;
#line 1 "<anonymous component>"

  print "Hello World!\\n";
;return;
},
\'load_time\' => 1285719534,

)
;' called at /usr/local/lib/perl5/site_perl/5.12.2/HTML/Mason/Interp.pm line 844
        HTML::Mason::Interp::_do_or_eval('HTML::Mason::Interp=HASH(0x99d2b50)',
'HASH(0x9950b60)') called at
/usr/local/lib/perl5/site_perl/5.12.2/HTML/Mason/Interp.pm line 817
        
HTML::Mason::Interp::eval_object_code('HTML::Mason::Interp=HASH(0x99d2b50)',
'object_code', 'SCALAR(0x99c9640)') called at
/usr/local/lib/perl5/site_perl/5.12.2/HTML/Mason/Interp.pm line 635
        eval {...} called at
/usr/local/lib/perl5/site_perl/5.12.2/HTML/Mason/Interp.pm line 635
        HTML::Mason::Interp::make_component(undef, 'comp_source',
'<%perl>\x{a}  print "Hello
World!\n";\x{a}</%perl>\x{a}<%init>\x{a}use borked...') called at
/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm line 418
        eval {...} called at
/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm line 416
        MasonX::Shell::interp('MasonX::Shell=HASH(0x96d1620)',
'broken.html') called at
/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm line 345
        MasonX::Shell::exec('MasonX::Shell=HASH(0x96d1620)') called at
/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm line 123
        MasonX::Shell::shell('broken.html') called at
/usr/local/bin/masonsh line 11
Compilation failed in require at <anonymous component> line 5.
BEGIN failed--compilation aborted at <anonymous component> line 5.


Stack:
  [/usr/local/lib/perl5/site_perl/5.12.2/HTML/Mason/Interp.pm:636]
  [/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm:418]
  [/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm:345]
  [/usr/local/lib/perl5/site_perl/5.12.2/MasonX/Shell.pm:123]
  [/usr/local/bin/masonsh:11]

Okay, ready for the weird part?  See that commented out "method foo"?
If I uncomment it, the error goes away.

Copious details follow. :-)

Last time I had a weird Moose error, someone asked me about version
numbers of various modules, so here they are in case someone wants to
know:

 perl -MMooseX::Declare -le 'no strict qw<refs>; our $ver =
"${_}::VERSION" and print "$_ :: $$ver" foreach qw<Moose
MooseX::Declare MooseX::Method::Signatures Class::MOP Devel::Declare>'
Moose :: 1.14
MooseX::Declare :: 0.34
MooseX::Method::Signatures :: 0.36
Class::MOP :: 1.08
Devel::Declare :: 0.006000

Changing the code in various ways makes the error (or the hacky fix)
change in weird ways too:

1) Taking out the MooseX::Declare and declaring everything
vanilla-Moose-style makes it work.

2) However, it doesn't seem to be MooseX::Declare as much as it is
MooseX::Method::Signatures.  Just changing the "method some_method" to
"sub some_method" makes it work.

3) But then changing "method foo" to "sub foo" not only keeps it
broken, but makes the "fix" not work either.

4) I tried taking the MooseX::Declare out and using MMS directly:

{
    package SomeRole;
    use Moose::Role;
    requires 'some_method';
}


{
    package SomeClass;
    use Moose;
    use MooseX::Method::Signatures;

    with 'SomeRole';

    method some_method
    {
    }
    #method foo {}

}

1;

This also keeps it broken, and negates the "fix."

5) For the ultimate weirdness, this:

{
    package SomeRole;
    use Moose::Role;
    requires 'some_method';
}


use MooseX::Declare;

class SomeClass with SomeRole
{

    method some_method { }
    #method foo {}

}

1;

actually fixes it altogether.  (The difference between this one and
the original is subtle: it's the fact that the braces are on the same
line as as the method now.)

So I have apparently stumbled upon some bizarre juxtabug involving all
of Perl 5.12, Mason, and MooseX::Method::Signatures, and possibly
MooseX::Declare (which at least changes the behavior in that it allows
the bizarre "fix" of adding a useless method at the end).  I have
literally no idea how to proceed from here.  Does anyone have any
suggestions for me?  Are there more details I can provide?

Thanx all you Moosites for all your help.  Working with Moose over the
past 9 months or so has really been awesome (despite the fact that I
keep popping up here with weird errors :-D ).


            -- Buddy

Reply via email to