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

Not correct function types in Swift4 (is)

    XMLWordPrintable

    Details

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

      Description

      Mark Lacey <mark.lacey@apple.com> asked to create this issue. ("is" part)

      I believe fooParam should have type of (Int,Int) -> () and fooTuple of type ((Int,Int)) -> (), but it seems like they have the same type:

      func fooParam(_ x: Int, _ y: Int){}
      func fooTuple(_ x: (Int, Int)) {}
      
      if fooParam is (_: (Int,Int))->() { print("fooParam is (_: (Int,Int))->()") }
      // result: fooParam is (_: (Int,Int))->()
      
      if fooTuple is (Int,Int)->() { print("fooTuple is (Int,Int)->()") }
      // result: fooTuple is (Int,Int)->()
      
      //--- closure ---
      
      var closureParam = { (x: Int, y: Int) in  }
      var closureTuple = { (x: (Int, Int)) in  }
      
      if closureParam is (_: (Int,Int))->() { print("closureParam is (_: (Int,Int))->()") }
      // result: closureParam is (_: (Int,Int))->()
      
      if closureTuple is (Int,Int)->() { print("closureTuple is (Int,Int)->()") }
      // result: closureTuple is (Int,Int)->()
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            VladimirS Vladimir
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: