Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 65220
Status: open
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

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

Attachments
ProhibitReusedNames.run.expressions.diff



Subject: ProhibitReusedNames vs "my" in expression
Date: Sat, 29 Jan 2011 08:29:49 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
Download (untitled) / with headers
text/plain 272b
When ProhibitReusedNames searches upwards for an existing lexical it doesn't seem to see a "my" which is within a list or an expression, per the failing cases below. The most typical is probably a "my" in an "if", like if (my $foo = some_thing()) { ... }
Index: ProhibitReusedNames.run =================================================================== --- ProhibitReusedNames.run (revision 4013) +++ ProhibitReusedNames.run (working copy) @@ -282,6 +282,40 @@ #----------------------------------------------------------------------------- +## name variable in list +## failures 1 +## TODO Descend into lists +## cut + +(my $foo, my $bar) = (1, 2); +{ + my $foo = 3; +} + +#----------------------------------------------------------------------------- + +## name variable in conditional +## failures 1 +## TODO Descend into expressions +## cut + +if (my $foo = 1) { + my $foo = 2; +} + +#----------------------------------------------------------------------------- + +## name variable in expression in conditional +## failures 1 +## TODO Descend into expressions +## cut + +if (defined (my $foo = 1)) { + my $foo = 2; +} + +#----------------------------------------------------------------------------- + ############################################################################## # $URL$ # $Date$
Download (untitled) / with headers
text/plain 484b
On Fri Jan 28 16:29:41 2011, user42@zip.com.au wrote: Show quoted text
> When ProhibitReusedNames searches upwards for an existing lexical it > doesn't seem to see a "my" which is within a list or an expression, per > the failing cases below. > > The most typical is probably a "my" in an "if", like > > if (my $foo = some_thing()) { > ... > } >
Thank you for the report, and particularly for the attached .run file mods. Looks like we will have to be smarter about a couple things.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.