[Lint] Reject duplicate cases in switch-statement
SupunS opened this issue · 2 comments
SupunS commented
Issue To Be Solved
Currently, duplicate cases are allowed in switch-statement. That can leave unreachable codes without the user being aware.
e.g.:
pub fun test(s: String) {
switch s {
case "foo":
return 1
case "bar":
return 2
case "bar": // a duplicate case: no errors/warnings are reported
return 3
}
}
Suggest A Solution
Validate and reject duplicate cases during compile time.