setstackhidden
Hides a function or a numeric stack level from Acedia's traceback and getfenv reporting.
Marks a target as hidden from supported stack walks so Acedia utilities skip over it. The target can be a function or a numeric stack level. hidden defaults to true; passing false removes the target from the hidden set.
A hidden function is removed from every frame it occupies, not from a specific level. Visible-level numbering closes over hidden frames: once a function is hidden, level 2 from inside its callee no longer points at it but at whatever called it.
Affects:
| Reader | Behavior |
|---|---|
debug.info(level, ...) | Resolves level against the visible stack. |
debug.traceback | Hidden frames do not appear in the output. |
getfenv(level) | Resolves level against the visible stack. |
error(msg, level) | Position info is formatted from the visible frame at level. |
Does not remove a frame from execution. The hidden function still runs and still receives its arguments.
setstackhidden(target: ((...any) -> ...any) | number, hidden: boolean?): ()Parameters
| Parameter | Type | Description |
|---|---|---|
target | function or number | A function to hide wherever it appears, or a non-negative stack level. |
hidden | boolean? | true adds the target to the hidden set, false removes it. Defaults to true. |
Errors: target must be a function or a non-negative integer; a negative level raises an error.
Example
local function Caller()
return debug.traceback():find("Caller") ~= nil
end
print(Caller()) -- true
setstackhidden(Caller, true)
print(Caller()) -- false, Caller no longer appears in the traceback
setstackhidden(Caller, false)
print(Caller()) -- true, hidden flag clearedExample output
true
false
true