Returns the constant in slot index of target.
Every function on this page is reachable both as debug.<name> and as a plain global of the same name, so debug.getupvalues(f) and getupvalues(f) are the same call.

Parameters

function | number
required
The function to inspect, or a stack level. Level 1 is your caller.
number
required
The constant slot, from 1 to the number of constants.

Returns

any
The constant, or nil for a table, function or nil slot.

Behavior

  • Out of range raises, while an in-range but unreadable slot returns nil. The two cases are distinguishable.

Example

Errors