You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a type inherits from a series of parents, the failure message it throws should come from the failing parent if that parent's constraint fails.
This will require some changes to how inlining works. Maybe the inlined constraint needs to return false on success and return a failure message on failure?
The text was updated successfully, but these errors were encountered:
FYI, I initially had it working this way in Type::Tiny, but it made inlining stupidly complex so I switched to just throwing from the child type constraint.
But with the build up to 0.006 I'm working on an $exception->explain method which re-examines why the value failed the type constraint, step-by-step.
For example, checking [1,2,[3]] against ArrayRef[Int] gives an explanation like this:
[
'[1,2,[3]] did not pass type constraint "ArrayRef[Int]"',
'"Int" is a subtype of "Num"',
'"Num" is a subtype of "Str"',
'"Str" is a subtype of "Value"',
'[3] did not pass type constraint "Value" (in $_->[2])',
'"Value" is defined as: (defined($_) and not ref($_))',
],
This means that the extensive examination is avoided on "hot" code paths (i.e. where the value passes the type constraint), but can be explicitly called in, say, a catch block.
Anyway, that's just an idea of a different way this can be done.
Migrated from rt.cpan.org #84351 (status was 'open')
Requestors:
From [email protected] (@autarch) on 2013-04-01 19:26:39:
When a type inherits from a series of parents, the failure message it throws should come from the failing parent if that parent's constraint fails.
This will require some changes to how inlining works. Maybe the inlined constraint needs to return false on success and return a failure message on failure?
The text was updated successfully, but these errors were encountered: