tobyink / p5-type-tiny

Perl 5 distribution Type-Tiny; see homepage for downloads and documentation.
https://typetiny.toby.ink/
54 stars 48 forks source link

"Use of uninitialized value in pattern match" warning when calling Type::Params wrapped func from minimum call stack #158

Closed djerius closed 1 month ago

djerius commented 4 months ago

Error::TypeTiny doesn't like it when there's a minimal call stack:


% cat bug.pl
use v5.10;

use Type::Params -all;
use Types::Standard -all;

signature_for get_products => (
    named => [
        bar => Optional[Str],
    ],
);

sub get_products {}

get_products( rs => 3 );
% perl bug.pl
Use of uninitialized value in pattern match (m//) at /home/dj/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/Error/TypeTiny.pm line 61.
Unrecognized parameter: rs at file? line NaN.

Wrapping the call to get_product in a subroutine makes the warning go away.

djerius commented 1 month ago

Thanks!