Debug libraryReference
debug.getproto
Represents inspection of a function prototype.
Aliases
getprotoDetails#
Inspects a nested Luau prototype at a one-based index; parent may also be a positive active stack level. With active=false (the default), returns an inspection closure with prototype metadata, not the original executable body. With active=true, returns existing live closures that share the nested prototype; an empty table is valid. Native functions and invalid indices raise errors. getproto is an alias.
Signature#
debug.getproto(parent: function | number, index: number, active: boolean?): function | {function}Parameters#
| Parameter | Type | Description |
|---|---|---|
parent | function | number | Luau parent function or positive stack level. |
index | number | One-based immediate nested-prototype index. |
activeoptional | boolean | Find live matching closures; default false. |
Returns#
An inspection function, or an array of live closures when active=true.
Examples#
Example
local chunk = assert(loadstring("return function() return 42 end"))
local child = chunk() -- keep a live reference
local matches = debug.getproto(chunk, 1, true)
print(type(matches), type(child)) -- table function
for _, closure in ipairs(matches) do
print(closure == child)
end