bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why 'statement may have no effect' lint warning here?


From: arnold
Subject: Re: Why 'statement may have no effect' lint warning here?
Date: Tue, 13 Apr 2021 23:16:13 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Manuel Collado <mcollado2011@gmail.com> wrote:

> El 13/04/2021 a las 10:20, Wolfgang Laun escribió:
> > Just ask your Software Quality Dptmt what they think of using a logical
> > expression as an alternative to an if statement without else.
>
> Of course, that construct is a mistake. My point is that --lint is
> intended to help diagnose mistakes. And hence flagging that statement
> as dubious makes sense.

`a == 1 && b = 42' is not a mistake. It's semantically valid code.
It might be "poor" code by various standards, but it's valid and
the current lint warning for it is a bug.

However, gawk does not comment on the quality of the code it runs, even
with --lint. Were it to do so, there is code I've seen that should
brick the computer it runs on.

Rather, it does try to point out real semantic mistakes, such as

BEGIN {
        a = 5
        b = 3
        a + b   # useless statement
}

The current code in gawk that does this analysis and prints error messages
is a bit confused.  I think this became the case when gawk moved from its
original recursive parse tree evaluator to the current byte code engine.

I am working to striaghten this out and will eventually post a patch.
In the meantime, just accept that current gawk is not behaving
completely correctly in this area.

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]