On Sat, Sep 29, 2012 at 07:47:01PM +0000, sh...@comcast.net wrote: > > I cannot make this work: > > > use MooseX::Declare; > > > class Foo { > use Moose::Util::TypeConstraints; > subtype 'NewType' => as 'Object'; > > > method bar (NewType $arg) { > > > } > } > > > I get the following error: > > > 'NewType' could not be parsed to a type constraint - maybe you need to > pre-declare the type with class_type at reader > Parse::Method::Signatures::TypeConstraint::tc (defined at /home/yshtil/ > lib/perl5/site_perl/5.14.1/Parse/Method/Signatures/TypeConstraint.pm line 20) > line 7
MooseX::Declare requires that type names are available during compilation, but 'subtype' happens at runtime, which is too late. You can move your type declaration to a separate type library and 'use' it in your module, or you can wrap the subtype declaration in a BEGIN block. -doy