Skip Menu |

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

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

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

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



Subject: Better messsages for type constraint failures
From: mail [...] tobyinkster.co.uk
The reasons for not back-tracking up the type constraint hierarchy when generating error messages are largely historic. The technique of throwing exceptions should allow us to give a clearer explanation for a failure. This may break test cases which are checking the exact strings of exceptions. However some of the damage could be mitigated using multi-line error messages and keeping the first line as-is.
OK, in 0.027_05: $ perl -Ilib -MTypes::Standard=ArrayRef,Int -E'(ArrayRef[Int])->([1,2,"Hi"])' Reference [1,2,"Hi"] did not pass type constraint "ArrayRef[Int]" Reference [1,2,"Hi"] did not pass type constraint "ArrayRef[Int]" "ArrayRef[Int]" constrains each value in the array with "Int" "Int" is a subtype of "Num" "Num" is a subtype of "LaxNum" Value "Hi" did not pass type constraint "LaxNum" (in $_->[2]) "LaxNum" is defined as: (!ref($_) && Scalar::Util::looks_like_number($_))
As of 0.027_08, this change is conditional on $]. Perl 5.8+ will get the new extended error messages. Perl 5.6.x gets the shorter messages. I have no idea why, but the long messages were breaking the test suite on Perl 5.6.
Fixed in 0.028.