Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 90865
Status: resolved
Priority: 0/
Queue: Type-Tiny

People
Owner: perl [...] toby.ink
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.032
Fixed in: (no value)



Subject: Type::Params::multisig fails to validate when presented with a slurpy Dict
The documentation for multisig indicates that it supports slurpy params, but it doesn't seem to work for me. The attached script fails where multisig is presented with a slurpy Dict: % perl multisig.pl Parameter validation failed at multisig.pl line 36. Parameter validation failed at multisig.pl line 50.
Subject: multisig.pl
use strict; use warnings; use Data::Dumper; use Type::Params qw[ multisig validate ]; use Types::Standard -all; my $a = Dict [ a => Num ]; my $b = Dict [ b => Num ]; # works eval { validate( [ { a => 3 } ], $a ); validate( [ a => 3 ], slurpy $a ); } || warn $@; # works eval { my $check = multisig( [ $a ], [ $b ] ); $check->( { a => 3 } ); $check->( { b => 3 } ); 1; } || warn $@; eval { my $check = multisig( [ slurpy $a ], [ slurpy $b ] ); # Parameter validation failed... $check->( { a => 3 } ); $check->( { b => 3 } ); 1; } || warn $@; eval { my $check = multisig( [ $a ], [ slurpy $b ] ); # works $check->( { a => 3 } ); # Parameter validation failed... $check->( { b => 3 } ); 1; } || warn $@;
On Wed Nov 27 19:53:07 2013, DJERIUS wrote: Show quoted text
> The documentation for multisig indicates that it supports slurpy > params, but it doesn't seem to work for me. > > The attached script fails where multisig is presented with a slurpy > Dict: > > % perl multisig.pl > Parameter validation failed at multisig.pl line 36. > Parameter validation failed at multisig.pl line 50.
Whoops. There's a bug in the test script. Fixed one attaced.
Subject: multisig.pl
use strict; use warnings; use Data::Dumper; use Type::Params qw[ multisig validate ]; use Types::Standard -all; my $a = Dict [ a => Num ]; my $b = Dict [ b => Num ]; # works eval { validate( [ { a => 3 } ], $a ); validate( [ a => 3 ], slurpy $a ); } || warn $@; # works eval { my $check = multisig( [ $a ], [ $b ] ); $check->( { a => 3 } ); $check->( { b => 3 } ); 1; } || warn $@; eval { my $check = multisig( [ slurpy $a ], [ slurpy $b ] ); # Parameter validation failed... $check->( a => 3 ); $check->( b => 3 ); 1; } || warn $@;
Type::Params line 213 is: max_args => $saw_slurpy ? $max_args : undef, But it should be: max_args => $saw_slurpy ? undef : $max_args, Argh! A workaround is to pre-compile the two candidates, a la: my $check = multisig( compile(slurpy $a), compile(slurpy $b), ); Anyway, it's fixed in the repo.
Fixed in 0.034.