debug.getinfo

Inspects a function or stack frame.

Syntax

Signature
debug.getinfo(FunctionOrLevel: function | number) -> table

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
FunctionOrLevelfunction | numberFunction to inspect or a positive stack level.

Returns

TypeDescription
tableFunction metadata and the function itself in func.

Notes

Returns source, short_src, what, name, linedefined, currentline, nups, numparams, is_vararg, and func for a function or positive stack level. is_vararg is stored as a number. Invalid levels raise an error.

Example

Luau
local Result = debug.getinfo(function() return 42 end)
print(Result)