Honor set-multimap hash-collision node invariant during removals #42
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.
Context
Hash-collision nodes were able to underflow upon removals and store a single remaining (non-colliding) key. This violated the canonical representation assumption and led to erroneously skipping compaction. This PR adds invariant checking and ensures that invariants are honored during removals.
Triaging
With the information provided in #41, I was able to pinpoint the issue after attaching a debugger to the Rascal REPL and execute the provided equality comparison. It turned out that an invariant assertion was missing in the set-multi map (that was now inserted), although it was present in the set and map data types.
Once the invariant check was added, the property-based test suite flagged the invariant violation. Hence the coverage of generated inputs is sufficiently covers scenarios that elicit the behaviour reported in #41:
Validating
With the fix present in this PR, the property-based test suite does not show any invariant violations for set-multimap hash-collision nodes any more.