Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't keel over on trivial Fnptr subtyping #804

Merged
merged 14 commits into from
Sep 17, 2024
4 changes: 4 additions & 0 deletions crates/flux-infer/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ impl Sub {
}
Ok(())
}
(BaseTy::FnPtr(sig_a), BaseTy::FnPtr(sig_b)) => {
assert_eq!(sig_a, sig_b);
Ok(())
}
_ => Err(query_bug!("incompatible base types: `{a:?}` - `{b:?}`"))?,
}
}
Expand Down
18 changes: 18 additions & 0 deletions tests/tests/pos/surface/fnptr00.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![allow(unused)]

type Binop = fn(i32, i32) -> i32;

struct Foo {
f: Binop,
}

// TODO: should actually support the below, not just leave it as `trusted`
#[flux::trusted]
fn bar(b: Binop) -> i32 {
b(3, 4)
}

fn test00(foo: Foo) -> i32 {
let x = bar(foo.f);
x
}
Loading