From: Shawn M Moore Date: Mon, 23 Feb 2009 02:46:41 +0000 (+0000) Subject: Throw a more useful error when users try to use a parameterized type, X-Git-Tag: 0.19~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=5fa003bf0b3308fd48519ff1173feb778c550c01 Throw a more useful error when users try to use a parameterized type, with a meager todo test --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 9683342..4387bcd 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -204,6 +204,9 @@ sub create { if exists $args{coerce}; if (exists $args{isa}) { + confess "Mouse does not yet support parameterized types (rt.cpan.org #39795)" + if $args{isa} =~ /\[.*\]/; + my $type_constraint = delete $args{isa}; $type_constraint =~ s/\s//g; my @type_constraints = split /\|/, $type_constraint; diff --git a/t/043-parameterized-type.t b/t/043-parameterized-type.t new file mode 100644 index 0000000..8bc1d98 --- /dev/null +++ b/t/043-parameterized-type.t @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 1; +use Test::Exception; + +TODO: { + local $TODO = "Mouse does not support parameterized types yet"; + + eval { + package Foo; + use Mouse; + + has foo => ( + is => 'ro', + isa => 'HashRef[Int]', + ); + }; + + ok(Foo->meta->has_attribute('foo')); +}; +