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

Force unwrapping nil literal compiles without warning

    XMLWordPrintable

    Details

      Description

      The following compiles without any warning/error, even though it's clearly nonsense:

      struct Foo {
        var bar: Int
      }
      let f = Foo(bar: nil!)
      

      Presumably the type checker thinks the nil is an Int? being force-unwrapped. It would be neat to have a warning or error here.

        Attachments

          Activity

            People

            Assignee:
            gbrntt George Barnett
            Reporter:
            gbrntt George Barnett
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: