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

We need an ambiguity warning for assigning .none to an optional enum where .none is a valid case.

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: None
    • Labels:
      None

      Description

      For example, if we have this enum:

      enum Foo: String {
          case valid
          case none
      }

      And then we initialize an optional variable like this:

      let foo: Foo? = .none

      We should get an ambiguity warning as it is not clear if we are talking about 

      Optional<T>.none OR Foo.none

      Currently the only way to tell them apart is because of the syntax coloring, and at this moment the compiler is choosing Optional<T>.none over Foo.none, but I'm unable to tell at this time if this is defined behavior or not. If it is not defined behavior it might change in the future and break source compatibility.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dev_jac Julio Carrettoni
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: