Fixed LogicValue
hash and equality inconsistency by forcing construction consistency
#217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description & Motivation
Bug #206 found that the
hashCode
of equalLogicValue
s might not be equal.Upon deeper inspection, sometimes equivalent
LogicValue
s with different internal representations would be non-equal.An initial thought was to make
hashCode
and==
more consistent between different underlying implementations ofLogicValue
, but instead this PR forces a consistent path for constructingLogicValue
s.Each value can now only be represented by one of the types:
_SmallLogicValue
,_BigLogicValue
, or_FilledLogicValue
._FilledLogicValue
must be.Assertions have been added to enforce these rules. With this guarantee, the hash and equality code did not need much update to consider alternative representations for the same value, though there were some small changes required for 0-width.
Additionally, the PR in this work revealed some corner-case bugs. Code coverage is incomplete on the different implementations and should be cleaned up since some bugs have been hiding for quite a while.
Related Issue(s)
Fix #206
Testing
Backwards-compatibility
No
Documentation
No