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

Strange values being printed when using protocols

    XMLWordPrintable

    Details

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

      Apple Swift version 4.0.1 (swiftlang-900.0.66 clang-900.0.37)

      Description

      If you launch Swift on the command line and give it the following code:

      protocol Testable {
      
      }
      
      struct TestStruct: Testable {
          var num = 0
          var str = ""
      }
      
      let test1 = TestStruct()
      let array: [Testable] = [test1]
      

      Then the output you get is as follows:

      test1: TestStruct = {
        num = 0
        str = ""
      }
      array: [Testable] = 1 value {
        [0] = {
          num = 4300275808
          str = ""
        }
      }
      

      The "4300275808" is clearly wrong. If you change the code to be [TestStruct] rather than [Testable] then the problem goes away.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            twostraws Paul Hudson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: