Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 132419
Status: resolved
Priority: 0/
Queue: Type-Tiny

People
Owner: Nobody in particular
Requestors: haukex [...] zero-g.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.010001
Fixed in: 1.010004



Subject: Documentation issue and/or bug with compile_named+head+named_to_list?
Hi, I'm confused about the documentation of compile_named: the last three examples in its docs (right before the docs of validate_named) show the use of `compile` instead of `compile_named`, and I assume as a result, those code examples don't appear to work. If I take the last example demonstrating the use of `head` and `named_to_list`, and I change the `compile` to `compile_named`, I get a bunch of errors, attached. Is this a bug in the code, or perhaps the documentation? Thanks, -- Hauke D
Subject: t.pl
#!/usr/bin/env perl use warnings; use strict; use Type::Params qw/ compile_named /; use Types::Standard qw/ Int Str CodeRef /; my $check = compile_named( { head => [ Int, Int ], tail => [ CodeRef ], named_to_list => 1 }, foo => Str, bar => Str, baz => Str, ); my ($int1, $int2, $foo, $bar, $baz, $coderef) = $check->( 666, 999, foo=>'x', bar=>'y', baz=>'z', sub {} ); print $bar; __END__ Failed to compile source because: syntax error at parameter validation for '__ANON__' line 25, near "} unshift" Global symbol "@R" requires explicit package name (did you forget to declare "my @R"?) at parameter validation for '__ANON__' line 25. Global symbol "@R" requires explicit package name (did you forget to declare "my @R"?) at parameter validation for '__ANON__' line 26. at t.pl line 7.
Update Type/Params.pm at line 631: $code[-1] = 'my @R = ' . $code[-1] . ';'; The trailing ';' is missing in the current code. I have attached a copy of Params.pm
Subject: Params.pm

Message body is not shown because it is too large.

Thank you for taking the time to figure out what was going on here. It's patched in the repo now and I hope to release a new version this week.