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
3.3.0, 3.3.1-RC4 (but seems to be true for all Scala 3 versions, although I haven't checked them exhaustively)
Minimized code
objectReproduction:defmethod():Int=varx=3vary=2whiletruedoif x < y then// always false because x and y are not modified below, PLACE BREAKPOINT ON THIS LINEif x >= y then
x +=1else
y -=1// stepping over with the debugger claims to stop on this line end while5endmethoddefmain(args: Array[String]):Unit=
println(method())
endReproduction
The combination of while loop, if statement in the body of the loop and no other code following the if statement in the while loop body triggers wrong debugging information to be emitted by the compiler. This is verified by using the step over functionality of both the IntelliJ debugger and the Metals debugger. Both debuggers stop on the y -= 1 line, but this line is never really executed in the code, which is confirmed when looking at the local variables which correctly don't change.
Modifying the code to:
objectReproduction:defmethod():Int=varx=3vary=2whiletruedoif x < y then// always false because x and y are not modified below, PLACE BREAKPOINT ON THIS LINEif x >= y then
x +=1else
y -=1
println("Hello")
end while5endmethoddefmain(args: Array[String]):Unit=
println(method())
endReproduction
results in correct stepping through in the debugger.
Output
Video of the IntelliJ debugger:
Screen.Recording.2023-07-18.at.12.59.47.mov
Video of the Metals debugger, same behavior:
Screen.Recording.2023-07-18.at.13.01.12.mov
Expected output
The debugger doesn't stop on the y -= 1 line, because the program never executes that statement.
If we don't, the code generated for the `else` branch remains
associated with the last instruction of the `then` branch, which
yields to confusing debugging sessions.
Compiler version
3.3.0, 3.3.1-RC4 (but seems to be true for all Scala 3 versions, although I haven't checked them exhaustively)
Minimized code
The combination of
while
loop,if statement
in the body of the loop and no other code following the if statement in the while loop body triggers wrong debugging information to be emitted by the compiler. This is verified by using the step over functionality of both the IntelliJ debugger and the Metals debugger. Both debuggers stop on they -= 1
line, but this line is never really executed in the code, which is confirmed when looking at the local variables which correctly don't change.Modifying the code to:
results in correct stepping through in the debugger.
Output
Video of the IntelliJ debugger:
Screen.Recording.2023-07-18.at.12.59.47.mov
Video of the Metals debugger, same behavior:
Screen.Recording.2023-07-18.at.13.01.12.mov
Expected output
The debugger doesn't stop on the
y -= 1
line, because the program never executes that statement.Original sighting of the bug
https://www.youtube.com/watch?v=hs_NdVjnO9U
The text was updated successfully, but these errors were encountered: