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: 38606
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: john.deighan [...] gmail.com
Cc:
AdminCc:

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



Subject: RequireFinalReturn fails to recognize valid return
We're getting the message Subroutine does not end with "return" on subroutines that clearly do end in "return;". After some examination, here is the case that causes the flawed message: sub f { foreach my $name qw(John Bill Bob) { print("$name\n"); } return; } The problem is with the construct "qw(John Bill Bob)". The problem goes away if you put parens around that. I always thought it a bit odd that Perl accepts this since I had assumed that surrounding parens would be required, but Perl doesn't complain and handles it as you would expect. But it does cause a problem with Perl::Critic.
Subject: Re: [rt.cpan.org #38606] RequireFinalReturn fails to recognize valid return
Date: Wed, 20 Aug 2008 08:53:51 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
John Deighan via RT wrote: Show quoted text
> We're getting the message Subroutine does not end with "return" on > subroutines that clearly do end in "return;". After some examination, > here is the case that causes the flawed message: > > sub f { > foreach my $name qw(John Bill Bob) { > print("$name\n"); > } > return; > } > > The problem is with the construct "qw(John Bill Bob)". The problem goes > away if you put parens around that. I always thought it a bit odd that > Perl accepts this since I had assumed that surrounding parens would be > required, but Perl doesn't complain and handles it as you would expect. > But it does cause a problem with Perl::Critic.
This is a known problem with PPI, the parser that Perl::Critic depends upon. We can't do anything about this.
Subject: Re: [rt.cpan.org #38606] RequireFinalReturn fails to recognize valid return
Date: Wed, 20 Aug 2008 07:08:32 -0700
To: bug-Perl-Critic [...] rt.cpan.org
From: Jeffrey Thalhammer <jeff [...] imaginative-software.com>
On Aug 20, 2008, at 6:16 AM, John Deighan via RT wrote: Show quoted text
> Wed Aug 20 09:16:15 2008: Request 38606 was acted upon. > Transaction: Ticket created by jdeighan > Queue: Perl-Critic > Subject: RequireFinalReturn fails to recognize valid return > Broken in: 1.090 > Severity: Important > Owner: Nobody > Requestors: john.deighan@gmail.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=38606 > > > > We're getting the message Subroutine does not end with "return" on > subroutines that clearly do end in "return;". After some examination, > here is the case that causes the flawed message: > > sub f { > foreach my $name qw(John Bill Bob) { > print("$name\n"); > } > return; > } > > The problem is with the construct "qw(John Bill Bob)". The problem > goes > away if you put parens around that. I always thought it a bit odd that > Perl accepts this since I had assumed that surrounding parens would be > required, but Perl doesn't complain and handles it as you would > expect. > But it does cause a problem with Perl::Critic.
At first sight, I would bet this is a parse error in PPI. We'll work with Adam Kennedy to get this fixed. Can I persuade not to use the construct (on the principal of least astonishment)? -Jeff
This looks to be fixed in Perl-Critic 1.105, probably due to new code in PPI for handling for and foreach loops.