-
Notifications
You must be signed in to change notification settings - Fork 172
Force casting fails if TextState has an unexpected storage #269
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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.
LocalizedStringKeyconforms toEquatablebut 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
- I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- If possible, I've reproduced the issue using the
mainbranch of this package. - This issue hasn't been addressed in an existing GitHub issue or discussion.
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.0Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working