debug.setinfo
Updates a function debug name, source and linedefined from a table.
Syntax
debug.setinfo(fnOrLevel: function | number, info: any) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
fnOrLevel | function | number | The fn or level value used by the call. |
info | any | The info value used by the call. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
debug.setinfo is part of the Debug library. The debug library exposes the internals of the active Luau state, including protos, constants, upvalues and stack frames.
The change is applied directly to the live target, so later reads observe the updated value.
Example
local fn = function() end
debug.setinfo(fn, { name = "Custom", source = "@custom", linedefined = 10 })
Notes
- Writing protos, constants or upvalues can corrupt a running function; test changes carefully.