From: Jesse Luehrs Date: Thu, 21 Apr 2011 01:41:12 +0000 (-0500) Subject: use Eval::Closure rather than doing string eval directly X-Git-Tag: 2.0100~62 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=477a812e8edd6ee5ebee1a3b7b90cfeac3b2b9f7;p=gitmo%2FMoose.git use Eval::Closure rather than doing string eval directly --- diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 1ce53c0..caf0ef8 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -10,6 +10,7 @@ use overload '0+' => sub { refaddr(shift) }, # id an object bool => sub { 1 }, fallback => 1; +use Eval::Closure; use Scalar::Util qw(blessed refaddr); use Sub::Name qw(subname); use Try::Tiny; @@ -250,11 +251,9 @@ sub _actually_compile_type_constraint { if $self->has_hand_optimized_type_constraint; if ( $self->has_inlined_type_constraint ) { - local $@; - my $sub = eval 'sub { ' . $self->_inline_check('$_[0]') . '}'; - die $@ if $@; - - return $sub; + return eval_closure( + source => 'sub { ' . $self->_inline_check('$_[0]') . ' }', + ); } my $check = $self->constraint;