if ($TYPE{$name} && $TYPE_SOURCE{$name} ne $pkg) {
Carp::croak "The type constraint '$name' has already been created in $TYPE_SOURCE{$name} and cannot be created again in $pkg";
};
- my $constraint = $conf{where};
- my $as_constraint = find_or_create_isa_type_constraint($conf{as} || 'Any');
+ my $constraint = delete $conf{where};
+ my $as_constraint = find_or_create_isa_type_constraint(delete $conf{as} || 'Any');
$TYPE_SOURCE{$name} = $pkg;
$TYPE{$name} = Mouse::Meta::TypeConstraint->new(
$as_constraint->check($_[0]);
}
),
+ %conf
);
return $name;
sub find_or_create_isa_type_constraint {
my $type_constraint = shift;
+ Carp::confess("Got isa => type_constraints, but Mouse does not yet support parameterized types for containers other than ArrayRef and HashRef and Maybe (rt.cpan.org #39795)")
+ if $type_constraint =~ /\A ( [^\[]+ ) \[\.+\] \z/xms &&
+ $1 ne 'ArrayRef' &&
+ $1 ne 'HashRef' &&
+ $1 ne 'Maybe'
+ ;
+
my $code;
$type_constraint =~ s/\s+//g;