Perl5-IDEA icon indicating copy to clipboard operation
Perl5-IDEA copied to clipboard

Syntax::Keyword::Try require redundant semicolon

Open eitankeren opened this issue 4 years ago • 6 comments

The syntax check mark an error if Syntax::Keyword::Try; is used without ending ";" while they aren't needed, see example below.

use Syntax::Keyword::Try;

try { attempt_a_thing(); return "success"; } catch ($e) { warn "It failed - $e"; return "failure"; };

The catch block do not need the ending semicolon signed but without it the Perl syntax checker will raise an error.

eitankeren avatar Oct 03 '21 02:10 eitankeren

The reason is that there are lot of different try-catch implementation. Some of them require semi others - don't. Plugin supports some of them, but it's not possible to say which one is used in particular file. So there is a heuristic. And it fails sometime. I don't see how I can distinct this approach from another one.

hurricup avatar Oct 03 '21 05:10 hurricup

Clear.

if you can link the Try/Cache module importation to the correct syntax that may be nice as this one is among the more popular one used by the Perl community together with Tiny::Try.

Thanks allot for your fast response, Your contribution to the community is very much appreciated!

-- Eitan

eitankeren avatar Oct 03 '21 05:10 eitankeren

The problem is that it may be used indirectly or in some tricky way. I don't really remember atm what problems I had, but it was a real headache :)

Here is the list of modules that should work correctly: https://github.com/Camelcade/Perl5-IDEA/blob/master/plugin/core/grammar/Perl5.bnf#L681

hurricup avatar Oct 03 '21 05:10 hurricup

I'll recheck the code, but can't give you exact estimation.

hurricup avatar Oct 03 '21 05:10 hurricup

Ok, thanks allot for your efforts!

eitankeren avatar Oct 03 '21 05:10 eitankeren

Maybe could add a per-project setting that lets us choose which Try library we're using?

That way we could have next and redo inside try or catch blocks, if we choose say Syntax::Keyword::Try without a red underline

akarelas avatar Dec 16 '21 13:12 akarelas