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

Lucky hour! Grab a free trial license — offer ends in 00:59:58. Claim now

>
>
>
V8004. The use of 'if A {...} else...
menu mobile close menu
Additional information
toggle menu Contents

V8004. The use of 'if A {...} else if A {...}' pattern was detected. A potential logical error is present.

Apr 03 2026

The analyzer has detected a potential error in a construction consisting of conditional instructions. The error is caused by repeated if conditions, which may result in the code within that branch becoming unreachable.

The example:

const (
  MONDAY    = "Monday"
  TUESDAY   = "Tuesday"
  WEDNESDAY = "Wednesday"
  THURSDAY  = "Thursday"
  FRIDAY    = "Friday"
)

if day == MONDAY {
  ....
} else if day == TUESDAY {
  ....
} else if day == WEDNESDAY {
  ....
} else if day == THURSDAY {
  ....
} else if day == MONDAY {
  ....
}

In the example, there are two if constructions with the same condition. If control flow reaches the second condition, it will always evaluate as false, making all code in the corresponding branch unreachable.

The fixed code:

if day == MONDAY {
  ....
} else if day == TUESDAY {
  ....
} else if day == WEDNESDAY {
  ....
} else if day == THURSDAY {

} else if day == FRIDAY {
  ....
}

This diagnostic is classified as:

You can look at examples of errors detected by the V8004 diagnostic.