debug.setname
Sets the debug name of a function.
Syntax
debug.setname(fn: function, name: string) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | function | The function or callback to use. |
name | string | The name used for the lookup or new object. |
Returns
| Type | Description |
|---|---|
nil | This function does not return a value. |
Description
debug.setname 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.
The aliases setname(fn, name) resolve to the same implementation.
Example
local fn = function() end
debug.setname(fn, "CustomName")
print(debug.info(fn, "n"))
Notes
- Aliases:
setname(fn, name). - Writing protos, constants or upvalues can corrupt a running function; test changes carefully.