bug-gawk
[Top][All Lists]
Advanced

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

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


From: Arkadiusz Drabczyk
Subject: Why 'statement may have no effect' lint warning here?
Date: Sun, 11 Apr 2021 23:23:12 +0200

The following code produces 'statement may have no effect' when run
with --lint:

BEGIN {
    var = 1
    var == 1 && var = 2
    print "var ==", var
}

But if function call is used instead of 'var == 1' the warning is
gone:

BEGIN {
    var = 1
    print("hi") && var = 3
    print "var ==", var
}

I don't understand why is this warning issued in the first case. I
thought that 'var == 1' will always have an effect as it returns
either true or false but warning says something completely
different. What is meant by 'effect' here?

-- 
Arkadiusz Drabczyk <arkadiusz@drabczyk.org>



reply via email to

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