Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Syntactic Confectionery Delight
 
PerlMonks  

More Misleading Compiler Error Messages

by QM (Vicar)
on Aug 01, 2006 at 22:49 UTC ( #565098=perlmeditation: print w/ replies, xml ) Need Help??

This is something between a SOPW and a Meditation. I'm not really asking a question, just grousing...

I suspect every language has its idiosyncratic compiler error messages. I know Perl is not immune. Consider:

C:\>perl -c ag2gen.pl "my" variable $i masks earlier declaration in same statement at ag2gen +.pl line 1391. "my" variable @test_order masks earlier declaration in same scope at a +g2gen.pl line 1391. "my" variable @test_order masks earlier declaration in same statement +at ag2gen.pl line 1393. "my" variable $i masks earlier declaration in same statement at ag2gen +.pl line 1393. "my" variable @test_order masks earlier declaration in same statement +at ag2gen.pl line 1393. "my" variable $j masks earlier declaration in same statement at ag2gen +.pl line 1393. "my" variable %test_order masks earlier declaration in same scope at a +g2gen.pl line 1394. "my" variable @test_order masks earlier declaration in same statement +at ag2gen.pl line 1394. "my" variable $i masks earlier declaration in same statement at ag2gen +.pl line 1394. "my" variable @test_order masks earlier declaration in same statement +at ag2gen.pl line 1394. "my" variable $j masks earlier declaration in same statement at ag2gen +.pl line 1394. syntax error at ag2gen.pl line 1389, near "2]" ag2gen.pl had compilation errors.
Here are the offending lines:
1389: for my $i (0..@test_order-2]) 1390: { 1391: for my $j ($i+1..@test_order-1) 1392: { 1393: unless ( ( $test_order[$i] eq $test_order[$j] ) 1394: or exists($test_order{"$test_order[$i]\t$test_order[$j]"} +) )
for my $i doesn't mask anything. In fact, it doesn't compile (at least, not completely).

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

Comment on More Misleading Compiler Error Messages
Select or Download Code
Re: More Misleading Compiler Error Messages
by ikegami (Pope) on Aug 01, 2006 at 23:17 UTC

    Might not be the only problem, but
    1389: for my $i (0..@test_order-2])
    should be
    1389: for my $i (0..@test_order-2)

      Thanks. I should have said that I figured it out. I guess it was something of a puzzle as well.

      I just find it odd that the for loop expression didn't compile, and it's complaining about the my $i, which is bogus. Granted, it pointed out the syntax error, but syntax errors should trump warnings, shouldn't it?

      Thanks again!

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

        You've obviously never driven your grandmother to the library, have you?

        GM: Look out for that bicycle! GM: Ooh! GM: The light is red, watch out! GM: Eek, a tram! Don't drive so fast! GM: Oh look what a darling kitty! Me: Where? GM: There! There behind that window, look! *CRASH*

        It doesn't realize the warning is related to the syntax error. Given

        my $s = shift . '!'; $s+++;

        the compile will issue both a warning (Warning: Use of "shift" without parens is ambiguous) and a syntax error (syntax error). As far as perl was concerned, it was the same situation with your code.

        Missing and extraneous closers (closing quotes, closing curlies, closing brackets, etc) are notoriously noisy errors. If you get a lot of unusual errors/warnings, chances are that's your problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://565098]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-04-17 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (453 votes), past polls