Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 120000
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: default, init_arg, trigger combo cause code eval failure
Moo 2.003 Sub::Quote 2.003001 Perl 5.22.1 This code: package Foo { use Moo; has _foo => ( is => 'rwp', default => 1, init_arg => undef, trigger => 1 ); } Foo->new; results in: Use of uninitialized value $test in concatenation (.) or string at [...]/Method/Generate/Accessor.pm line 575. Eval went very, very wrong: 0001: { 0002: my $_UNQUOTED = ${$_[1]->{"\$_UNQUOTED"}}; 0003: my $_QUOTED = ${$_[1]->{"\$_QUOTED"}}; 0004: package Foo; 0005: no warnings 'closure'; 0006: sub new { 0007: ($_QUOTED,$_UNQUOTED) if 0; 0008: # BEGIN quote_sub PRELUDE 0009: package Foo; 0010: BEGIN { 0011: $^H = 2018; 0012: ${^WARNING_BITS} = "UUUUUUUUUUUUUUUUU\005"; 0013: %^H = ( 0014: ); 0015: } 0016: # END quote_sub PRELUDE 0017: my $invoker = CORE::shift(); 0018: my $class = CORE::ref($invoker) ? CORE::ref($invoker) : $invoker; 0019: if ($class ne "Foo") { 0020: if ($Moo::MAKERS{$class}) { 0021: if ($Moo::MAKERS{$class}{constructor}) { 0022: package Foo; 0023: return $invoker->SUPER::new(@_); 0024: } 0025: Moo->_constructor_maker_for($class); 0026: return $invoker->new(@_); 0027: } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) { 0028: return $meta->new_object( 0029: $class->can("BUILDARGS") ? $class->BUILDARGS(@_) 0030: : $class->Moo::Object::BUILDARGS(@_) 0031: ); 0032: } 0033: } 0034: my $args = scalar @_ == 1 0035: ? CORE::ref $_[0] eq 'HASH' 0036: ? { %{ $_[0] } } 0037: : Carp::croak("Single parameters to new() must be a HASH ref" 0038: . " data => ". $_[0]) 0039: : @_ % 2 0040: ? Carp::croak("The new() method for $class expects a hash reference or a" 0041: . " key/value list. You passed an odd number of arguments") 0042: : {@_} 0043: ; 0044: my $new = bless({}, $class);; 0045: ($new->{"_foo"} = 1),( and do { local @_ = ($new, $new->{"_foo"}); # BEGIN quote_sub PRELUDE 0046: package Method::Generate::Accessor; 0047: BEGIN { 0048: $^H = 2018; 0049: ${^WARNING_BITS} = "TUUEUUUUUUUUUUUUU\001"; 0050: %^H = ( 0051: ); 0052: } 0053: # END quote_sub PRELUDE 0054: shift->_trigger__foo(@_) }), return $new; 0055: } 0056: $$_UNQUOTED = \&new; 0057: } 0058: 1; syntax error at (eval 11) line 45, near "( and" BEGIN not safe after errors--compilation aborted at (eval 11) line 52. at [...]/Method/Generate/Constructor.pm line 161. Removing any of default, init_arg, or trigger causes the compilation to succeed.
Fixed in git.
On Thu Jan 26 12:59:19 2017, haarg wrote: Show quoted text
> Fixed in git.
Thanks!
Released in v2.003001.