From: Jesse Luehrs Date: Wed, 3 Nov 2010 21:32:25 +0000 (-0500) Subject: error if we have a lazy attr with no default or builder X-Git-Tag: 1.9900~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0504b18b49a440305d83a1d1dd1d2bc0a1a1148d;p=gitmo%2FMoose.git error if we have a lazy attr with no default or builder --- diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index a3aaa90..59b5cd4 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -252,9 +252,15 @@ sub _inline_init_from_default { my ($instance, $default, $for_lazy) = @_; my $attr = $self->associated_attribute; - # XXX: should this throw an error instead? - return $self->_inline_init_slot($attr, $instance, 'undef') - unless $attr->has_default || $attr->has_builder; + + if (!($attr->has_default || $attr->has_builder)) { + $self->throw_error( + 'You cannot have a lazy attribute ' + . '(' . $attr->name . ') ' + . 'without specifying a default value for it', + attr => $attr, + ); + } return ( $self->_inline_generate_default($instance, $default),