From: Matt S Trout Date: Mon, 21 May 2007 17:02:23 +0000 (+0000) Subject: fix for prototype undecl issue when type constraint utils loaded before consumers... X-Git-Tag: 0_22~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c4acc601eded1380a6496b9265a331afee580d6;p=gitmo%2FMoose.git fix for prototype undecl issue when type constraint utils loaded before consumers (e.g. Moose::Meta::Attribute) by predeclaring prototypes in TC utils --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 2ac9d5a..d984085 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -12,6 +12,26 @@ use Sub::Exporter; our $VERSION = '0.12'; our $AUTHORITY = 'cpan:STEVAN'; +# Prototyped subs must be predeclared because we have a circular dependency +# with Moose::Meta::Attribute et. al. so in case of us being use'd first the +# predeclaration ensures the prototypes are in scope when consumers are +# compiled + +sub find_type_constraint ($); +sub _create_type_constraint ($$$;$$); +sub _install_type_coercions ($$); +sub create_type_constraint_union (@); +sub type ($$;$$); +sub subtype ($$;$$$); +sub coerce ($@); +sub as ($); +sub from ($); +sub where (&); +sub via (&); +sub message (&); +sub optimize_as (&); +sub enum ($;@); + use Moose::Meta::TypeConstraint; use Moose::Meta::TypeCoercion; diff --git a/t/050_util_type_constraints.t b/t/050_util_type_constraints.t index 37a7fa9..2252957 100644 --- a/t/050_util_type_constraints.t +++ b/t/050_util_type_constraints.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 37; +use Test::More tests => 38; use Test::Exception; use Scalar::Util (); @@ -101,3 +101,6 @@ ok(!defined($string->validate("Five")), '... validated successfully (no error)') is($string->validate(5), "This is not a string (5)", '... validated unsuccessfully (got error)'); + +lives_ok { Moose::Meta::Attribute->new('bob', isa => 'Spong') } + 'meta-attr construction ok even when type constraint utils loaded first';