Skip Menu |

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

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

Owner: perl [...]
Requestors: djerius [...]

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

Subject: Type::Params; slurpy Dict breaks HasMethods
Download (untitled) / with headers
text/plain 926b
The attached code illustrates the problem. It results in not ok 1 - slurpy Dict w/ HasMethods # Failed test 'slurpy Dict w/ HasMethods' # at line 18. # got: 'Can't use string ("send") as a HASH ref while "strict refs" in use at parameter validation for 'main::__ANON__' line 4. # ' # expected: undef 1..1 # Looks like you failed 1 test of 1. The generated code has this in it: Scalar::Util::blessed( $_->{"encoder"} ) and not grep( !$_->{"encoder"}->can( $_ ), qw/send/ ); The $_ in the grep code can't be both the grep variable and the outer $_. This is generated by this code in Type::Tiny::Duck::_build_inlined: qq{ Scalar::Util::blessed($var) and not grep(!$var->can(\$_), qw/@methods/) }; which assumes $var isn't $_. Here's a possible fix (works for me) qq{ Scalar::Util::blessed($var) and not do { my \$var = $var; grep(!\$var->can(\$_), qw/@methods/) } }; Thanks, Diab
text/x-perl 351b
use Type::Params -all; use Types::Standard -all; use Test::More; use Test::Fatal; { package Foo; sub new { bless {}, shift } sub send { } }; is( exception { validate( [ encoder => Foo->new ], slurpy Dict [ encoder => HasMethods ['send'] ] ); }, undef, "slurpy Dict w/ HasMethods" ); done_testing;
Ouch. Yes, that needs to be fixed.
Download (untitled) / with headers
text/plain 221b
Fixed in repo. I'll get a new developer release out this afternoon. I'm planning to release the next stable version on Wed 2 April.
Fixed in 0.042.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to