Quick potential bug report

Hi all, I'm learning Swift and loving the language. The following example or facsimile is reproducible when using Swift interpreter in a Mac Terminal:

 17> let y = (statusCode: 200, description: "OKEY")
y: (statusCode: Int, description: String) = {
  statusCode = 200
  description = "OKEY"
}
 18> let y = (statusCode: 200, description: "OKE")
y: (statusCode: Int, description: String) = {
  statusCode = 200
  description = "OKE"
}
 19> let y = (statusCode: 200, description: "OK")
y: (statusCode: Int, description: String) = {
  statusCode = 200
  description = unable to read data
}

Okey Dokey? :) Finally,

$ swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0

Please forward to appropriate team if this is new.

Regards,
Dave.

I would like to thank you for taking the time for reporting this.

There was a point in time where the formatter in lldb for small strings for small strings was broken, and this probably was shipped as part of the swift compiler you run on. We fixed and added a test to make sure it doesn't regress in future.

$ ./lldb --repl
Welcome to Swift version 4.2-dev (LLVM eb00ef6046, Clang 9b4efae436, Swift d17b767361). Type :help for assistance.
  1> let y = (statusCode: 200, description: "OKEY")
y: (statusCode: Int, description: String) = {
  statusCode = 200
  description = "OKEY"
}
  2> let y = (statusCode: 200, description: "OKE")
y: (statusCode: Int, description: String) = {
  statusCode = 200
  description = "OKE"
}
  3>
  4>  let y = (statusCode: 200, description: "OK")
y: (statusCode: Int, description: String) = {
  statusCode = 200
  description = "OK"
}

You can grab the latests snapshot toolchain where this should be fixed, if you want to try yourself.

1 Like