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

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

>
>
>
V7003. A condition is equivalent to...
menu mobile close menu
Additional information
toggle menu Contents

V7003. A condition is equivalent to a condition in an 'else if' statement, making it unreachable.

Apr 03 2026

The analyzer has detected duplicate conditions in an if and else if statements' chain. The code in the repeated condition will never execute, which indicates an error.

The example:

if (a == 1) {
  foo();
} else if (a == 2) {
  bar();
} else if (a == 1) {
  baz();
}

In this example, the call to baz() is unreachable, since control flow never reaches it. This is probably a logic error, and the fixed code should look like this:

if (a == 1) {
  foo();
} else if (a == 2) {
  bar();
} else if (a == 3) {
  baz();
}

Non-identical but equivalent expressions are also taken into account. The example:

if (a & b) {
  foo();
} else if (b & a) {
  bar();
}

This code triggers a warning because a bitwise AND is commutative, so the result will be the same.