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

Can't infer the type of index #26735

Open
yongqli opened this issue Jul 2, 2015 · 4 comments
Open

Can't infer the type of index #26735

yongqli opened this issue Jul 2, 2015 · 4 comments
Labels
A-closures Area: Closures (`|…| { … }`) A-inference Area: Type inference C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@yongqli
Copy link

yongqli commented Jul 2, 2015

This doesn't type-check

fn main() {
    let m = [[0.; 2]; 2];
    println!("{}", (|i, j| m[i][j])(0, 1));
}

failing with

error[E0282]: type annotations needed
 --> inf.rs:3:28
  |
3 |     println!("{}", (|i, j| m[i][j])(0, 1));
  |                            ^^^^ cannot infer type

Annotating as usize fixes it, but I would expect the compiler to be able to infer the type. Is there a reason why it can't?

@bluss
Copy link
Member

bluss commented Jul 2, 2015

See also issue #12679

@steveklabnik steveklabnik added the A-type-system Area: Type system label Jul 2, 2015
@steveklabnik
Copy link
Member

Triage: No change.

@Mark-Simulacrum Mark-Simulacrum added the A-inference Area: Type inference label May 16, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: no changes

@Mark-Simulacrum Mark-Simulacrum added A-closures Area: Closures (`|…| { … }`) and removed A-type-system Area: Type system labels Aug 31, 2019
@Spoonbender
Copy link

triage: no change

@fmease fmease added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) A-inference Area: Type inference C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants