cadence-tools
cadence-tools copied to clipboard
[Lint] Reject duplicate cases in switch-statement
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.
is it safe to assume this ticket as done? )
The implementation is available in this [closed] PR: https://github.com/onflow/cadence-tools/pull/8. But unfortunately, it was never merged, because of some tech-dept at the time, where these tools were moved to a separate repo.
We would still need to resurface that PR/changes, and open it as a new PR.