Skip to content

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

Open
@SupunS

Description

@SupunS

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions