rust's `#[derive(DisjointUnion)]` derives incorrect bottom and top. · Issue #25 · facebook/SPARTA · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "bottom" element of a Lattice is the identity element of the "join" operation.
The "top" element of a Lattice is the identity element of the "meet" operation.
But when using the #[derive(DisjointUnion)] macro, I can create elements for which x.clone().join(bottom) != x and x.clone().meet(top) != x.
Reproducible Example
These tests should pass:
use sparta::datatype::PatriciaTreeSetAbstractDomain;use sparta::datatype::DisjointUnion;#[derive(Debug,Clone,PartialEq,Eq,DisjointUnion)]enumX{A(PatriciaTreeSetAbstractDomain<u32>),B(PatriciaTreeSetAbstractDomain<u32>),}#[test]fntest_bottom_is_identity_element_of_join_operation(){letmut b = X::B(PatriciaTreeSetAbstractDomain::Value(Default::default()));let b2 = b.clone();
b.join_with(X::bottom());assert_eq!(b, b2);}#[test]fntest_top_is_identity_element_of_meet_operation(){letmut b = X::B(PatriciaTreeSetAbstractDomain::Value(Default::default()));let b2 = b.clone();
b.meet_with(X::top());assert_eq!(b, b2);}
Hey @kaidaniel, thank you for finding the bug. Since you have the solution, do you want to create a PR to fix this? You can also add your example to a test.
If you intend to do that, a small suggestion is to incorporate the two if statements into the pattern matching here.
The "bottom" element of a Lattice is the identity element of the "join" operation.
The "top" element of a Lattice is the identity element of the "meet" operation.
But when using the
#[derive(DisjointUnion)]
macro, I can create elements for whichx.clone().join(bottom) != x
andx.clone().meet(top) != x
.Reproducible Example
These tests should pass:
but they fail with the following error message:
Solution
replace
SPARTA/rust-proc-macros/src/lib.rs
Lines 87 to 99 in bd758a8
The text was updated successfully, but these errors were encountered: