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

stack reports wrong function information #903

Open
XAYRGA opened this issue May 18, 2020 · 1 comment
Open

stack reports wrong function information #903

XAYRGA opened this issue May 18, 2020 · 1 comment

Comments

@XAYRGA
Copy link
Contributor

XAYRGA commented May 18, 2020

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

@thegrb93
Copy link
Owner

thegrb93 commented Mar 2, 2021

@XAYRGA This might be why, tail calls don't use stack. https://www.lua.org/pil/6.3.html

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

2 participants