Skip Menu |

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

Report information
The Basics
Id: 100014
Status: rejected
Priority: 0/
Queue: Type-Tiny

People
Owner: Nobody in particular
Requestors: lloyd.fourn [...] gmail.com
Cc:
AdminCc:

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



Subject: check and coerce arguments not being passed to parameterized types
Date: Tue, 4 Nov 2014 20:21:54 +1100
To: bug-Type-Tiny [...] rt.cpan.org
From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
my $context = {day => 'Tuesday'}; MyType->check($x,$context); #MyType's constraint gets passed the second argument (ArrayRef[MyType])->check([$x],$context) # MyType's constraint doesn't get passed the second argument I realise I am not using types in the conventional way here but it was working really well until I used an ArrayRef. Being able to pass arguments to checks and coercions is really useful to me though I don't know whether it's an intended feature! thanks
On 2014-11-04T09:22:03Z, M0ast wrote: Show quoted text
> I realise I am not using types in the conventional way here but it was > working really well until I used an ArrayRef. Being able to pass arguments > to checks and coercions is really useful to me though I don't know whether > it's an intended feature!
It's not an intended feature. The simplest workaround is probably to stash it in a global variable. $::CONTEXT = $context; MyType->check($value); A better solution though might be to make MyType into a parameterized type itself, so you can do: ( MyType[$context] )->check($value);