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

Parenthesised part of type mismatch error message sometimes prints back-to-front #11771

Closed
nmsmith opened this issue Jan 24, 2014 · 2 comments · Fixed by #18555
Closed

Parenthesised part of type mismatch error message sometimes prints back-to-front #11771

nmsmith opened this issue Jan 24, 2014 · 2 comments · Fixed by #18555
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@nmsmith
Copy link

nmsmith commented Jan 24, 2014

As the title says, the parenthesised part sometimes prints backwards. At least, I've found one case where it does - when one of the operands is a reference provided by an iterator:

Test code:

fn main() {
    let i: [int, ..5] = [0, ..5];
    let n = &i[0];

    // Error prints correctly
    1 + n;

    // Error prints backwards
    for v in i.iter() {
        1 + v;
    }
}

Result:

test.rs:8:6: 8:7 error: mismatched types: expected `<generic integer #3>`
but found `&int` (expected integral variable but found &-ptr)
test.rs:8   1 + n;
                ^
test.rs:12:7: 12:8 error: mismatched types: expected `<generic integer #4>`
but found `&int` (expected &-ptr but found integral variable)
test.rs:12      1 + v;
@ben0x539
Copy link
Contributor

Slightly more minimal test case:

fn main() {
    let x = ();
    // Error prints correctly
    1 + x;

    let x: () = ();
    // Error prints backwards
    1 + x;
}

Weird~

@nmsmith
Copy link
Author

nmsmith commented Jan 28, 2014

Ah, that's interesting. Then it seems the problem might be related to type inference. I'm not familiar enough with the compiler internals to investigate it myself though.

@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants