You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scala 3.3.0 (and also in Scala 2.12.18 and Scala 2.13.11)
Minimized code
@main
defmain():Unit= {
valx=123
}
Output
Compiled from "main.scala"
public final class main$package$ implements java.io.Serializable {
public static final main$package$ MODULE$;
private main$package$();
Code:
0: aload_0
1: invokespecial #13 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this Lmain$package$;
public static {};
Code:
0: new #2 // class main$package$
3: dup
4: invokespecial #16 // Method "<init>":()V
7: putstatic #18 // Field MODULE$:Lmain$package$;
10: return
LineNumberTable:
line 1: 0
private java.lang.Object writeReplace();
Code:
0: new #22 // class scala/runtime/ModuleSerializationProxy
3: dup
4: ldc #2 // class main$package$
6: invokespecial #25 // Method scala/runtime/ModuleSerializationProxy."<init>":(Ljava/lang/Class;)V
9: areturn
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 10 0 this Lmain$package$;
public void main();
Code:
0: bipush 123
2: istore_1
3: return
LineNumberTable:
line 2: 0 <------------ this line is also possibly not necessary (not visible in the next bytecode dump below)
line 3: 0
line 4: 3 <----------- this line is not necessary, line 4 is a closing bracket
LocalVariableTable:
Start Length Slot Name Signature
3 1 1 x I
0 4 0 this Lmain$package$;
}
Here's how this line manifests in the debugger. The behavior is the same in Metals.
Screen.Recording.2023-08-01.at.12.12.47.mov
Expectation
The debug information line 4 is not generated. For comparison, if we omit the curly braces and use the braceless syntax:
@main
defmain():Unit=valx=123
the same debug line is not generated.
Compiled from "main.scala"
public final class main$package$ implements java.io.Serializable {
public static final main$package$ MODULE$;
private main$package$();
Code:
0: aload_0
1: invokespecial #13 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this Lmain$package$;
public static {};
Code:
0: new #2 // class main$package$
3: dup
4: invokespecial #16 // Method "<init>":()V
7: putstatic #18 // Field MODULE$:Lmain$package$;
10: return
LineNumberTable:
line 1: 0
private java.lang.Object writeReplace();
Code:
0: new #22 // class scala/runtime/ModuleSerializationProxy
3: dup
4: ldc #2 // class main$package$
6: invokespecial #25 // Method scala/runtime/ModuleSerializationProxy."<init>":(Ljava/lang/Class;)V
9: areturn
LineNumberTable:
line 1: 0
LocalVariableTable:
Start Length Slot Name Signature
0 10 0 this Lmain$package$;
public void main();
Code:
0: bipush 123
2: istore_1
3: return
LineNumberTable:
line 3: 0 <--------------- only 1 debug line, both the line above and below were not generated
LocalVariableTable:
Start Length Slot Name Signature
3 1 1 x I
0 4 0 this Lmain$package$;
}
The text was updated successfully, but these errors were encountered:
Synthetic `()` values are added to blocks without an expression. Don't
emit a line number for them.
Implemented by checking the `SyntheticUnit` attachment. This seems
simpler than trying to control the position assigned to synthetic unit
trees, as they are created in many places.
Fixes#18320. Forward port of
scala/scala#10577
This ticket is the Scala 3 equivalent of scala/bug#12835.
Compiler version
Scala 3.3.0 (and also in Scala 2.12.18 and Scala 2.13.11)
Minimized code
Output
Here's how this line manifests in the debugger. The behavior is the same in Metals.
Screen.Recording.2023-08-01.at.12.12.47.mov
Expectation
The debug information
line 4
is not generated. For comparison, if we omit the curly braces and use the braceless syntax:the same debug line is not generated.
The text was updated successfully, but these errors were encountered: