Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 87868
Status: rejected
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: bluefeet [...] gmail.com
Cc:
AdminCc:

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



Subject: init_arg gets confused
Date: Wed, 14 Aug 2013 20:01:55 -0700
To: bug-Moo [...] rt.cpan.org
From: Aran Deltac <bluefeet [...] gmail.com>
In Moose this works as I would expect: has original_foo => ( is => 'ro', init_arg => 'foo', ); has foo => ( is => 'ro', init_arg => undef, lazy_build => 1, ); sub _build_foo { my ($self) = @_; print "BUILDING FOO\n"; return $self->original_foo() || 'NO FOO'; } print Package->new( foo => 'bar' )->foo(); Both Moo and Moose will print "bar". But, only Moose will call _build_foo and print "BUILDING FOO". Something in Moo is getting confused and is directly assigning the foo argument to the foo attribute, even tho the foo attribute has an undef init_arg.
I can't reproduce this. Moo doesn't have lazy_build, so _build_foo is never called, and ->foo returns undef. Changing it to use is => 'lazy' (which is similar to lazy_build) causes it to work as expected, showing BUILDING FOO and returning 'bar'.
Closing this. Re-open if you can provide other evidence of a problem here.