Skip to main content

MAX_INLINE_DEPTH

Constant MAX_INLINE_DEPTH 

Source
pub const MAX_INLINE_DEPTH: usize = 32;
Expand description

Hard ceiling on nested eval-time function inlining. The eval path walks a defun body inline for constant folding; a recursive defun whose recursion doesn’t fold to a base case (a runtime-arg call, or genuinely unbounded recursion) would otherwise recurse the compiler’s native stack until it overflows. This turns that into a structured compile error.

Set conservatively below the macro ceiling: an inline level is far heavier on the native stack than a macro-expansion level (it clones the table, binds params, and re-enters the full eval_value recursion through if/arithmetic/etc.), and compilation is not guaranteed to run on a large stack — empirically a default ~2 MiB thread overflows around ~64 inline levels. 32 leaves roughly a 2× native-stack margin while still allowing far deeper const-folded recursion than any realistic accounting script uses (the deepest legitimate cases are a handful of levels).