lua-users home
lua-l archive

default stack trace function

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi.
I noticed something that seems strange to me when using the error
function with an error level parameter.
Consider the following piece of code:
p3 = function()
 error("the error",3)
end
p2 = function()
 p3()
end
p1 = function()
 p2()
end
luaf = function(d)
 print(d)
 p1()
 return "the result"
end
print(luaf("ha!"))
-- END OF CODE
Running the lua 5 interpreter with this file gives the following stack trace:
lua5: stacktrace.lua:10: the error
stack traceback:
 [C]: in function `error'
 stacktrace.lua:2: in function `p3'
 stacktrace.lua:6: in function `p2'
 stacktrace.lua:10: in function `p1'
 stacktrace.lua:15: in function `luaf'
 stacktrace.lua:19: in main chunk
 [C]: ?
The line where the error happened seems correct. (line 10, the call to
p2() in p1 body)
Shouldn't the stack trace omit the lines for error levels 1 and 2?
(line 2 and 6, respectively)
-- Fred

AltStyle によって変換されたページ (->オリジナル) /