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

A returning value of Array<Void> should give a warning, like Optional<Void>

    XMLWordPrintable

    Details

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

      Description

      let optOne: Int? = 1
      let y = optOne.map { _ in return () } // Constant 'y' inferred to have type '()?', which may be unexpected
      let z = [""].map { _ in return () } // no warning.
      
      // The expected warning would be:
      // Constant 'z' inferred to have type '[()]', which may be unexpected
      

      For more information see the thread in this tweet.

        Attachments

          Activity

            People

            Assignee:
            jder Jesse Rusak
            Reporter:
            bas Bas Thomas Broek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: