Returns the constant table of target: the literal values the compiler baked into it, such as strings, numbers and booleans.
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.

Returns

table
An array of constants, indexed by slot.

Behavior

  • Some slots read as nil by design. Table and function constants, and genuine nils, are reported as nil rather than handed out, so the array can contain holes. Index it rather than relying on #.
  • Indices are compiler slots, not a count of the literals you wrote.

Example

Errors