[SR-5521] elementsEqual doesn't work properly for Dictionary #48093
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Environment
Xcode Version 9.0 beta 3 (9M174d)
Additional Detail from JIRA
md5: 031153430bb6642d6654eb26a485b95f
Issue Description:
`elementsEqual` is defined for Dictionary but it appears not to be implemented correctly behind the scenes. Here's my test example:
When I test equality using `==`, I get `true`, the correct answer. But when I try to write my own test using `elementsEqual`, I get `false`, even though I am writing the equality test exactly as I believe `==` must be implementing it.
The problem appears to be that I am being handed the elements in order. But Dictionary elements have no order! I need to be handed only pairs whose keys are known to be hash-equivalent. To put it another way, I shouldn't need to compare keys at all, since keys are guaranteed equatable; I should need only to compare values. I did try that, but it didn't work either:
Thus I would suggest that `elementsEqual` should not even be defined for Dictionary, since it doesn't work properly — or, if it is defined then it should work.
Of course it's perfectly possible that I'm failing to understand what should happen here, so feel free to correct me.
The text was updated successfully, but these errors were encountered: