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:
Low/Low
Queue:

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

BugTracker
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>
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$
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 runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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