Skip Menu |

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

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

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

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



Subject: ')' in comment can terminate parameter list?
$ cat wtf #!perl use Method::Signatures; func wtf( $x, # ok) $y ) {} __END__ $ perl wtf Use of uninitialized value $sigil in pattern match (m//) at /home/mauke/usr/lib/perl5/site_perl/5.16.2/Method/Signatures.pm line 658. Use of uninitialized value $name in substitution (s///) at /home/mauke/usr/lib/perl5/site_perl/5.16.2/Method/Signatures.pm line 659. Use of uninitialized value $name in substitution (s///) at /home/mauke/usr/lib/perl5/site_perl/5.16.2/Method/Signatures.pm line 660. Use of uninitialized value $sigil in concatenation (.) or string at /home/mauke/usr/lib/perl5/site_perl/5.16.2/Method/Signatures.pm line 663. Use of uninitialized value $name in concatenation (.) or string at /home/mauke/usr/lib/perl5/site_perl/5.16.2/Method/Signatures.pm line 663. Use of uninitialized value in pattern match (m//) at /home/mauke/usr/lib/perl5/site_perl/5.16.2/Method/Signatures.pm line 845. Type of arg 1 to main::func must be block or sub {} (not scalar dereference) at wtf line 7, near "$y ) " Can't use an undefined value as a subroutine reference at /home/mauke/usr/lib/perl5/site_perl/5.16.1/i686-linux/Devel/Declare/MethodInstaller/Simple.pm line 42.
Subject: Re: [rt.cpan.org #81365] ')' in comment can terminate parameter list?
Date: Fri, 23 Nov 2012 17:08:28 -0800
To: bug-Method-Signatures [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2012.11.23 12:55 AM, Lukas Mai via RT wrote: Show quoted text
> $ cat wtf > #!perl > use Method::Signatures; > > func wtf( > $x, # ok) > $y > ) {}
This is a problem upstream in Devel::Declare::toke_scan_str. It's being fooled by the comment and only returning '$x, # ok' as the prototype. toke_scan_str() is using scan_str() which looks for balanced delimiters and has no understanding of comments. Devel::Declare would have to use whatever the full parser is that Perl uses for parsing lists. We could override strip_proto to use PPI, but there's a Catch 22 there. PPI is a DOM parser, it has to parse the whole document. But we want it to stop as soon as its hit a balanced delimiter. I don't think PPI can be made to do that. I don't see a solution to this on the horizon. Might be worth documenting it as a limitation.
I've documented the limitation here: https://github.com/schwern/method-signatures/commit/fff40a4452cc71fc5e60fdcd1de784e5ab57c438 It will go live when I promote the current dev version to full. Since this is an upstream limitation, rejecting.