Re: What is the problem here?

[email protected] (Jesse Luehrs)
Newsgroups perl.moose
Message-ID <[email protected]>
On Sat, Sep 29, 2012 at 07:47:01PM +0000, [email protected] 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.