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

Line number off-by-1 in stack trace #17425

Open
armanbilge opened this issue May 6, 2023 · 3 comments
Open

Line number off-by-1 in stack trace #17425

armanbilge opened this issue May 6, 2023 · 3 comments
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug

Comments

@armanbilge
Copy link
Contributor

Compiler version

3.3.1-RC1-bin-20230504-0e00420-NIGHTLY

Minimized code

package com.example

object Bar {

  def void(): Unit =
    throw new Exception

  def main(args: Array[String]): Unit = {
    this
      .void() // this is line 10
  }
}

Output

Exception in thread "main" java.lang.Exception
        at com.example.Bar$.void(test.scala:6)
        at com.example.Bar$.main(test.scala:9)
        at com.example.Bar.main(test.scala)

Expectation

at com.example.Bar$.main(test.scala:9) would ideally be at com.example.Bar$.main(test.scala:10), right?

@armanbilge armanbilge added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 6, 2023
@som-snytt
Copy link
Contributor

Same backend behavior in Scala 2.

It's not off-by-one, but the whole tree gets the same line number.

thing
  .self
  .bomb()

@armanbilge
Copy link
Contributor Author

but the whole tree gets the same line number.

What is the "whole tree"? For example consider:

package com.example

object Bar {

  def self(x: Any): Bar.type =
    this

  def void(): Unit =
    throw new Exception

  def main(args: Array[String]): Unit = {
    this
      .self((x: Int) => x)
      .void() // this is line 14
  }
}
Exception in thread "main" java.lang.Exception
        at com.example.Bar$.void(test.scala:9)
        at com.example.Bar$.main(test.scala:13)
        at com.example.Bar.main(test.scala)

Why is the line number 13 and not 14 or 12?

@som-snytt
Copy link
Contributor

Loading any arg persuades it to emit a line, apparently. By whole tree, I meant the this.x.y application. I confirmed that javac does the obvious thing (complete line info).

@mbovel mbovel added area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants