V8019. Two or more equivalent expressions are specified inside the case expression list.
The analyzer detected equivalent expressions for the same case within the switch statement.
The example:
switch {
case s == "start", s == "start":
Start()
case s == "stop":
Stop()
}
Using equivalent expressions likes == "start" makes no sense.
- If the first expression evaluates to
true, control flow enters the branch, bypassing the second expression. - If the first expression evaluates to
false, the second expression will evaluate the same way, and control flow will skip this entire branch.
Most likely, this is a typo, and the second equivalent expression should be something else.
The fixed code:
switch {
case s == "start", s == "begin":
Start()
case s == "stop":
Stop()
}