debug.setinfo

Changes selected debug metadata on a Luau function or proto.

Syntax

debug.setinfo(func_or_level: function | number | ProtoProxy, info: table) -> ()

Parameters

ParameterTypeDescription
func_or_levelfunction, stack level, or ProtoProxyLuau proto to modify
infotableMetadata fields to assign

Supported Fields

FieldTypeDescription
sourcestringFull source identifier
short_srcstringReplacement source identifier that preserves a leading = or @ marker
namestringFunction debug name
currentlinenumberFunction definition line

If both source and short_src are present, source takes precedence.

Example

local function example()
    return true
end

debug.setinfo(example, {
    source = "@custom/example.luau",
    name = "renamed_example",
    currentline = 25,
})

local info = debug.getinfo(example)
print(info.source) -- @custom/example.luau
print(info.name) -- renamed_example
print(info.currentline) -- 25

Notes

  • C closures are rejected