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

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

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 bug.pl 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
Subject: bug.pl
Download bug.pl
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. https://github.com/tobyink/p5-type-tiny/commit/610ef8d5f991c4ed1dccdc1cb551c2a7eb721079 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 Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.