From: Dave Rolsky Date: Thu, 21 Apr 2011 20:18:07 +0000 (-0500) Subject: Don't use $_ when checking member constraints, since that can conflict with $_ used... X-Git-Tag: 2.0100~50 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e8cddd7b18ca15aaa2773af593977618532dc8d;p=gitmo%2FMoose.git Don't use $_ when checking member constraints, since that can conflict with $_ used in inlined TC --- diff --git a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm index c4ce898..d06ae03 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm @@ -99,17 +99,17 @@ sub _inline_check_member_constraint { my $check = $self->_tc_member_type->can_be_inlined - ? '! (' . $self->_tc_member_type->_inline_check('$_') . ')' - : ' !$member_tc->($_) '; + ? '! (' . $self->_tc_member_type->_inline_check('$new_val') . ')' + : ' !$member_tc->($new_val) '; return ( - 'for (' . $new_value . ') {', + 'for my $new_val (' . $new_value . ') {', "if ($check) {", $self->_inline_throw_error( '"A new member value for ' . $attr_name . ' does not pass its type constraint because: "' - . ' . $member_tc_obj->get_message($_)', - 'data => $_', + . ' . $member_tc_obj->get_message($new_val)', + 'data => $new_val', ) . ';', '}', '}', @@ -144,6 +144,10 @@ around _eval_environment => sub { $env->{'$member_tc'} = \( $member_tc->_compiled_type_constraint ); + my $tc_env = $member_tc->inline_environment(); + + $env = { %{$env}, %{$tc_env} }; + return $env; };