On 07/10/2023 12.56, Hermann Peifer wrote:
Hi again.
I am wondering if it is a feature or rather a bug that the lint warning
is also thrown in the second example below.
Regards, Hermann
# Adding 2 values of type: string
> echo a b | ./gawk --lint '{print $1 + $2, typeof($1), typeof($2)}'
gawk: cmd. line:1: warning: `typeof' is a gawk extension
gawk: cmd. line:1: (FILENAME=- FNR=1) warning: operator `+' used on two
string values
0 string string
# Adding 2 values of type: strnum
> echo 1 2 | ./gawk --lint '{print $1 + $2, typeof($1), typeof($2)}'
gawk: cmd. line:1: warning: `typeof' is a gawk extension
gawk: cmd. line:1: (FILENAME=- FNR=1) warning: operator `+' used on two
string values
3 strnum strnum
(...)
Just to add a 3rd example where the lint warning is gone after moving
"$1 + $2" to the end of the print statement.
> echo 1 2 | ./gawk --lint '{print typeof($1), typeof($2), $1 + $2}'
gawk: cmd. line:1: warning: `typeof' is a gawk extension
strnum strnum 3