From: Jesse Luehrs Date: Sun, 17 Oct 2010 20:42:24 +0000 (-0500) Subject: return returns from functions, not do blocks X-Git-Tag: 1.16~23^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f420346f225cba177897d84440a8ba8a596ab7e;p=gitmo%2FMoose.git return returns from functions, not do blocks --- diff --git a/lib/Moose/Meta/Method/Constructor.pm b/lib/Moose/Meta/Method/Constructor.pm index fc043e7..a9aa244 100644 --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@ -153,21 +153,23 @@ sub _generate_BUILDARGS { # {} block. return sprintf( <<'EOF', $self->_inline_throw_error( q{'Single parameters to new() must be a HASH ref'}, 'data => $_[0]' ) ); do { + my $params; if ( scalar @_ == 1 ) { unless ( defined $_[0] && ref $_[0] eq 'HASH' ) { %s } - return { %%{ $_[0] } }; + $params = { %%{ $_[0] } }; } elsif ( @_ %% 2 ) { Carp::carp( "The new() method for $class expects a hash reference or a key/value list." . " You passed an odd number of arguments" ); - return { @_, undef }; + $params = { @_, undef }; } else { - return {@_}; + $params = {@_}; } + $params }; EOF ;