@@ -40,9 +40,11 @@ function debug.getfenv(o) end
4040--- Returns the current hook settings of the thread, as three values: the
4141--- current hook function, the current hook mask, and the current hook count
4242--- (as set by the `debug.sethook` function).
43- --- @overload fun (): thread
43+ --- @overload fun (): function ?, string , integer
4444--- @param thread thread
45- --- @return thread
45+ --- @return function ? hook
46+ --- @return string mask
47+ --- @return integer count
4648function debug .gethook (thread ) end
4749
4850--- @class debuglib.DebugInfo
@@ -65,7 +67,7 @@ function debug.gethook(thread) end
6567
6668--- @alias debuglib.InfoWhat
6769--- |+ " n" # `name`, `namewhat`
68- --- |+ " S" # `source`, `short_src`, `linedefined`, `lalinedefined `, `what`
70+ --- |+ " S" # `source`, `short_src`, `linedefined`, `lastlinedefined `, `what`
6971--- |+ " l" # `currentline`
7072--- |+ " t" # `istailcall`
7173--- |+ " u" # `nups`, `nparams`, `isvararg`
@@ -177,8 +179,8 @@ function debug.getregistry() end
177179--- no known names (variables from chunks saved without debug information).
178180--- @param f function
179181--- @param up integer
180- --- @return string name
181- --- @return any value
182+ --- @return string ? name
183+ --- @return any ? value
182184--- @nodiscard
183185function debug .getupvalue (f , up ) end
184186
@@ -254,12 +256,12 @@ function debug.sethook(thread, hook, mask, count) end
254256--- raises an error when called with a `level` out of range. (You can call
255257--- `getinfo` to check whether the level is valid.) Otherwise, it returns the
256258--- name of the local variable.
257- --- @overload fun ( level : integer , var : string , value : any ): string
259+ --- @overload fun ( level : integer , var : string , value : any ): string ?
258260--- @param thread thread
259261--- @param level integer
260262--- @param var string
261263--- @param value any
262- --- @return string
264+ --- @return string ?
263265function debug .setlocal (thread , level , var , value ) end
264266
265267---
@@ -279,7 +281,7 @@ function debug.setmetatable(value, meta) end
279281--- @param f fun (): any
280282--- @param up integer
281283--- @param value any
282- --- @return string
284+ --- @return string ?
283285function debug .setupvalue (f , up , value ) end
284286
285287--- Sets the given `value` as the `n`-th associated to the given `udata`.
@@ -289,22 +291,40 @@ function debug.setupvalue(f, up, value) end
289291--- @param udata userdata
290292--- @param value any
291293--- @param n integer
292- --- @return userdata
294+ --- @return userdata ?
293295function debug .setuservalue (udata , value , n ) end
294296
295- --- Generates a traceback of the call stack.
296- --- When called with no arguments, returns a traceback of the current thread.
297- --- When the first argument is a thread, the traceback is generated for that thread;
298- --- the optional second argument (if a string) is prepended to the traceback, and the
299- --- optional third argument sets the level where the traceback should start (default is 1).
300- --- When the first argument is not a thread and not nil, it is treated as an optional message.
301- --- In that case, the traceback is generated for the current thread and the second argument,
302- --- if provided, specifies the starting level.
297+ --- @version 5.1
298+ ---
299+ --- Returns a string with a traceback of the call stack. An optional message
300+ --- string is appended at the beginning of the traceback. An optional level
301+ --- number tells at which level to start the traceback (default is 1, the
302+ --- function calling traceback).
303+ --- @overload fun (): string
304+ --- @overload fun ( message ?: string , level ?: integer ): string
305+ --- @param thread ? thread
306+ --- @param message ? string
307+ --- @param level ? integer
308+ --- @return string
309+ function debug .traceback (thread , message , level ) end
310+
311+ --- @version > 5.2
312+ ---
313+ --- If message is present but is neither a string nor nil, this function
314+ --- returns message without further processing. Otherwise, it returns a string
315+ --- with a traceback of the call stack. The optional message string is appended
316+ --- at the beginning of the traceback. An optional level number tells at which
317+ --- level to start the traceback (default is 1, the function calling traceback).
318+ --- @generic T
303319--- @overload fun (): string
304320--- @overload fun ( message ?: string , level ?: integer ): string
305- --- @param thread ? thread | integer Optional thread or nil. If not a thread , it is interpreted as the message.
306- --- @param message ? string Optional message to prepend to the traceback. If not a string (or nil ), it is returned as is.
307- --- @param level ? integer Optional level from which to start the traceback (default is 1 ).
321+ --- @overload fun ( message : T , level ?: integer ): T
322+ --- @overload fun ( thread : thread ): string
323+ --- @overload fun ( thread : thread , message ?: string , level ?: integer ): string
324+ --- @overload fun ( thread : thread , message : T , level ?: integer ): T
325+ --- @param thread ? thread
326+ --- @param message ? string | T
327+ --- @param level ? integer
308328--- @return string
309329function debug .traceback (thread , message , level ) end
310330
0 commit comments