Skip Menu |

This queue is for tickets about the Method-Signatures CPAN distribution.

Report information
The Basics
Id: 81361
Status: rejected
Priority: 0/
Queue: Method-Signatures

People
Owner: Nobody in particular
Requestors: MAUKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 20120523
Fixed in: (no value)



Subject: M:S can corrupt line numbers for unrelated parts of the file, take 1
$ cat lineno1 #!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.
Subject: Re: [rt.cpan.org #81361] M:S can corrupt line numbers for unrelated parts of the file, take 1
Date: Fri, 23 Nov 2012 17:44:13 -0800
To: bug-Method-Signatures [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
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.
I'm just consolidating these three duplicate tickets into one. This ticket is referenced in #87544.