If a function is a single line long and encounters an error, the stacktrace will depict the actual function's details instead of the function which actually errored.
function ramGet16(addr)
return bit.bor( bit.lshift(RAM[addr] , 8), RAM[addr + 1])
end
Hook 'tick' errored with: SF:chip8.txt:223: bad argument #2 to 'ramGet16' (number expected, got nil)
stack traceback:
[C]: in function 'ramGet16'
SF:chip8.txt:223: in function 'emulate'
SF:chip8.txt:165: in function <SF:chip8.txt:155>
Whereas the expected result
function ramGet16(addr)
local val = bit.bor( bit.lshift(RAM[addr] , 8), RAM[addr + 1])
return val
end
Hook 'tick' errored with: SF:chip8.txt:205: bad argument #2 to 'bor' (number expected, got nil)
stack traceback:
[C]: in function 'bor'
SF:chip8.txt:205: in function 'ramGet16'
SF:chip8.txt:224: in function 'emulate'
SF:chip8.txt:165: in function <SF:chip8.txt:155>
In the first, the error is occurring in "bor" but it's instead reporting ramGet16
If a function is a single line long and encounters an error, the stacktrace will depict the actual function's details instead of the function which actually errored.
Whereas the expected result
In the first, the error is occurring in "bor" but it's instead reporting ramGet16