[SR-13794] AnyHashable can become nested unexpectedly when a generic type is specialized with an AnyHashable #56191
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Environment
Xcode 12.0.1 (12A7300)
Swift 5.3
MacOS 10.15.7 (19H2)
Additional Detail from JIRA
md5: 51b4efcf2c28e45704e2c7537e05b3db
Issue Description:
With the following code
The output is unexpectedly the following:
In the first case with S<AnyHashable> there are two layers of nested AnyHashable in a.erasedID, which results in a.id not being equal to a.erasedID. This is unexpected behavior, and intuitively as a language consumer you would not expect AnyHashables to be possible to double-box like this.
In the second case with S<E>, it functions as expected, with b.id equal to b.erasedID.
You can fix this behavior by updating the `erasedID` to the following, but it feels like something that the language should handle automatically:
The text was updated successfully, but these errors were encountered: