closure type inference bug
Open
@philberty is already working on this.
Since Feb 3, 2024.
bug
typechecking
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
I tried this code: https://godbolt.org/z/aKPfG1Khf
#[lang = "sized"]
pub trait Sized {}
#[lang = "fn_once"]
pub trait FnOnce<Args> {
#[lang = "fn_once_output"]
type Output;
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}
pub fn test() {
let add: fn(&i32, &i32) -> i32 = |x, y| {
*x + *y
};
}
I expected to see this happen: compile without error
Instead, this happened:
x86-64 GCCRS (GCCRS master) - 579ms
<source>:15:16: error: expected reference type got T?
15 | *x + *y
| ^
<source>:15:21: error: expected reference type got T?
15 | *x + *y
| ^
<source>:15:16: error: cannot apply this operator to types <tyty::error> and <tyty::error>
15 | *x + *y
| ^
<source>:14:5: error: bounds not satisfied for fnptr (& i32 ,& i32 ,) -> i32 'FnOnce' is not satisfied [E0277]
14 | let add: fn(&i32, &i32) -> i32 = |x, y| {
| ^~~
Meta
- What version of Rust GCC were you using, git sha if possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.