[SR-8672] Hashable struct in function #51186
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
conformances
Feature → protocol: protocol conformances
duplicate
Resolution: Duplicates another issue
nested types
Feature: nested types
operators
Feature: operators
type checker
Area → compiler: Semantic analysis
unexpected behavior
Bug: Unexpected behavior or incorrect output
Additional Detail from JIRA
md5: 7b3ca9a11387440e866eac5a2c2b0cdc
relates to:
Issue Description:
Link to Swift forum discussion : link
Hello ! I would like to have some clarifications about why
Set
does not interact properly with aHashable
struct declared in a function.Here I have a struct
Hello
that conforms toHashable
and only needs itsid
for thehashValue
. Because structs need to haveEquatable
custom conformance to have custom hash behavior, so a==
function is declared.I first declare a
Set
with an identifier123
and the I try to insert another struct having the same identifier with different "value". It does not insert the new element because it is considered as the same by the equality.Here I have a struct
Hello
that conforms toHashable
and only needs itsid
for thehashValue
and it is declared in a function. The struct is the same as the previous example but it does not work, the set keep inserting it while theid
is the same. The custom comparison operand is not used so I suspect that the default implementation is called instead.The text was updated successfully, but these errors were encountered: