Skip to content

[SR-1660] Enum with String rawValue and escaped init identifier causes compile error #44269

@swift-ci

Description

@swift-ci
Previous ID SR-1660
Radar None
Original Reporter Wheerd (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, Parser
Assignee None
Priority Medium

md5: 5665fa3f90e5789f42eca1cf46a3fc49

is duplicated by:

  • SR-6959 can't use init as a enum case with associated values

relates to:

  • SR-6557 init case of enum can be used implicitly

Issue Description:

The following program results in a compile time error, because the generated rawValue initializer interferes with the `init` case:

enum Test : String {
    case `init`
}

The compiler gives the following error message:

<unknown>:0: error: invalid redeclaration of 'init(rawValue:)'
INFO at line 5, col 10: 'init' previously declared here
    case `init`
         ^

From my understanding, this enum should work perfectly fine, as that is what the backtick escapes are supposed to prevent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfparserArea → compiler: The legacy C++ parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions