CC: | Chris Tijerina <CTijerina [...] emortgagelogic.com>, David Lewis <dlewis [...] emortgagelogic.com>, Eric Hall <ehall [...] emortgagelogic.com> |
Subject: | Kavorka sometimes eats use strict 'vars' error messages |
Date: | Mon, 19 May 2014 16:22:34 -0500 |
To: | "bug-Kavorka [...] rt.cpan.org" <bug-Kavorka [...] rt.cpan.org> |
From: | Jonathan Cast <JCast [...] emortgagelogic.com> |
Loading the attached file using `perl -Meats::Strict::Vars::Error -E 1' produces the following output (included in its entirety):
Eval went very, very wrong:
{
my $_QUOTED = ${$_[1]->{"\$_QUOTED"}};
my $default_for_signature_5fclass = ${$_[1]->{"\$default_for_signature_5fclass"}};
my $default_for_traits = ${$_[1]->{"\$default_for_traits"}};
my $default_for_attributes = ${$_[1]->{"\$default_for_attributes"}};
no warnings 'closure';
sub Kavorka::Sub::Method::new {
package Method::Generate::Constructor;
BEGIN {
$^H = "2018";
${^WARNING_BITS} = "\377\377\377\377\377\377\377\377\377\377\377\377\377\017";
%^H = (
);
}
my $class = shift;
$class = ref($class) if ref($class);
if ($class ne "Kavorka::Sub::Method") {
if ($Moo::MAKERS{$class}) {
Moo->_constructor_maker_for($class,"Kavorka::Sub::Method");
return $class->new(@_);
} elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) {
return $meta->new_object($class->BUILDARGS(@_));
}
}
my $args;
if ( scalar @_ == 1 ) {
unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
die "Single parameters to new() must be a HASH ref"
." data => ". $_[0] ."\n";
}
$args = { %{ $_[0] } };
}
elsif ( @_ % 2 ) {
die "The new() method for $class expects a hash reference or a key/value list."
. " You passed an odd number of arguments\n";
}
else {
$args = {@_};
}
my $new = bless({}, $class);;
if (exists $args->{"_pads_to_poke"}) {
$new->{"_pads_to_poke"} = $args->{"_pads_to_poke"};
}
if (exists $args->{"_tmp_name"}) {
$new->{"_tmp_name"} = $args->{"_tmp_name"};
}
if (exists $args->{"_unwrapped_body"}) {
$new->{"_unwrapped_body"} = $args->{"_unwrapped_body"};
}
$new->{"attributes"} = (
exists $args->{"attributes"}
? $args->{"attributes"}
: $default_for_attributes->($new)
);
if (exists $args->{"body"}) {
$new->{"body"} = $args->{"body"};
}
if (exists $args->{"declared_name"}) {
$new->{"declared_name"} = $args->{"declared_name"};
}
if (exists $args->{"keyword"}) {
$new->{"keyword"} = $args->{"keyword"};
}
if (exists $args->{"package"}) {
$new->{"package"} = $args->{"package"};
}
if (exists $args->{"prototype"}) {
$new->{"prototype"} = $args->{"prototype"};
}
if (exists $args->{"qualified_name"}) {
$new->{"qualified_name"} = $args->{"qualified_name"};
}
if (exists $args->{"signature"}) {
$new->{"signature"} = $args->{"signature"};
}
$new->{"signature_class"} = (
exists $args->{"signature_class"}
? $args->{"signature_class"}
: $default_for_signature_5fclass->($new)
);
$new->{"traits"} = (
exists $args->{"traits"}
? $args->{"traits"}
: $default_for_traits->($new)
);
return $new;
}
$_QUOTED->[3] = \&Kavorka::Sub::Method::new
}
1;
BEGIN not safe after errors--compilation aborted at (eval 32) line 6.
Compilation failed in require.
BEGIN failed--compilation aborted.
Note that the actual error from 'use strict vars':
Global symbol "$foo" requires explicit package name at /home/castj/src/examples/Eats/Strict/Vars/Error.pm line 9.
does not appear in the output, even though the error is in a regular sub and not the Kavorka method. Removing the 'delete' method entirely, or moving it after the 'create' method, seem to be the only way to cause perl to display the use strict 'vars' error message as it should. Other permutations produce other, irrelevant, error messages, but nothing causes the regular error message to be displayed.
Jonathan
Message body is not shown because sender requested not to inline it.