Catch calls to subtype that just provide a name (and no parent) and barf on them.
[gitmo/Moose.git] / lib / Moose / Util / TypeConstraints.pm
index 5f20933..9dd4ff1 100644 (file)
@@ -9,7 +9,7 @@ use List::MoreUtils qw( all any );
 use Scalar::Util qw( blessed reftype );
 use Moose::Exporter;
 
-our $VERSION   = '0.71';
+our $VERSION   = '0.72';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -288,6 +288,10 @@ sub subtype {
         return _create_type_constraint(@_);
     }
 
+    if ( @_ == 1 && ! ref $_[0] ) {
+        __PACKAGE__->_throw_error('A subtype cannot consist solely of a name, it must have a parent');
+    }
+
     # The blessed check is mostly to accommodate MooseX::Types, which
     # uses an object which overloads stringification as a type name.
     my $name = ref $_[0] && ! blessed $_[0] ? undef : shift;