lua-users home
lua-l archive

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


I have problems using debug.traceback() with level but without message argument.
The reference manual seems to indicate that both arguments are optional:

    debug.traceback ([thread,] [message] [, level])

But the following script demonstrates that it seems impossible to use debug.traceback() this way:

------8<------
#!/usr/bin/env lua

local c = coroutine.create( function() coroutine.yield() end )
coroutine.resume(c)

print( "()\n",debug.traceback() )
print( "('msg')\n",debug.traceback('msg') )
print( "(2)\n",debug.traceback(2) )
print( "('msg',2)\n",debug.traceback('msg',2) )
print( "(nil,2)\n",debug.traceback(nil,2) )
print( "(c)\n",debug.traceback(c) )
print( "(c,'msg')\n",debug.traceback(c,'msg') )
print( "(c,1)\n",debug.traceback(c,1) )
print( "(c,'msg',1)\n",debug.traceback(c,'msg',1) )
print( "(c,nil,1)\n",debug.traceback(c,nil,1) )
------8<------

Output:

------8<------
()
        stack traceback:
        ./traceback.lua:6: in main chunk
        [C]: ?
('msg')
        msg
stack traceback:
        ./traceback.lua:7: in main chunk
        [C]: ?
(2)
        2
stack traceback:
        ./traceback.lua:8: in main chunk
        [C]: ?
('msg',2)
        msg
stack traceback:
        [C]: ?
(nil,2)
        nil
(c)
        stack traceback:
        [C]: in function 'yield'
        ./traceback.lua:3: in function <./traceback.lua:3>
(c,'msg')
        msg
stack traceback:
        [C]: in function 'yield'
        ./traceback.lua:3: in function <./traceback.lua:3>
(c,1)
        1
stack traceback:
        [C]: in function 'yield'
        ./traceback.lua:3: in function <./traceback.lua:3>
(c,'msg',1)
        msg
stack traceback:
        ./traceback.lua:3: in function <./traceback.lua:3>
(c,nil,1)
        nil
------8<------

Is this a issue with the reference manual or with the implementation?

Thanks,
   Jörg