CC: | Steve Grazzini <grazzini [...] grantstreet.com> |
Subject: | Bug in coercions for parameterized types |
Date: | Wed, 14 Sep 2016 11:46:55 -0700 |
To: | bug-Type-Tiny [...] rt.cpan.org |
From: | Lyle Kopnicky <lyle.kopnicky [...] grantstreet.com> |
Hi, I've run into some unexpected behavior involving coercions from
parameterized types. The attached script demonstrates the problem.
What I'm expecting: ArrayRef[Bullwinkle] should be able to use the coercion
that was added to Bullwinkle. This works with line 22 commented out. But
surprisingly, just calling ArrayRef[Bullwinkle] (by uncommenting line 22)
seems to freeze the coercions as they were before the coercion was added,
even though each time ArrayRef[Bullwinkle] is called, it creates a new
object.
In our code base we have interface definitions for an API, that make use of
type constraints. The interface definitions are used by both the client and
server side. Some of the coercions, however, can only be included in the
server-side code, because they involve accessing server-side data. So we
add coercions as needed on the server side.
This was working fine with the MooseX::Types::Moose library, but we wanted
to switch to Type::Tiny because it has much better error messages. And
because you get the auto-generated coercions for parameterized types.
So, is this something that you consider a bug? Can it be fixed? Or should
we be taking a different approach? Thanks for your help.
--
*Lyle Kopnicky, **Perl Software Developer*
*Grant Street Group*Ph: (412) 391-5555, Ext. 6817
Message body is not shown because sender requested not to inline it.