hydroflow
hydroflow copied to clipboard
spurious lattice type warnings on loops through `lattice_fold`
See the test case test_lattice_fold_loop
(from hydroflow/tests/surface_lattice_fold.rs
and pasted below.) It generates the following warning:
warning: Input to `union()` will be downcast to `None` to match other inputs.
--> hydroflow/tests/surface_lattice_fold.rs:42:16
|
42 | -> folder;
| ^^^^^^
- As a side note, the text of the warning is unhelpful. Wasn't clear to me that it was related to lattices at all.
fn test_lattice_fold_loop() {
let (output_send, output_recv) = hydroflow::util::unbounded_channel::<u8>();
let mut df = hydroflow_syntax! {
start = source_iter_delta([1])
-> map(Max::<u8>::new)
-> folder;
folder = union()
-> lattice_fold::<'static>(|| Max::<u8>::new(0))
-> cast(Some(Delta))
-> map(|x| Max::<u8>::new(x.into_reveal() + 1))
-> filter(|x| !x.is_top())
-> tee();
folder -> cast(Some(Delta)) -> folder;
folder
-> for_each(|v: Max<u8>| output_send.send(*v.as_reveal_ref()).unwrap());
};
df.run_tick();
assert_eq!(
&(2..=254).collect::<Vec<u8>>(),
&*collect_ready::<Vec<_>, _>(output_recv)
);
}