Subject: | "coercion cannot be inlined" error w/ Type::Params::compile & Dict |
The attached code when run under 5.16.3 results in the following error:
$ perl type.pl
[
[0] [
[0] "b"
]
]
This coercion cannot be inlined at [...]/lib/perl5/Types/Standard.pm line 934.
I'm not quite sure how to fix this...
Subject: | type.pl |
use strict;
use warnings;
package Types {
use Type::Library
-base,
-declare => qw[ StrList ];
use Type::Utils;
use Types::Standard qw[ ArrayRef Str ];
declare StrList, as ArrayRef [Str];
coerce StrList, from Str, via { [$_] };
}
use Type::Params qw[ compile ];
use Types::Standard qw[ Dict slurpy Optional ];
sub foo {
my $check
= compile( Dict [ foo => Types::StrList ] );
my @opts = $check->( @_ );
use Data::Printer;
p @opts;
}
sub bar {
my $check = compile( Types::StrList );
my @opts = $check->( @_ );
use Data::Printer;
p @opts;
}
bar( 'b' );
foo( foo => 'a' );