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

Improve diagnostic for multi-statement closures instead of saying "too complex closure return type"

    XMLWordPrintable

    Details

      Description

      See https://forums.swift.org/t/too-complex-closure-return-type/49897 – it's not clear why a closure is "too complex" because from a user perspective, it looks quite simple.

      In case there are multiple statements, we can provide a more specialized diagnostic saying that the compiler doesn't support inferring types of closures with multiple statements.

      _ = { // error: Unable to infer complex closure return type; add explicit type to disambiguate
          _ = "" // or anything else here
          return ""
      } 

        Attachments

          Activity

            People

            Assignee:
            jiaren wang jiaren wang
            Reporter:
            theindigamer Varun Gandhi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: