Skip to content

Keep a TrieRefOwned valid at a location with nothing below it - #205

Open
imlvts wants to merge 1 commit into
Adam-Vandervorst:masterfrom
imlvts:fix/trie-ref-owned-empty-node
Open

imlvts wants to merge 1 commit into
Adam-Vandervorst:masterfrom
imlvts:fix/trie-ref-owned-empty-node

Conversation

@imlvts

@imlvts imlvts commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

TrieRefOwned::new_with_node_and_val_in(None, val, ..) returned an invalid ref and dropped val. None there means the location has no node below it, not that it doesn't exist. So TrieRefOwned::from / TrieRef::from a childless map reported path_exists() == false and lost its root value. Every write zipper's get_trie_ref() did the same at a childless focus, while the zipper itself reported the location and its value.

Give such a ref the empty node instead, keeping the value. Non-slim_ptrs builds fall back to an allocated empty node. WriteZipperCore::get_trie_ref now checks path_exists() first, since get_focus() is also None at a focus that doesn't exist, and that one must stay invalid.

TrieRefOwned::new_with_node_and_val_in(None, val, ..) returned an invalid ref
and dropped val.  None there means the location has no node below it, not that
it doesn't exist.  So TrieRefOwned::from / TrieRef::from a childless map
reported path_exists() == false and lost its root value.  Every write zipper's
get_trie_ref() did the same at a childless focus, while the zipper itself
reported the location and its value.

Give such a ref the empty node instead, keeping the value.  Non-slim_ptrs
builds fall back to an allocated empty node.  WriteZipperCore::get_trie_ref
now checks path_exists() first, since get_focus() is also None at a focus that
doesn't exist, and that one must stay invalid.
@imlvts
imlvts marked this pull request as ready for review November 30, 2026 08:21
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