From: Stevan Little Date: Tue, 14 Nov 2006 18:35:26 +0000 (+0000) Subject: foo X-Git-Tag: 0_18~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cecd110f54f5f07e2f06748ee611db4c2852c0a4;p=gitmo%2FMoose.git foo --- diff --git a/Changes b/Changes index adf2267..30e2bc1 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension Moose +0.17 Tues. Nov. 14, 2006 + * Moose::Meta::Method::Accessor + - bugfix for read-only accessors which + are have a type constraint and lazy. + Thanks to chansen for finding it. + 0.16 Tues. Nov. 14, 2006 ++ NOTE ++ There are some speed improvements in this release, diff --git a/MANIFEST b/MANIFEST index a0ba448..94c8ef7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -87,6 +87,7 @@ t/100_subtype_quote_bug.t t/101_subtype_conflict_bug.t t/102_Moose_Object_error.t t/103_subclass_use_base_bug.t +t/104_inline_reader_bug.t t/201_example.t t/202_example_Moose_POOP.t t/203_example.t diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index 307c4bc..413b5b9 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -6,7 +6,7 @@ use warnings; use Carp 'confess'; -our $VERSION = '0.02'; +our $VERSION = '0.03'; use base 'Moose::Meta::Method', 'Class::MOP::Method::Accessor'; @@ -81,6 +81,13 @@ sub generate_reader_method_inline { . $self->_inline_check_lazy . 'return ' . $self->_inline_auto_deref( '$_[0]->{$attr_name}' ) . ';' . '}'; + + # NOTE: + # set up the environment + my $type_constraint = $attr->type_constraint + ? $attr->type_constraint->_compiled_type_constraint + : undef; + my $sub = eval $code; confess "Could not create reader for '$attr_name' because $@ \n code: $code" if $@; return $sub; diff --git a/t/104_inline_reader_bug.t b/t/104_inline_reader_bug.t new file mode 100644 index 0000000..7321764 --- /dev/null +++ b/t/104_inline_reader_bug.t @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 2; +use Test::Exception; + +BEGIN { + use_ok('Moose'); +} + +=pod + +This was a bug, but it is fixed now. This +test makes sure it does not creep back in. + +=cut + +{ + package Foo; + use Moose; + + ::lives_ok { + has 'bar' => ( + is => 'ro', + isa => 'Int', + lazy => 1, + default => 10, + ); + } '... this didnt die'; +} +