Skip to main content
Returns the upvalues captured by a closure or by a running stack frame, as a table.
New to upvalues? Learn more here.
Give it a number instead of a function and it reads a stack level, exactly like debug.getupvalue.
Most commonly used to snapshot a closure’s captured state in one call: find an unknown function with getgc, dump its upvalues, and read off the objects it is holding before touching it.

Parameters

Returns

{any} - an array-style table of the captured upvalues, in the order they were captured. A closure with no upvalues returns an empty table, never nil.

Aliases

  • getupvalues

Example

A closure with two upvalues, dumped with pairs:
Give it a number instead of a function and it reads a stack level, exactly like debug.getupvalue.