Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patricia tree: Enforce use of smart constructors (fixes bug) #507

Merged
merged 1 commit into from
Jun 29, 2021

Conversation

lukemaurer
Copy link

There was a case in merge' where we were failing to use the branch
smart constructor, sometimes causing an invalid branch node where both
subtrees were empty. This was causing spurious invariant failures
because equal map1 map2 was false even though both map1 and map2
were empty.

This fixes the bug, and also tries to prevent future bugs by hiding the
Branch constructor in a sub-module, enforcing the use of the branch
smart constructor, which checks each argument for emptiness. Also added
branch_non_empty to skip the check when the arguments are provably
both not empty (for instance, in add).

There was a case in `merge'` where we were failing to use the `branch`
smart constructor, sometimes causing an invalid branch node where both
subtrees were empty. This was causing spurious invariant failures
because `equal map1 map2` was false even though both `map1` and `map2`
were empty.

This fixes the bug, and also tries to prevent future bugs by hiding the
`Branch` constructor in a sub-module, enforcing the use of the `branch`
smart constructor, which checks each argument for emptiness. Also added
`branch_non_empty` to skip the check when the arguments are provably
both not empty (for instance, in `add`).
@lukemaurer lukemaurer merged commit d1828d4 into flambda2.0-stable Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants