Skip to content

[SR-10077] Switching over duplicate enum case names won't compile #52479

@swift-ci

Description

@swift-ci
Previous ID SR-10077
Radar None
Original Reporter xavier.lowmiller (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 12
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 11bc61add2da06bf28b3399dd2617f81

Issue Description:

In Swift 4.2 (Xcode 10.1) and 5.0 (Xcode 10.2 beta 4), it's legal to define multiple identical enum cases as long as their associated value is different:

enum PictureImport { case add(image: UIImage) case add(data: Data) }

This, however, leads to compile errors when switching:

func importImage(_ importedImage: PictureImport) { switch importedImage { case .add(image: let image): // Error: Tuple pattern element label 'image' must be 'data' // ... case .add(data: let data): // ... } }

(Maybe related to #49402)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdeclarationsFeature: declarationsenumFeature → type declarations: Swift enumeration declarationsenum casesFeature → enums: Enum casesoverloadingFeature: Overloading symbol namespattern matchingFeature: pattern matchingpatternsFeature: patternsswift 5.9type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions