Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Show all errors on compile time

by ifazlives (Initiate)
on Aug 08, 2018 at 19:12 UTC ( #1220129=perlquestion: print w/replies, xml ) Need Help??
ifazlives has asked for the wisdom of the Perl Monks concerning the following question:

I recently upgraded Perl from 5.18 to 5.22 and I noticed a difference at the compile time [ perl -c <script> ] experience.

On 5.18, I used to get all the syntax errors at compile time in a single compilation.

But on 5.22, the compile process exists as soon as it hits the first syntax error. I will have to fix this error and re-compile it to check for further syntax errors.

Is there a way to get all the syntax errors at compile time in a single compilation.

Regards, IE

Replies are listed 'Best First'.
Re: Show all errors on compile time
by Discipulus (Monsignor) on Aug 08, 2018 at 19:54 UTC
    Hello ifazlives and welcome to the monastery and to the wonderful world of Perl!

    It sounds strange what you are reporting.. in my little experience I noticed that when multiple errors are found during -c compilation, the first one is the meaningfull one and if are reported additional errors they many times caused by the first one. Then others errors can be found and reported, but I suspect this depend on which kind of errors is the first and if compiler can go on.

    Probably you should reduce what you are experiencing into a minimal amount of code that produces such behaviours under these version and include, if still true, more information like perl -v gives.

    I've tried in different perl distros ( 5.14 5.22 5.24 strawberry portable) and I got the same output under -c simply modifing a large file introducing 3 errors the first one at line 300 consisting into a if($condition){ continue{1} ...

    "my" variable $par_fname masks earlier declaration in same scope at ERRORS.pl line 316 (#1) (W misc) A "my", "our" or "state" variable has been redeclared in +the current scope or statement, effectively eliminating all access to +the previous instance. This is almost always a typographical error. +Note that the earlier variable will still exist until the end of the sc +ope or until all closure references to it are destroyed. syntax error at ERRORS.pl line 300, near "continue" syntax error at eERRORS.pl line 310, near "}" Can't use global $& in "my" at ERRORS.pl line 316, near "uc($&" syntax error at ERRORS.pl line 401, near "log_stdout" syntax error at ERRORS.pl line 641, near "}" syntax error at ERRORS.pl line 734, near "}" syntax error at ERRORS.pl line 743, near "}" Can't redeclare "my" in "my" at ERRORS.pl line 745, near "" syntax error at ERRORS.pl line 782, near "}" Can't redeclare "my" in "my" at ERRORS.pl line 788, near "" ERRORS.pl has too many errors (#2) (F) Probably means you had a syntax error. Common reasons include +: ...

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Thanks
Re: Show all errors on compile time
by ikegami (Pope) on Aug 08, 2018 at 22:03 UTC

    But on 5.22, the compile process exists as soon as it hits the first syntax error.

    You appear to have misdiagnosed the issue because that's not true. Both new and old compilers show as many errors as possible.

    Note that some errors prevent the compiler from going any further, but that's always been the case.

    Since all you've provided is a misdiagnosis, we can't help you until you provide more information.

      You are correct. I have misdiagnosed the issue.

      What prompted me to ask the question was:
      In Perl 5.18, I get the below result when I compile a script

      perl -c OrgChart.cgi
      defined(%hash) is deprecated at OrgChart.cgi line 104, <DATA> line 751.
      (Maybe you should just omit the defined()?)
      defined(@array) is deprecated at OrgChart.cgi line 2424, <DATA> line 751.
      (Maybe you should just omit the defined()?)
      defined(@array) is deprecated at OrgChart.cgi line 2426, <DATA> line 751.
      (Maybe you should just omit the defined()?)
      defined(@array) is deprecated at OrgChart.cgi line 2428, <DATA> line 751. (Maybe you should just omit the defined()?)

      But in Perl 5.22, the compile gave me only the first one from 5.18.

      perl -c OrgChart.cgi
      Can't use 'defined(%hash)' (Maybe you should just omit the defined()?) at OrgChart.cgi line 104, <DATA> line 755.

      It was my misunderstanding the 5.18 was throwing all error. But infact those where just warnings.
      Regards,
      IE

        defined(%hash) makes no sense.

        In 5.16, it was deprecated and it started warning you that you needed to stop using it.

        In 5.22, it became a fatal error.

        The parser probably can't continue because this isn't an error encountered by the parser. You could use perlbug to file a ticket asking that this type of error doesn't stop the parser.

Re: Show all errors on compile time
by LanX (Bishop) on Aug 08, 2018 at 19:46 UTC
    Do you have an example with multiple such errors demonstrating your observation?

    update

    On a side note: If you use an IDE which supports continuously running perl -c in the background (like "flymake" in emacs) you will see all compile-time errors almost immediately wile you type.

    You can also configure to let the check run with an older Perl (if that really helps)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: Show all errors on compile time
by Laurent_R (Canon) on Aug 08, 2018 at 22:41 UTC
    I also don't think this is true. I've noticed that some errors prevent the compiler from continuing, others don't, irrespective (probably) of the Perl version.

    Unless, of course, you can prove it by showing an example where compiling the same program displays the behavior your described with two versions of Perl (even then, it might be an odd case and still not really evidence your case, as I am pretty sure that I have seen multiple errors displayed by the compiler with newer versions of Perl).

Re: Show all errors on compile time
by QM (Parson) on Aug 09, 2018 at 13:06 UTC
    I've noticed that some errors are marked as syntax errors, and may not be the first error listed. But these are usually the first ones to address.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1220129]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-08-17 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (184 votes). Check out past polls.

    Notices?