Skip to content

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.

3 participants