Description
|
Array(Mirror(reflecting: children[0].value).children)[0].value as! (Any, Formatter?) |
The force casting above fails if the TextState has an unexpected storage such as AttibutedString.
LocalizedStringKey conforms to Equatable but returns false for equivalent format strings. To account for this we reflect on it to extract and string-format its storage.
I have noticed this comment and understand that this workaround is required for LocalizedStringKey.
But LocalizedStringResource does not seem to require it, so I think supporting LocalizedStringResource might be another workaround.
Checklist
Expected behavior
No crash, no matter what the the storage is.
Actual behavior
Crash if the storage is not (Any, Formatter?).
Steps to reproduce
- Create a TextState with
AttibutedString: TextState("\(AttributedString())")
- Trigger
LocalizedStringKey.formatted(locale:tableName:bundle:comment:) by initial a String or check the equability
SwiftUI Navigation version information
2.2.3
Destination operating system
iOS 18.2
Xcode version information
16.2 (16C5032a)
Swift Compiler version information
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Description
swift-navigation/Sources/SwiftNavigation/TextState.swift
Line 608 in ddcd641
The force casting above fails if the TextState has an unexpected storage such as AttibutedString.
I have noticed this comment and understand that this workaround is required for
LocalizedStringKey.But
LocalizedStringResourcedoes not seem to require it, so I think supportingLocalizedStringResourcemight be another workaround.Checklist
mainbranch of this package.Expected behavior
No crash, no matter what the the storage is.
Actual behavior
Crash if the storage is not
(Any, Formatter?).Steps to reproduce
AttibutedString:TextState("\(AttributedString())")LocalizedStringKey.formatted(locale:tableName:bundle:comment:)by initial a String or check the equabilitySwiftUI Navigation version information
2.2.3
Destination operating system
iOS 18.2
Xcode version information
16.2 (16C5032a)
Swift Compiler version information