Closed clarkeaa closed 6 months ago
This works fine if you run the program with fennel
:
$ fennel /tmp/scratch.fnl
runtime error: hi
stack traceback:
[C]: in function 'error'
/tmp/scratch.fnl:4: in function ?
[C]: in function 'xpcall'
/home/phil/bin/fennel:6409: in function ?
[C]: in ?
If you want to run it specifically from Lua, you need to either enable correlate
mode, or use fennel.traceback
to get the line numbers instead of using the default traceback.
require("fennel").install().dofile("main.fnl", {correlate=true})
https://fennel-lang.org/api#get-fennel-aware-stack-traces
local fennel = require("fennel").install()
xpcall(function() fennel.dofile("scratch.fnl") end,
function() print(fennel.traceback()) end)
Both these solutions will get you correct line numbers.
FWIW running through fennel
isn't an option since I'm using raylib-lua
and the entrypoint is hardcoded to be a lua file.
This is a simple reproduction of the problem I run into which is making working with fennel very difficult. I haven't seen line numbers ever correct. The names of the functions in the frames are correct though.
reproduction
run.lua:
main.fnl
invocation:
fennel version
1.4.0
output
Notice that it says the error was on line 2 but it was called on line 4.