Lucky hour! Grab a free trial license — offer ends in 00:59:58. Claim now
The analyzer detected identical expressions in case. This error may occur as a result of copy-pasted code. As a result, not all of the intended options may be handled in the switch statement, and some branches may become unreachable.
The example:
const (
MONDAY = 1
TUESDAY = 2
WEDNESDAY = 3
THURSDAY = 4
FRIDAY = 5
)
switch {
case day == MONDAY:
....
case day == TUESDAY:
....
case day == WEDNESDAY:
....
case day == THURSDAY:
....
case day == MONDAY:
....
}
In this example, the day == MONDAY condition is used twice. Consequently, the code inside the last case will be unreachable. Instead of the second identical expression, the day == FRIDAY is intended to be used.
The fixed code:
switch {
case day == MONDAY:
....
case day == TUESDAY:
....
case day == WEDNESDAY:
....
case day == THURSDAY:
....
case day == FRIDAY:
....
}
You can look at examples of errors detected by the V8010 diagnostic. |
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: