debug.getupvalues
C closures are not supported
This function will throw an error if called on a C closure, such as print
, for security reasons.
debug.getupvalues
returns a list of upvalues captured by a Luau function. These are the external variables that a function closes over from its surrounding scope.
If the function has no upvalues, the result will be an empty table.
Parameters
Parameter | Description |
---|---|
func |
The Lua function (or stack level) to retrieve upvalues from. |
Examples
Example 1
Retrieving upvalues from a closure | |
---|---|
Example 2
Calling with a function that has no upvalues | |
---|---|
Example 3
Calling on a C closure should error | |
---|---|