Skip to content

Commit 378d1f7

Browse files
authored
Merge pull request #322 from lewis6991/fix/debuglua
fix(std): debug.lua
2 parents bbfa649 + 4d38a23 commit 378d1f7

File tree

1 file changed

+37
-19
lines changed
  • crates/emmylua_code_analysis/resources/std

1 file changed

+37
-19
lines changed

crates/emmylua_code_analysis/resources/std/debug.lua

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ function debug.gethook(thread) end
6363
---@field ntransfer integer
6464
---@field activelines table
6565

66-
---@alias debuglib.Infowhat
67-
---|+"n" # `name` and `namewhat`
68-
---|+"S" # `source`, `short_src`, `linedefined`, `lastlinedefined`, and `what`
69-
---|+"l" # `currentline`
70-
---|+"t" # `istailcall`
71-
---|+"u" # `nups`, `nparams`, and `isvararg`
72-
---|+"f" # `func`
73-
---|+"r" # `ftransfer` and `ntransfer`
74-
---|+"L" # `activelines`
75-
7666
---
7767
--- Returns a table with information about a function. You can give the
7868
--- function directly, or you can give a number as the value of `f`,
@@ -93,13 +83,15 @@ function debug.gethook(thread) end
9383
--- with a name for the current function, if a reasonable name can be found,
9484
--- and the expression `debug.getinfo(print)` returns a table with all available
9585
--- information about the `print` function.
96-
---@overload fun(f: int|function, what?: debuglib.Infowhat):debuglib.DebugInfo
86+
---@overload fun(f: int|function, what?: string):debuglib.DebugInfo
9787
---@param thread thread
9888
---@param f function
99-
---@param what? debuglib.Infowhat
89+
---@param what? string
10090
---@return debuglib.DebugInfo
91+
---@nodiscard
10192
function debug.getinfo(thread, f, what) end
10293

94+
--- @version >5.2, JIT
10395
---
10496
--- This function returns the name and the value of the local variable with
10597
--- index `local` of the function at level `level f` of the stack. This function
@@ -120,23 +112,49 @@ function debug.getinfo(thread, f, what) end
120112
---
121113
--- The parameter `f` may also be a function. In that case, `getlocal` returns
122114
--- only the name of function parameters.
123-
---@overload fun(f:table, var:string):table
124-
---@param thread thread
125-
---@param f table
126-
---@param var? string
127-
---@return table
128-
function debug.getlocal(thread, f, var) end
115+
--- @overload fun(f: integer, integer): string?, any?
116+
--- @overload fun(f: function, integer): string?
117+
--- @overload fun(thread: thread, f: function, integer): string?
118+
--- @param thread thread
119+
--- @param f integer
120+
--- @param index integer
121+
--- @return string? name
122+
--- @return any? value
123+
--- @nodiscard
124+
function debug.getlocal(thread, f, index) end
125+
126+
--- @version 5.1
127+
---
128+
--- This function returns the name and the value of the local variable with
129+
--- index `index` of the function at level `level` of the stack. (The first
130+
--- parameter or local variable has index 1, and so on, until the last active
131+
--- local variable). The function returns **nil** if there is no local variable
132+
--- with the given index, and raises an error when called with a level out of
133+
--- range. (You can call `debug.getinfo` to check whether the level is valid.)
134+
---
135+
--- Variable names starting with `'('` (open parentheses) represent internal
136+
--- variables (loop control variables, temporaries, and C function locals).
137+
--- @overload fun(f: integer, integer): string, any
138+
--- @param thread thread
139+
--- @param lvl integer
140+
--- @param index integer
141+
--- @return string? name
142+
--- @return any? value
143+
--- @nodiscard
144+
function debug.getlocal(thread, lvl, index) end
129145

130146
---
131147
--- Returns the metatable of the given `value` or **nil** if it does not have
132148
--- a metatable.
133149
---@param value table
134-
---@return table
150+
---@return table?
151+
---@nodiscard
135152
function debug.getmetatable(value) end
136153

137154
---
138155
--- Returns the registry table.
139156
---@return table
157+
---@nodiscard
140158
function debug.getregistry() end
141159

142160
---

0 commit comments

Comments
 (0)