![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
(Solved?) Moose type-constraint is unhappy with defaults ... why?by sundialsvc4 (Abbot) |
on Nov 23, 2011 at 19:41 UTC ( #939716=perlquestion: print w/replies, xml ) | Need Help?? |
sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question: I have this ... and in the object ...
And when I instantiate the object:
Changing it to isa => 'Int', for example, allows the constructor to continue. I have confirmed that is_MyOffset(0) is true. All of the edge-cases work. On closer look, it appears that any use of a isa=>'some_subtype' is refusing to accept the default value even when the where clause for some_subtype says that it should. (For example, taking a definition PositiveInt straight out of the Synopsis of MooseX::Types, the message will appear if the default is 1. Fudging the isa string to produce a bogus type-name fails immediately (as is correct), and removing the where clause from the existing subtype removes the problem. So it certainly would appear that the subtype, and its associated where clause, is being found and executed. Edit: On closer inspection of the documentation (what? what%squo;s that?) for MooseX::Types, I see that they recommend using barewords for the types, noting also that this will cause compile-time error goodness. (MooseX::Types::Moose provides the standard Moose types.) Making this change resolved the problem, although I remain somewhat fuzzled as to why it occurred.)
Back to
Seekers of Perl Wisdom
|
|