Describe the bug
Passing a LocalizedStringKey constructed with basic string interpolation works correctly. For example, the following code works as you would expect:
let name = "Dalton"
let control: LocalizedStringKey = "Static string"
let success: LocalizedStringKey = "Hello, \(name)!"
// This prints:
// - "Static string"
// + "Hello, Dalton!"
print(diff(control, success) ?? "No diff")
However, passing a LocalizedStringKey that uses any of the other variations of string interpolation supported by LocalizedStringKey results in a crash:
let control: LocalizedStringKey = "Static string"
let crash1: LocalizedStringKey = "Date: \(Date(), style: .date)"
let crash2: LocalizedStringKey = "Date range: \(Date.distantPast...Date.distantFuture)"
let crash3: LocalizedStringKey = "Time: \(Duration.seconds(10), format: .time(pattern: .minuteSecond))"
print(diff(control, crash1) ?? "No diff") // crash!
print(diff(control, crash2) ?? "No diff") // crash!
print(diff(control, crash3) ?? "No diff") // crash!
Could not cast value of type 'SwiftUI.LocalizedStringKey.FormatArgument.Token' (0x1fea477e8) to 'NSFormatter' (0x1fd708ed8).
2023-09-02 19:11:54.584602-0500 dump-bug[32884:11397570] Could not cast value of type 'SwiftUI.LocalizedStringKey.FormatArgument.Token' (0x1fea477e8) to 'NSFormatter' (0x1fd708ed8).
Expected behavior
I expect that the above code would not result in a crash and would instead print an appropriate diff between the provided strings.
Environment
swift-custom-dump version: 1.0.0
Xcode Version 14.3.1 (14E300c)
Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Describe the bug Passing a
LocalizedStringKey
constructed with basic string interpolation works correctly. For example, the following code works as you would expect:However, passing a
LocalizedStringKey
that uses any of the other variations of string interpolation supported byLocalizedStringKey
results in a crash:The crash (
SIGABRT
) occurs on this line: https://github.com/pointfreeco/swift-custom-dump/blob/c2012e1eadd30b232186a9045da0fc5635969566/Sources/CustomDump/Conformances/SwiftUI.swift#L59The console output:
Expected behavior I expect that the above code would not result in a crash and would instead print an appropriate diff between the provided strings.
Environment