Skip Menu |

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

Report information
The Basics
Id: 100291
Status: resolved
Priority: 0/
Queue: Perl-Critic-Pulp

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

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



Subject: CodeLayout::RequireFinalSemicolon false positive with TryCatch
The CPAN module TryCatch adds try/catch syntax to Perl. This can cause a false positive requiring a final semicolon: { try { say 55 } catch ($err) { die $err unless $err =~ /foo/; } } Note that if the outer {} are removed the false positive goes away.
On 2014-11-12 08:11:01, EDAVIS wrote: Show quoted text
> The CPAN module TryCatch adds try/catch syntax to Perl. This can > cause a false positive requiring a final semicolon:
Basically, all bets are off when Devel::Declare is present. Some accomodation must be done for when the parser is hooked and modified.
CC: bug-Perl-Critic-Pulp [...] rt.cpan.org
Subject: Re: [rt.cpan.org #100291] CodeLayout::RequireFinalSemicolon false positive with TryCatch
Date: Thu, 13 Nov 2014 19:27:11 +1100
To: EDAVIS [...] cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"EDAVIS via RT" <bug-Perl-Critic-Pulp@rt.cpan.org> writes: Show quoted text
> > The CPAN module TryCatch adds try/catch syntax to Perl.
Hmm. Recognising that as a new kind of compound statement might be possible. I wonder if PPI might do that, if it's a popular module. "use TryCatch" seems to apply from its source line onwards (as opposed to lexically scoped or whatever). Is that right?
Show quoted text
>"use TryCatch" seems to apply from its source line onwards
Probably - but note that approximately the same syntax extensions is provided by another module Try::Tiny. There might be others. It probably makes most sense not to check for whether one of these modules is being loaded but just recognize try / catch syntax all the time. If that requires a change in PPI it might be a harder sell.
Subject: Re: [rt.cpan.org #100291] CodeLayout::RequireFinalSemicolon false positive with TryCatch
Date: Sat, 03 Jan 2015 19:01:16 +1100
To: "EDAVIS via RT" <bug-Perl-Critic-Pulp [...] rt.cpan.org>
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"EDAVIS via RT" <bug-Perl-Critic-Pulp@rt.cpan.org> writes: Show quoted text
> > recognize try / catch syntax all the time.
I see Try::Tiny, and maybe its friends, demands a final semi, use Try::Tiny; try { print "hi\n" } catch { 456 } try { print "hi\n" } catch { 456 } => hi try() encountered an unexpected argument (1) - perhaps a missing semi-colon before or at foo.pl line 30. For it "RequireFinalSemicolon" could be a good thing (for the same reason as ordinary statements). But Try, TryCatch, and Syntax::Feature::Try are without. I'm tempted to recognise those as not needing ...
Subject: Re: [rt.cpan.org #100291] CodeLayout::RequireFinalSemicolon false positive with TryCatch
Date: Sun, 04 Jan 2015 17:57:28 +1100
To: bug-Perl-Critic-Pulp [...] rt.cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
I added some bits to version 89, distinguishing the two styles of try. See how it goes.
Subject: Re: [rt.cpan.org #100291] CodeLayout::RequireFinalSemicolon false positive with TryCatch
Date: Sun, 04 Jan 2015 18:06:41 +1100
To: "EDAVIS via RT" <bug-Perl-Critic-Pulp [...] rt.cpan.org>
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"EDAVIS via RT" <bug-Perl-Critic-Pulp@rt.cpan.org> writes: Show quoted text
> > If that requires a change in PPI it might be a harder sell.
Oh, on this bit, PPI takes most { } as code blocks rather than anon hashrefs. That usually suits syntax extensions. I put some slightly nasty nonsense for the opposite, to avoid hashrefs which have parsed as code blocks so as not to give false positives. Don't want to claim a semicolon should be at the end of a hashref.