+ - throw a useful exception when typemap doesn't return a value
- avoid localising @_ when not required for Sub::Quote
- successfully inflate a metaclass for attributeless classes (RT#86415)
- fix false default values used with non-lazy accessors
my ($name) = @_;
our %DID_INJECT;
return Class::MOP::get_metaclass_by_name($name) if $DID_INJECT{$name};
- require Moose; require Moo; require Moo::Role;
+ require Moose; require Moo; require Moo::Role; require Scalar::Util;
Class::MOP::remove_metaclass_by_name($name);
my ($am_role, $meta, $attr_specs, $attr_order) = do {
if (my $info = $Moo::Role::INFO{$name}) {
my $tc = $spec{isa} = do {
if (my $mapped = $TYPE_MAP{$isa}) {
my $type = $mapped->();
+ Scalar::Util::blessed($type) && $type->isa("Moose::Meta::TypeConstraint")
+ or die "error inflating attribute '$name' for package '$_[0]': \$TYPE_MAP{$isa} did not return a valid type constraint'";
$coerce ? $type->create_child_type(name => $type->name) : $type;
} else {
Moose::Meta::TypeConstraint->new(
'External (MooseX::Types type) ok'
);
+local $@;
+eval q {
+ package Fooble;
+ use Moo;
+ my $isa = sub { 1 };
+ $Moo::HandleMoose::TYPE_MAP{$isa} = sub { $isa };
+ has barble => (is => "ro", isa => $isa);
+ __PACKAGE__->meta->get_attribute("barble");
+};
+
+like(
+ $@,
+ qr{^error inflating attribute 'barble' for package 'Fooble': \$TYPE_MAP\{CODE\(\w+?\)\} did not return a valid type constraint},
+ 'error message for incorrect type constraint inflation',
+);
+
done_testing;