Debug

getupvalue

Reads an upvalue from a function by one-based index.

Syntax

getupvalue(target: function | integer, index: number | integer): any
Aliases debug.getupvalue

Arguments

NameTypeDescription
targetfunction | integerFunction, stack level, or prototype to inspect.
indexnumber | integerOne-based index inside constants, protos, upvalues, or stack slots.

Returns

NameTypeDescription
upvalueanyUpvalue at the requested index.

Description

Reads an upvalue from a function by one-based index.

Call it with 2 parameter(s): target, index. The argument table explains which values are required and which ones only refine the behavior.

It returns upvalue (any). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getupvalue(1, 1)
print(result)