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

Useless diagnostic when passing expression of wrong type to function

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Cannot Reproduce
    • Component/s: Compiler
    • Environment:

      Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)

      Swift version 4.0 (swiftlang-900.0.59 clang-900.0.34.2)

      Description

      Code:

      let x: Bool = true
      enum A { 
      	case a
      	case b
      }
      func f(_ a: A) {}
      let a: A = .a
      f(x ? .a(a) : .b)
      

      Result:
      error: repl.swift:8:13: error: result values in '? :' expression have mismatching types '' and ''
      f(x ? .a(a) : .b)
      ~~~~~ ^ ~~

      This is a reduction of a case I saw in my code. In the real code I got "Int1 is not convertible to 'Bool'", but I'm not sure why that was different, other than the fact that it's inside of a closure inside of another closure...

        Attachments

          Activity

            People

            • Assignee:
              xedin Pavel Yaskevich
              Reporter:
              NachoSoto Nacho Soto
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: