Subject: | "$type" is not necessarily unique |
For non-inlineable type constraints, you use:
$Class::Slot::TYPE{$type}->check($value)
However, there's no guarantee that "$type" will stringify to something unique.
With Type::Tiny it's certainly possible to create, say, two different Type constraints which stringify to the same thing. For example:
use Types::Standard qw( Int Str );
use Scalar::Util qw( refaddr );
my $type1 = Int->where("1");
my $type2 = Str->where("1");
# prove that they are different type constraints
say $_->check("xyz") ? "pass" : "fail" for $type1, $type2;
# but they stringify to the same thing.
say for $type1, $type2;
For other type implementations, it probably is too.
Using refaddr($type) as your hash key might be slightly better. Not sure.