Subject: | positional parameters with coercions fail |
Positional parameters with coercions fail unless they are specified as
required with the bang (!) character.
MooseX::Types::TypeDecorator::AUTOLOAD():
MooseX::Types::TypeDecorator::AUTOLOAD(): Cannot coerce without a type
coercion at Moose/Meta/TypeConstraint.pm line 83
Moose::Meta::TypeConstraint::coerce('Moose::Meta::TypeConstraint::Parameterized=HASH(0x17da680)',
.) called at MooseX/Types/TypeDecorator.pm line 173
eval {...} called at MooseX/Types/TypeDecorator.pm line 172
MooseX::Types::TypeDecorator::AUTOLOAD('MooseX::Types::TypeDecorator=HASH(0x17da998)',
.) called at MooseX/Method/Signatures/Meta/Method.pm line 311
MooseX::Method::Signatures::Meta::Method::__ANON__('HASH(0x14c9e88)', .)
called at MooseX/Method/Signatures/Meta/Method.pm line 338
MooseX::Method::Signatures::Meta::Method::__ANON__('ARRAY(0x17d7628)')
called at /Moose/Meta/TypeCoercion.pm line 63
Moose::Meta::TypeCoercion::__ANON__('ARRAY(0x17d7628)') called
at Moose/Meta/TypeCoercion.pm line 97
Moose::Meta::TypeCoercion::coerce('MooseX::Meta::TypeCoercion::Structured=HASH(0x17f3788)',
'ARRAY(0x17d7628)') called at Moose/Meta/TypeConstraint.pm line 88
Moose::Meta::TypeConstraint::coerce('MooseX::Meta::TypeConstraint::Structured=HASH(0x17f35c0)',
'ARRAY(0x17d7628)') called at MooseX/Types/TypeDecorator.pm line 173
eval {...} called at MooseX/Types/TypeDecorator.pm line 172
MooseX::Types::TypeDecorator::AUTOLOAD('MooseX::Types::TypeDecorator=HASH(0x17ecef0)',
'ARRAY(0x17d7628)') called at
MooseX/Meta/TypeConstraint/ForceCoercion.pm line 29
MooseX::Meta::TypeConstraint::ForceCoercion::validate('MooseX::Meta::TypeConstraint::ForceCoercion=HASH(0x17f3e30)',
'ARRAY(0x17d7628)', 'SCALAR(0x13fadf8)') called at
MooseX/Method/Signatures/Meta/Method.pm line 365
MooseX::Method::Signatures::Meta::Method::validate('MooseX::Method::Signatures::Meta::Method=HASH(0x17d77d8)',
'ARRAY(0x17d7628)') called at MooseX/Method/Signatures/Meta/Method.pm
line 139
A::ls_boom('A=HASH(0x17ff288)', 'directory', .) called at
./test.pl line 23
Subject: | test.pl |
package A;
{
use Moose;
use MooseX::Method::Signatures;
use MooseX::Types::Path::Class qw/Dir/;
method ls_works (Dir $directory does coerce) {
print `ls $directory`;
}
method ls_boom (Dir :$directory does coerce) {
print `ls $directory`;
}
method ls_also_works (Dir :$directory! does coerce) {
print `ls $directory`;
}
};
my $a = A->new();
$a->ls_works(".");
$a->ls_also_works(directory => ".");
$a->ls_boom(directory => ".");