Skip to content

spec: multiple equal integer constant switch case values should be illegal #4524

Closed
@griesemer

Description

@griesemer
The spec does not prohibit multiple integer constant case values from being equal:

var x int
switch x {
case 1:
case 1:
}

is not illegal according to http://tip.golang.org/ref/spec#Switch_statements . However,
running this program ( http://play.golang.org/p/MkI5XjE1TS ) results in:

prog.go:7: duplicate case in switch
    previous case at prog.go:6

using the gc compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions