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

Duplicate bytecode in line number table #15107

Closed
adpi2 opened this issue May 5, 2022 · 1 comment
Closed

Duplicate bytecode in line number table #15107

adpi2 opened this issue May 5, 2022 · 1 comment

Comments

@adpi2
Copy link
Member

adpi2 commented May 5, 2022

Compiler version

3.1.2

Minimized code

package example

class A {
  def bar: Unit = {
    println("bar")
  }
}

Output

  public void bar();
    Code:
       0: getstatic     #18                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
       3: ldc           #19                 // String bar
       5: invokevirtual #23                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
       8: return
    LineNumberTable:
      line 4: 0
      line 5: 0
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0       9     0  this   Lexample/A;

Expectation

The LineNumberTable should only contain line 5: 0
Or it should contain line 4: 0 and line 5: 3

@adpi2 adpi2 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 5, 2022
@nicolasstucki nicolasstucki removed the stat:needs triage Every issue needs to have an "area" and "itype" label label May 17, 2022
@nicolasstucki
Copy link
Contributor

These are the position of the trees in genBCode

package example@<1> {
  class A extends Object {
    def <init>(): Unit =
      {
        super@<3>@<3>()@<3>
        ()@<3>
      }@<3>
    @<4>
    def bar(): Unit =
      {
        println@<5>("bar"@<5>)@<5>
      }@<4>
    @<4>
  }@<3>
}@<1>

It is probably an issue in the backend.

sjrd added a commit to dotty-staging/dotty that referenced this issue Feb 2, 2023
There was already some deduplication code to avoid consecutive
`LineNumber` nodes. However, it can happen that `LabelNode`s
appear in-between. In that case, we also want to deduplicate the
`LineNumber`s, since labels do not actually contribute to the
final bytecode.
@sjrd sjrd closed this as completed in b9b3ed5 Feb 3, 2023
sjrd added a commit that referenced this issue Feb 3, 2023
…6813)

There was already some deduplication code to avoid consecutive
`LineNumber` nodes. However, it can happen that `LabelNode`s appear
in-between. In that case, we also want to deduplicate the `LineNumber`s,
since labels do not actually contribute to the final bytecode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants