Uploaded image for project: 'Swift'
  1. Swift
  2. SR-1660

Enum with String rawValue and escaped `init` identifier causes compile error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              Wheerd Manuel Krebber
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: