From: Dave Rolsky Date: Sun, 5 Jun 2011 21:40:21 +0000 (-0500) Subject: When generating inlining code, distinguish between $default from calling $attr->defau... X-Git-Tag: 2.0100~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0ec497676d412efaba24f9a65d5b6fefc955b3a4;p=gitmo%2FMoose.git When generating inlining code, distinguish between $default from calling $attr->default and the default val it generates --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index b0160bc..3b138fa 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -859,7 +859,7 @@ sub _inline_generate_default { my ($instance, $default) = @_; if ($self->has_default) { - my $source = 'my ' . $default . ' = $default'; + my $source = 'my ' . $default . ' = $attr_default'; $source .= '->(' . $instance . ')' if $self->is_default_a_coderef; return $source . ';'; diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index 93148d0..e5da1f6 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -50,7 +50,7 @@ sub _eval_environment { $env->{'$trigger'} = \($attr->trigger) if $attr->has_trigger; - $env->{'$default'} = \($attr->default) + $env->{'$attr_default'} = \($attr->default) if $attr->has_default; if ($attr->has_type_constraint) {