You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is almost certainly a typo; the second case is unreachable. The compiler may reject duplicate constant cases in expression switches, but not e.g. nil or composite literals containing constants. (See #15896 for discussion.) Perhaps cmd/vet should step in to help catch these likely bugs. This issue is a reminder to investigate.
The text was updated successfully, but these errors were encountered:
@mvdan Let's try it in vet first. It's not always clear when two different cases are identical. Do they have to be written precisely the same way? What if one says 1 and one says int(1)? And so forth.
Also, doing it in the compiler would require a spec change, probably an addition to the implementation restriction in https://golang.org/ref/spec#Switch_statements . Which can of course be done but again requires some thought as to when cases are identical.
Consider:
This is almost certainly a typo; the second case is unreachable. The compiler may reject duplicate constant cases in expression switches, but not e.g.
nil
or composite literals containing constants. (See #15896 for discussion.) Perhaps cmd/vet should step in to help catch these likely bugs. This issue is a reminder to investigate.The text was updated successfully, but these errors were encountered: