It's a bug, only print(3) once.
$ luac -l test.lua
main <test.lua:0,0> (12 instructions at 00000000007d1dc0)
0+ params, 2 slots, 1 upvalue, 0 locals, 3 constants, 0 functions
1 [1] LOADBOOL 0 1 0
2 [1] TEST 0 1
3 [1] JMP 0 4 ; to 8
4 [4] JMP 0 7 ; to 12
5 [5] GETTABUP 0 0 -1 ; _ENV "print"
6 [5] LOADK 1 -2 ; 2
7 [5] CALL 0 2 1
8 [7] GETTABUP 0 0 -1 ; _ENV "print"
9 [7] LOADK 1 -3 ; 3
10 [7] CALL 0 2 1
11 [7] JMP 0 -8 ; to 4 -- should be JMP 0 -9, to 3
12 [9] RETURN 0 1
if true then
print(1)
goto LBL
::loop::
print(2)
::LBL::
print(3)
goto loop
end
It's correct , infinite loop.
$ luac -l test.lua
main <test.lua:0,0> (12 instructions at 00000000007f1dc0)
0+ params, 2 slots, 1 upvalue, 0 locals, 4 constants, 0 functions
1 [2] GETTABUP 0 0 -1 ; _ENV "print"
2 [2] LOADK 1 -2 ; 1
3 [2] CALL 0 2 1
4 [2] JMP 0 3 ; to 8
5 [5] GETTABUP 0 0 -1 ; _ENV "print"
6 [5] LOADK 1 -3 ; 2
7 [5] CALL 0 2 1
8 [7] GETTABUP 0 0 -1 ; _ENV "print"
9 [7] LOADK 1 -4 ; 3
10 [7] CALL 0 2 1
11 [7] JMP 0 -7 ; to 5
12 [9] RETURN 0 1