flux-rs / flux

Refinement Types for Rust
MIT License
633 stars 17 forks source link

bug: function closure pointer parameter #697

Open Samir-Rashid opened 1 month ago

Samir-Rashid commented 1 month ago

The following cause Flux to crash on latest Flux & fixpoint.

pub fn foo<F>(f: F)
where
    F: Fn(u32) -> bool,
{
    if f(0) {
        println!("Hello");
    }
}

pub fn foo2(f: impl Fn(u32) -> bool) {
    if f(0) {
        println!("Hello");
    }
}
error: internal compiler error: crates/flux-refineck/src/checker.rs:678:41: expected discr

thread 'rustc' panicked at crates/flux-common/src/bug.rs:75:49:
Box<dyn Any>

I believe function pointers fn are unsupported by flux (f: fn(u32) -> bool), but these closures (Fn, FnMut) cause Flux to crash.

nilehmann commented 2 weeks ago

This is no longer crashing after the hack implemented in https://github.com/flux-rs/flux/pull/736. We should still find the root cause and implement a proper fix.