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

Single-tuple and multiple-argument function types should be treated as different types

    XMLWordPrintable

    Details

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

      Description

      Swift should properly distinguish between single-tuple and multiple-argument function types.
      But it isn't, as demonstrated below.
      The following is the behavior of swift-DEVELOPMENT-SNAPSHOT-2017-06-05-a-osx (-swift-version 4):

      func add(_ a: Int, _ b: Int) -> Int { return a + b }
      let a: (Int, Int) -> Int = add
      let b: ((Int, Int)) -> Int = add // OK, but why isn't it an error?
      print(a(1, 2)) // 3
      print(b((1, 2))) // 3
      // I would not expect the assignment to b to compile since the func `add`
      // does not have the type ((Int, Int)) -> Int.
      

      (Reported as requested by Mark Lacey here:
      https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170605/037013.html
      )

        Attachments

          Activity

            People

            Assignee:
            rudkx Mark Lacey
            Reporter:
            jens Jens Persson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: