islclosure
Returns whether the given function is a Luau closure.
function islclosure(func: function): booleanSynopsis
How it works
Checks the
isC byte in the closureClosureA function value that captures its lexical environment. In Luau, closures come in two types: LClosure (Luau bytecode + Proto + upvalues) and CClosure (native C function pointer + upvalues).'s ClosureHeader:
typedef struct ClosureHeader {
CommonHeader; // GC header
uint8_t isC; // 0 = LClosure, 1 = CClosure
uint8_t nupvalues;
...
} ClosureHeader;
Returns true if isC == 0 (Luau closure with bytecodeBytecodeThe compiled binary representation of Luau source code. A sequence of 32-bit instructions (opcodes + operands) stored in a Proto's code[] array. Executed by the Luau VM interpreter. Proto). newcclosure-wrapped functions return false even though their inner function may be Luau, because the outer wrapper is a C closure. This is the inverse of iscclosure().Usage
Check closure type
print(islclosure(function() end)) "cc">--> true
print(islclosure(print)) "cc">--> falseParameters
func function The function to inspect.
Returns
boolean true if the function is a Luau closure.