First of all, thank you for creating this amazing library!
When exploring the codebase, I found that hashValues are used in comparison in a few places. This seems a logic error: x == y implies x.hashValue == y.hashValue, but not the other way around. Therefore, using hashValue in comparison, technically speaking, is not reliable because of potential hash collision.
I understand that in many cases, we are comparing two hash value generated by SwiftState classes, and hash collision is unlikely/impossible. However, the concrete Event/State types will be implemented by the client (user of SwiftState), so there is no way to guarantee that hash collision won't happen.
I have removed all occurrences of comparison of hashValues, and reimplemented them using plain old pattern matching. Please let me know your thoughts on this.
Hi @inamiy,
First of all, thank you for creating this amazing library!
When exploring the codebase, I found that
hashValue
s are used in comparison in a few places. This seems a logic error:x == y
impliesx.hashValue == y.hashValue
, but not the other way around. Therefore, usinghashValue
in comparison, technically speaking, is not reliable because of potential hash collision.I understand that in many cases, we are comparing two hash value generated by SwiftState classes, and hash collision is unlikely/impossible. However, the concrete Event/State types will be implemented by the client (user of SwiftState), so there is no way to guarantee that hash collision won't happen.
I have removed all occurrences of comparison of
hashValue
s, and reimplemented them using plain old pattern matching. Please let me know your thoughts on this.