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

LLDB can falsely report that a variable holds nil

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: LLDB for Swift
    • Labels:
      None
    • Environment:

      Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
      Target: x86_64-apple-darwin19.4.0

      macOS 10.15.4 (19E287)

      Description

      Given the following program:

      import AppKit
      
      let panel = NSOpenPanel()
      panel.canChooseDirectories = true
      guard panel.runModal() == .OK else {
          fatalError()
      }
      let url = panel.url
      // breakpoint #1: v url
      print(String(describing: url))
      
      if let nonOptionalURL: URL = url {
          // breakpoint #2: v nonOptionalURL
          print(nonOptionalURL)
          
          let optionalURL: URL? = url
          // breakpoint #3: v optionalURL
          print(String(describing: optionalURL))
      }
      

      At breakpoint #1, lldb's frame variable reports that url is nil, even when it is not.

      At breakpoint #2, frame variable reports that nonOptionalURL is {}, whatever that even means.

      At breakpoint #3, frame variable cannot find optionalURL at all; however, from my testing the problem also remains when using nonOptionalURL as an argument to a function taking a URL?.

      Please consult the attached output for specifics.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            ThatsJustCheesy Ian Gregory
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated: