Skip to content

Prune by whether the focus exists, not by whether its node is empty - #206

Draft
imlvts wants to merge 1 commit into
Adam-Vandervorst:masterfrom
imlvts:fix/prune-empty-node-stumps
Draft

imlvts wants to merge 1 commit into
Adam-Vandervorst:masterfrom
imlvts:fix/prune-empty-node-stumps

Conversation

@imlvts

@imlvts imlvts commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

prune_path_internal started pruning wherever the node holding the focus was empty. That gave two wrong answers when a dangling path is held as an empty node:

  • A pruning remove at a focus that doesn't exist removed the dangling parent above it, because the missing focus is inside that empty node too. This happens below a stump a ZipperHead writer leaves, and below what an empty graft_masked_branches leaves. Below an ordinary dangling path the same remove does nothing, which is what the docs say: prune = true is the remove with prune = false followed by prune_path.
  • A dangling tip held as a link to an empty node wasn't pruned, because the node holding the link isn't empty. A ZipperHead leaves such a node at a leaf head root after splitting it off for a read zipper, so remove() left the location dangling.

remove_val, remove_branches, remove_subtrie and remove_unmasked_branches now prune only when the focus exists on entry. prune_path_internal also starts at a valueless link to an empty node.

prune_path_internal started pruning wherever the node holding the focus was
empty.  That gave two wrong answers when a dangling path is held as an empty
node:

- A pruning remove at a focus that doesn't exist removed the dangling parent
  above it, because the missing focus is inside that empty node too.  This
  happens below a stump a ZipperHead writer leaves, and below what an empty
  graft_masked_branches leaves.  Below an ordinary dangling path the same
  remove does nothing, which is what the docs say: prune = true is the
  remove with prune = false followed by prune_path.
- A dangling tip held as a link to an empty node wasn't pruned, because the
  node holding the link isn't empty.  A ZipperHead leaves such a node at a
  leaf head root after splitting it off for a read zipper, so remove() left
  the location dangling.

remove_val, remove_branches, remove_subtrie and remove_unmasked_branches now
prune only when the focus exists on entry.  prune_path_internal also starts at
a valueless link to an empty node.
@imlvts
imlvts marked this pull request as ready for review November 30, 2026 20:38
@imlvts
imlvts marked this pull request as draft December 1, 2026 23:03
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.

1 participant