0

If I make mistakes in a Lua script and I call it from a .tex file via

\luadirect{
    dofile("myscript.lua")
}

then I get a full stacktrace in the output of lualatex-compiler:

myscript.lua:3: attempt to compare nil with number
stack traceback:
    myscript.lua:3: in function 'expected_number'
    myscript.lua:9: in function 'fn2'
    myscript.lua:13: in main chunk
    [C]: in function 'dofile'
    [\directlua]:1: in main chunk.

But if I call script from a console with

$ texlua myscript.lua
myscript.lua:3: attempt to compare nil with number

I just get the last entry of the error. How can I call texlua that it prints all entries in stacktrace out?

-- myscript.lua
function expected_number(x)
    if x == 0 then return 0 end
    if x < 0 then return -1 end
    if x > 0 then return  1 end
end


function fn2(n)
    local m = expected_number(n)
end

local y
fn2(y)
2
  • do you mean \directlua rather than \luadirect? Commented 2 hours ago
  • it is odd that it behaves as a standalone lua when called via \directlua, but not when called as texlua or with --luaonly. Commented 1 hour ago

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.