Skip to content

[Lint] Reject duplicate cases in switch-statement #61

Open

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions