-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaArea: Standard library umbrella
Description
| Previous ID | SR-12092 |
| Radar | rdar://problem/58999133 |
| Original Reporter | @NevinBR |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
• Swift 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
• MacOS 10.14.6 (18G103)
I observe the same results in both:
• Xcode 11.3.1 playground for MacOS
• Swift REPL in Terminal
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Standard Library |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 977913cfdf8c4746de5a59c4a30a3555
Issue Description:
When values representing the same integer are stored as different types (whether integer or floating-point) then wrapped in AnyHashable, the resulting AnyHashable instances compare equal even though the underlying base types are different:
let a = AnyHashable(1)
let b = AnyHashable(1.0)
let c = AnyHashable(1 as UInt8)
(a == b, a == c, b == c) // (true, true, true)
type(of: a.base) == type(of: b.base) // false
type(of: a.base) == type(of: c.base) // false
type(of: b.base) == type(of: c.base) // falseMetadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrellaArea: Standard library umbrella