Skip to main content

run_pending_finalizers_inner

Function run_pending_finalizers_inner 

Source
pub fn run_pending_finalizers_inner(
    state: &mut LuaState,
    propagate: bool,
) -> Result<(), LuaError>
Expand description

__gc driver that mirrors C-Lua’s GCTM(L, propagateerrors).

propagate corresponds to C’s propagateerrors argument. C calls GCTM(L, 1) from runafewfinalizers (the explicit-collect / automatic step paths) and GCTM(L, 0) from callallpendingfinalizers (the lua_close path). When a finalizer errors and propagate is set, the disposition is version-specific:

  • 5.2 / 5.3: wrap the error object as error in __gc metamethod (%s) (matching GCTM’s LUA_ERRGCMM branch) and re-throw, aborting the drain. Returned here as Err(LuaError) for the caller to propagate.
  • 5.4 / 5.5: luaE_warnerror(L, "__gc") — emit a warning and discard the error. The warning is silent unless the program enabled warnings (warn("@on")), which matches the reference default of swallowing __gc errors with warnings off.
  • 5.1: errors are silently swallowed (luaC_callGCTM ignores the status).

propagate = false (the close path) swallows the error on every version, matching callallpendingfinalizers’s GCTM(L, 0).