Skip to content

Commit

Permalink
Don't keel over on trivial Fnptr subtyping (#804)
Browse files Browse the repository at this point in the history
* blerp

* temp checkin

* temp checkin

* add fnptr test
  • Loading branch information
ranjitjhala authored Sep 17, 2024
1 parent eaf52f0 commit 9b8b4a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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
}

0 comments on commit 9b8b4a9

Please sign in to comment.