Subject: | Tuple+Enum constraints on strings with spaces fail when Type::Tiny::XS is installed |
Here's a simple program showing the error:
use strict;
use warnings;
use Type::Utils -all;
use Types::Standard -types;
my $type = declare as Tuple[Enum["foo bar", "foo baz"], Str];
$type->assert_valid(["foo bar", "whatever"]);
$type->assert_valid(["foo baz", "whatever"]);
$type->assert_valid(["foo bay", "whatever"]);
When Type::Tiny::XS is installed (unexpected):
Expected R_BRACKET; got TYPE at /Users/aeruder/.perl5/perls/perl-5.32.0/lib/site_perl/5.32.0/Type/Parser.pm line 393
When not installed (expected):
Reference ["foo bay","whatever"] did not pass type constraint at /Users/aeruder/Projects/scratch/2020-08/test.pl line 10
"__ANON__" is a subtype of "Tuple[Enum["foo bar","foo baz"],Str]"
Reference ["foo bay","whatever"] did not pass type constraint "Tuple[Enum["foo bar","foo baz"],Str]"
"Tuple[Enum["foo bar","foo baz"],Str]" constrains value at index 0 of array with "Enum["foo bar","foo baz"]"
"Enum["foo bar","foo baz"]" requires that the value is equal to "foo bar" or "foo baz"
After doing a backtrace it appears that at some point with Type::Tiny::XS it is calling:
Type::Parser::parse("Tuple[Enum[foo bar,foo baz],Str]")
which is what generates the error.