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

Improve error message when type is unknown #3723

Closed
bstrie opened this Issue Oct 11, 2012 · 9 comments

Comments

Projects
None yet
6 participants
@bstrie
Contributor

bstrie commented Oct 11, 2012

fn main() {
    1.bar();
}

Compiling this gives:

error: attempted access of field `bar` on type `<VI0>`, but no field or method with that name was found.

I'm guessing that the compiler hasn't inferred a type for <VI0>, but it should probably be more explicit about this fact rather than spitting out something that looks like a compiler error. Nothing fancy, it could just look like:

error: attempted access of field `bar` on type `<unknown integral type>`, but no field or method with that name was found.

(Here I'm presuming that a type like <VI0> is known to be integral, where this error occurs more generally it might say <V0>, which should simply become <unknown type>.)

If this can happen in other error messages it should be improved there as well.


Here's a test case with another error message that would likely be improved by the fixing this bug:

trait T {
    fn foo();
}

fn bar<V: T>(v: @V) {
    v.foo();
}

fn main() {
    bar(5);
}

Current output:

5124.rs:10:8: 10:9 error: mismatched types: expected `@<V0>` but found `<VI0>` (expected @-ptr but found integral variable)
5124.rs:10     bar(5);
                   ^

Suggested fixed output:

5124.rs:10:8: 10:9 error: mismatched types: expected `@<unknown type>` but found `<unknown integral type>` (expected @-ptr but found integral variable)
5124.rs:10     bar(5);
                   ^
@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Mar 25, 2013

Member

Not critical for 0.6; de-milestoning

Member

pnkfelix commented Mar 25, 2013

Not critical for 0.6; de-milestoning

@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism May 23, 2013

Contributor

Nominating for milestone 5, production-ready

Contributor

catamorphism commented May 23, 2013

Nominating for milestone 5, production-ready

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Jun 27, 2013

Member

accepted for production ready

Member

pnkfelix commented Jun 27, 2013

accepted for production ready

@bstrie

This comment has been minimized.

Show comment
Hide comment
@bstrie

bstrie Jul 2, 2013

Contributor

Updated with the test case for #5124.

Contributor

bstrie commented Jul 2, 2013

Updated with the test case for #5124.

@pcwalton

This comment has been minimized.

Show comment
Hide comment
@pcwalton

pcwalton Aug 26, 2013

Contributor

Triage bump

Contributor

pcwalton commented Aug 26, 2013

Triage bump

@mo

This comment has been minimized.

Show comment
Hide comment
@mo

mo Dec 25, 2013

Contributor

Another example is this snippet:

fn main() {
    let i = 1;
    if (i % 3 || i % 5)
    {
        println("hello");
    }
}

repro.rs:3:8: 3:22 error: binary operation || cannot be applied to type <VI0>

Ideal error imo would be:
repro.rs:3:8: 3:22 error: binary operation || cannot be applied to integral types

Contributor

mo commented Dec 25, 2013

Another example is this snippet:

fn main() {
    let i = 1;
    if (i % 3 || i % 5)
    {
        println("hello");
    }
}

repro.rs:3:8: 3:22 error: binary operation || cannot be applied to type <VI0>

Ideal error imo would be:
repro.rs:3:8: 3:22 error: binary operation || cannot be applied to integral types

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Jan 22, 2014

Member

we believe this is fixed, or at least the message quality has been improved.

Member

pnkfelix commented Jan 22, 2014

we believe this is fixed, or at least the message quality has been improved.

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Jan 22, 2014

Member

closing as believed to be fixed.

Member

pnkfelix commented Jan 22, 2014

closing as believed to be fixed.

@pnkfelix pnkfelix closed this Jan 22, 2014

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jan 22, 2014

Member

This appears fixed by #11513

Member

alexcrichton commented Jan 22, 2014

This appears fixed by #11513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment