Subject: | Confusing error message if required slurpy Dict not present in parameter list |
If a non-optional slurpy Dict is requested but not provided, the error message is confusing. To wit:
use Types::Standard -all;
use Type::Params qw[ validate ];
validate( [ 'a' ], Str, slurpy Dict [ var => Int ]);
results in:
Value "HASH(0x10a8f310)" in $_[1] does not meet type constraint "Dict[var=>Int]" at /opt/perl5/perls/perl-5.16.2/lib/5.16.3/Carp.pm line 97.
Carp::shortmess('Value "HASH(0x10a8f310)" in $_[1] does not meet type constrai...') called at /opt/perl5/perls/perl-5.16.2/lib/5.16.3/Carp.pm line 100
Carp::croak('Value "HASH(0x10a8f310)" in $_[1] does not meet type constrai...') called at /home/dj/.perlbrew/libs/perl-5.16.2@dev/lib/perl5/Type/Params.pm line 92
Type::Params::__ANON__('Value "HASH(0x10a8f310)" in $_[1] does not meet type constrai...') called at parameter validation for 'Type::Params::validate' line 7
Eval::TypeTiny::Sandbox69::__ANON__('a') called at try.pl line 4
instead of a "Wrong number of parameters" error. A missing non-slurpy Dict results in a message along the lines of:
Wrong number of parameters (1); expected 2 at /opt/perl5/perls/perl-5.16.2/lib/5.16.3/Carp.pm line 97.
which is more along the lines of what I expected.
Thanks,
Diab