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

Single-tuple and multiple-argument function types should not be considered equal

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Duplicate
    • Component/s: None
    • Labels:
      None

      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 f(_ a: Int, _ b: Int) { print("\(a), \(b)") }
      func g(_ tuple: (Int, Int)) { print("\(tuple)") }
      f(1, 2) // 1, 2
      g((1, 2)) // (1, 2)
      // Working as expected.
      
      // But:
      print(type(of: f) == type(of: g)) // true (!?)
      
      // Or, simpler put:
      print(
          type(of: ((Int, Int) -> Int).self) ==
          type(of: (((Int, Int)) -> Int).self)
      ) // true
      

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              jens Jens Persson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: