From: Stevan Little Date: Fri, 30 Nov 2007 05:13:16 +0000 (+0000) Subject: little better error message there X-Git-Tag: 0_32~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6f9ff1af2a8de6a0c55f6cc7aa436bd9c3ad08a6;p=gitmo%2FMoose.git little better error message there --- diff --git a/lib/Moose/Meta/TypeCoercion.pm b/lib/Moose/Meta/TypeCoercion.pm index 0954307..4620c51 100644 --- a/lib/Moose/Meta/TypeCoercion.pm +++ b/lib/Moose/Meta/TypeCoercion.pm @@ -56,7 +56,7 @@ sub compile_type_coercion { foreach my $coercion (@coercions) { my ($constraint, $converter) = @$coercion; if (defined $constraint->($thing)) { - local $_ = $thing; + local $_ = $thing; return $converter->($thing); } } diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index e7eaf18..76ea01d 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -149,23 +149,23 @@ sub _compile_subtype { # then we compile them to run without # having to recurse as we did before - return subname $self->name => sub { - local $_ = $_[0]; + return subname $self->name => sub { + local $_ = $_[0]; foreach my $parent (@parents) { return undef unless $parent->($_[0]); } - return undef unless $check->($_[0]); - 1; - }; + return undef unless $check->($_[0]); + 1; + }; } sub _compile_type { my ($self, $check) = @_; - return subname $self->name => sub { - local $_ = $_[0]; - return undef unless $check->($_[0]); - 1; - }; + return subname $self->name => sub { + local $_ = $_[0]; + return undef unless $check->($_[0]); + 1; + }; } ## other utils ... diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index ac82b6a..365c6e6 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -283,7 +283,7 @@ sub _create_type_constraint ($$$;$$) { # the union constraint, which means we need to # handle this differently. # - SL - if (not(defined($check)) + if (not(defined $check) && $parent->isa('Moose::Meta::TypeConstraint::Union') && $parent->has_coercion ){ @@ -301,6 +301,8 @@ sub _create_type_constraint ($$$;$$) { sub _install_type_coercions ($$) { my ($type_name, $coercion_map) = @_; my $type = $REGISTRY->get_type_constraint($type_name); + (defined $type) + || confess "Cannot find type '$type_name', perhaps you forgot to load it."; if ($type->has_coercion) { $type->coercion->add_type_coercions(@$coercion_map); }