Skip to content

Introduce a T_err type for type errors #1871

Closed
@catamorphism

Description

@catamorphism
fn main() {
  let f = 42;

  let _g = if f < 5 {
      f.honk();
  }
  else {
    12
  };
}

If I compile this code, I get two error messages for (basically) the same span:

/Users/TimChevalier/silly.rs:5:6: 5:12 error: attempted access of field honk on type int, but no method implementation was found
/Users/TimChevalier/silly.rs:5       f.honk();
                                     ^~~~~~
/Users/TimChevalier/silly.rs:5:6: 5:14 error: mismatched types: expected function or native function but found ()
/Users/TimChevalier/silly.rs:5       f.honk();
                                     ^~~~~~~~

This kind of thing gets annoying fast. Would it be reasonable to only print an error message for the smallest sub-span when there are multiple error messages such that one span encloses the other? (In this case, the spans aren't exactly the same, but we should see the first error and realize "oh, we don't need to print out the second error, since its span is a superspan of the other")

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions