Skip to content

Wrong vertical error ranges #7028

Closed
Closed
@odersky

Description

@odersky

minimized code

object Test {
  "abc"
    .foo

  "abc"
    .bar.baz

  "abc"
    .bar
    .baz
}

Output

-- [E008] Member Not Found Error: test.scala:2:2 -------------------------------
2 |  "abc"
  |  ^
  |  value foo is not a member of String - did you mean String("abc").+?
3 |    .foo
-- [E008] Member Not Found Error: test.scala:5:2 -------------------------------
5 |  "abc"
  |  ^
  |  value bar is not a member of String - did you mean String("abc").+?
-- [E008] Member Not Found Error: test.scala:8:2 -------------------------------
8 |  "abc"
  |  ^
  |  value bar is not a member of String - did you mean String("abc").+?
9 |    .bar
three errors found

The first and third error messages are as expected, but the second is not: it strips the interesting part, namely .bar from the output.

Comparing 2nd and 3rd error points to a possible cause: When displaying multi-line errors, it seems the last line is dropped unless it forms part of the error range in its entirety.

Expectation

The last line should never be dropped if it contains tokens. Ideally, if only a part of the last line forms part of the error range, that part should be indicated with horizontal markers. I.e. something like this:

5 |  "abc"
  |  ^
  |  value bar is not a member of String - did you mean String("abc").+?
     .bar.baz
     ^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions