ifparens

IF function is confusing, use parentheses

Rule "ifparens" gives this warning when it finds an IF function (not
an IF statement) where ELSE is followed by an operator. This may cause
confusion, which can be solved by putting parentheses around the IF
function.

ASSIGN answer = IF x>0
                   THEN 10
                   ELSE 20 
                + 3000.
DISPLAY answer.

'answer' will be 3020 when x<=0.

'answer' will be 10 (not 3010) when x>0. The programmer may have
been confused and intended the value of 'answer' to be 3010.

the risc:

The IF function can be very confusing, depending on how the code is indented.
There is a good chance that the statement containing the IF function does not
behave how the programmer intended. Parentheses around the IF fuction
can make a huge difference and will certainly make the statement easier to
understand.

how to solve this:

/* simply add parentheses around the IF function: */
ASSIGN answer = (IF x>0
                   THEN 10
                   ELSE 20) 
                 + 3000.

/* or: */
ASSIGN answer = IF x>0
                   THEN 10
                   ELSE (20 + 3000).

How to suppress these warnings:

You can put the directive {&_proparse_ prolint-nowarn(ifparens)} directly before
the statement that contains the IF function. See also: suppress warnings.