@@ -1572,6 +1572,48 @@ mod tests {
15721572 ) ,
15731573 ) ;
15741574 }
1575+
1576+ #[ test]
1577+ fn prune_regression_337_1 ( ) {
1578+ // Two values that differ only in padding bits are nonetheless equal
1579+ let ty_2x1_opt = Final :: sum (
1580+ Final :: unit ( ) ,
1581+ Final :: product ( Final :: two_two_n ( 0 ) , Final :: unit ( ) ) ,
1582+ ) ;
1583+
1584+ // L(ε) as all zeros
1585+ let mut iter = BitIter :: new ( Some ( 0b0000_0000u8 ) . into_iter ( ) ) ;
1586+ let value_1 = Value :: from_padded_bits ( & mut iter, & ty_2x1_opt) . unwrap ( ) ;
1587+ // L(ε) with a one in its padding bit
1588+ let mut iter = BitIter :: new ( Some ( 0b0100_0000u8 ) . into_iter ( ) ) ;
1589+ let value_2 = Value :: from_padded_bits ( & mut iter, & ty_2x1_opt) . unwrap ( ) ;
1590+
1591+ assert_eq ! ( value_1, value_2) ;
1592+ }
1593+
1594+ #[ test]
1595+ fn prune_regression_337_2 ( ) {
1596+ let ty_2x1_opt = Final :: sum (
1597+ Final :: unit ( ) ,
1598+ Final :: product ( Final :: two_two_n ( 0 ) , Final :: unit ( ) ) ,
1599+ ) ;
1600+ let ty_1x1_opt = Final :: sum ( Final :: unit ( ) , Final :: product ( Final :: unit ( ) , Final :: unit ( ) ) ) ;
1601+
1602+ // Bits [false, true] - first bit is false (left sum), second bit is true (unused padding)
1603+ let mut iter = BitIter :: new ( Some ( 0b0100_0000u8 ) . into_iter ( ) ) ;
1604+
1605+ // Parse as (2 × 1)? then prune to (1 × 1)?
1606+ let value = Value :: from_padded_bits ( & mut iter, & ty_2x1_opt) . unwrap ( ) ;
1607+ let pruned = value. prune ( & ty_1x1_opt) . unwrap ( ) ;
1608+
1609+ // Expected: L(ε) - still in the left (unit) branch
1610+ let expected = Value :: left ( Value :: unit ( ) , Final :: product ( Final :: unit ( ) , Final :: unit ( ) ) ) ;
1611+
1612+ // BUG: This fails because pruning incorrectly returns R((ε,ε)). We first compare string
1613+ // serializations since a direct comparison might only test `prune_regression_337_1`.
1614+ assert_eq ! ( pruned. to_string( ) , expected. to_string( ) ) ;
1615+ assert_eq ! ( pruned, expected) ;
1616+ }
15751617}
15761618
15771619#[ cfg( bench) ]
0 commit comments