Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/line_list_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,11 @@ fn merge_guts<'a, V: Clone + Lattice + Send + Sync, A: Allocator, const ASLOT: u
(true, true) => { //both are child nodes, so join them
let a_child = unsafe{ a.child_in_slot::<ASLOT>() };
let b_child = unsafe{ b.child_in_slot::<BSLOT>() };
return a_child.pjoin(b_child).map(|new_child| (a_key, ValOrChild::Child(new_child)))
return match a_child.pjoin(b_child) {
//Two empty children are both just the dangling path
AlgebraicResult::None => AlgebraicResult::Identity(SELF_IDENT | COUNTER_IDENT),
joined => joined.map(|new_child| (a_key, ValOrChild::Child(new_child))),
}
},
(false, false) => { //both are values, so join them
let a_val = unsafe{ a.val_in_slot::<ASLOT>() };
Expand Down Expand Up @@ -3984,4 +3988,20 @@ mod tests {
m.write_zipper().restrict(&o.read_zipper());
assert_eq!(keys(&m), ["bx"]);
}

/// Joining two nodes whose children under the same key are both empty
#[test]
fn merge_empty_children_under_same_key() {
let node = || {
let mut n = LineListNode::<u64, GlobalAlloc>::new_in(global_alloc());
let child = LineListNode::<u64, GlobalAlloc>::new_in(global_alloc());
unsafe { n.set_child_0(&[0, 3], TrieNodeODRc::new_in(child, global_alloc())); }
n
};
let (a, b) = (node(), node());
match merge_list_nodes(&a, &b) {
Ok(AlgebraicResult::Identity(mask)) => assert_eq!(mask, SELF_IDENT | COUNTER_IDENT),
_ => panic!("expected an identity"),
}
}
}