Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
V7018. The expression 'A || (A &&...
menu mobile close menu
Additional information
toggle menu Contents

V7018. The expression 'A || (A && B)' is redundant and always evaluates to 'A'.

Apr 03 2026

The analyzer has detected an expression that can be simplified. Such expressions may also indicate logical errors.

The example:

let firstCond, secondCond, thirdCond;
....
if (firstCond || (firstCond && thirdCond))
....

The expression is redundant. If firstCond is true, the condition result is always true, regardless of thirdCond. If firstCond is false, the expression is always false.

The firstCond || (firstCond && thirdCond) expression can be simplified as follows:

if (firstCond)

Most likely, a wrong variable was used in the second subexpression. The fixed code may look like this:

if (firstCond || (secondCond && thirdCond))