On 2012.11.23 12:34 AM, Lukas Mai via RT wrote:
Show quoted text> #!perl
> use Method::Signatures;
>
> func foo(
> $x, # first
> $y # second
> ) {
> } # this is line 8
>
> my $aref = [];
> my $oops = %{ $aref };
>
> print "got $oops\n";
> __END__
> $ perl lineno1
> Not a HASH reference at lineno1 line 8.
>
> This line number is bogus. Line 8 is "}"; the actual error is on line
> 11. Corrupted line numbers make debugging runtime errors unnecessarily
> interesting.
I believe what's happening here is Method::Signatures is compiling the
signature into a single line on the presumption that your original signature
was a single line. That's throwing off the rest of the code.
A way to solve this is to:
1) Record the line number of each parameter in the signature.
2) Add newlines into the compiled signature.
#1 can be recorded in Method::Signatures::Parser->split_proto from
$token->line_number. This would be a good opportunity to turn each prototype
argument into an object rather than just a string. It would be passed along
to the parameter signature created from the prototype argument in
Method::Signatures->parse_func. This would also be a good time to turn the
parameter signature into an object.
#2 is handled in Method::Signatures->inject_from_signature.