develooper Front page | perl.perl5.porters | Postings from February 2000

Bug or Feature? Warnings about logical 'and' for bad 'if' statements

Thread Next
From:
Michael G Schwern
Date:
February 9, 2000 19:48
Subject:
Bug or Feature? Warnings about logical 'and' for bad 'if' statements
Message ID:
20000209224816.A2028@athens.aocn.com
I was quite surprised to see the following warning when checking the
syntax (-c) a program:

        Probable precedence problem on logical and (&&) at ...

Okay, fine.  Problem is there's no 'and' or '&&' in the program.
Wrote a quick test case and discovered that subroutine names with
underscores in them used as barewords before the routine is defined
throws this error:

        perl -wle 'if( foo_me ) { print "Foo!" }  sub foo_me { print "FMH" }'
        Probable precedence problem on logical and (&&) at -e line 1.
        Foo!

njt informs me that internally if statements and logical ands are the same
op, which explains the warning.

Question is:  Is this the warning we want displayed to the user?  It is
not descriptive of the problem, doesn't aid in debugging except to
point the user's eyes at the right line and exposes an internal issue to
the outside world.


Occurs the same on 5.005_03 and 5.5.640

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About