Subject: | anon sub attrs silently ignored under perl -d |
% cat wtf.t
#!perl
use strict;
use warnings;
use Test::More tests => 1;
{
package Zomg;
use Moose;
use MooseX::MethodAttributes;
no warnings 'once';
*foo = sub : Hello {};
}
is_deeply +Zomg->meta->get_method('foo')->attributes, ['Hello'];
__END__
% perl wtf.t
1..1
ok 1
% PERLDB_OPTS=NonStop perl -d wtf.t
1..1
not ok 1
# Failed test at wtf.t line 17.
# Structures begin differing at:
# $got->[0] = Does not exist
# $expected->[0] = 'Hello'
# Looks like you failed 1 test of 1.
=> Subroutine attributes are silently ignored under perl -d.
This bug also affects Method::Signatures and similar modules because they use anonymous subs + glob assignment internally.
This in turn interacts badly with Catalyst. Take a controller like this:
{
package Foo::Controller::Product;
use Moose;
use syntax 'method';
BEGIN { extends 'Catalyst::Controller' }
method list($ctx) : Path Args(0) {
...
}
}
Catalyst uses MooseX::MethodAttributes to handle attributes to register actions. Syntax::Feature::Method uses Method::Signatures::Simple, which uses glob assignment to define methods. The result is that visiting /product gives a 404 error (because no actions got registered) but only if the debugger is active.
Unfortunately this also breaks profiling (Devel::NYTProf) because it's implemented using -d (possibly coverage checks (Devel::Cover) too, I haven't checked).
Subject: | wtf.t |
#!perl
use strict;
use warnings;
use Test::More tests => 1;
{
package Zomg;
use Moose;
use MooseX::MethodAttributes;
no warnings 'once';
*foo = sub : Hello {};
}
is_deeply +Zomg->meta->get_method('foo')->attributes, ['Hello'];
__END__