From: Dagfinn Ilmari Mannsåker Date: Thu, 9 Aug 2012 01:35:35 +0000 (+0100) Subject: fix pre-5.8.3 weak_ref setter as well X-Git-Tag: v1.000003~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42ae0e0cd96994af3a63fd8451c68d19e64b1624;p=gitmo%2FMoo.git fix pre-5.8.3 weak_ref setter as well --- diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm index b5ee174..be2ac5f 100644 --- a/lib/Method/Generate/Accessor.pm +++ b/lib/Method/Generate/Accessor.pm @@ -452,17 +452,19 @@ sub _generate_simple_set { Moo::_Utils::lt_5_8_3() ? <<"EOC" : $weak_simple; my \$preserve; - eval { Scalar::Util::weaken($simple); 1 } or do { - if( \$@ =~ /Modification of a read-only value attempted/) { - require Carp; - Carp::croak( sprintf ( - 'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3', - $name_str, - ) ); - } else { - die \$@; + eval { Scalar::Util::weaken($simple); 1 } + ? do { no warnings 'void'; \$preserve; } + : do { + if( \$@ =~ /Modification of a read-only value attempted/) { + require Carp; + Carp::croak( sprintf ( + 'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3', + $name_str, + ) ); + } else { + die \$@; + } } - }; EOC } else { $self->_generate_core_set($me, $name, $spec, $value);