pub fn max_parse_recursion() -> usizeExpand description
The parse-time recursion budget: an EIGHTH of the AST limit (min the floor).
The parser’s own descent is BY FAR the fattest stack consumer — each parenthesis level re-enters the whole precedence/condition chain — so it gets a much tighter budget than the built-tree limit. The number that matters is the ratio between one level’s frame and the smallest stack the parser must survive on:
| measured | value |
|---|---|
| one level of descent, debug build (2026-09) | ~64 KiB |
| smallest stack the gate is tested on | 2 MiB |
| levels before the real stack dies | 32 |
| this budget at the default limit | 16 |
The budget must fire BEFORE the stack dies, or the guard is decorative: a SIGABRT is
exactly the crash it exists to prevent. It was a QUARTER of the limit, which put it at 32 —
the cliff itself, with no margin — so any growth of the descent’s frame turned a graceful
rejection into a stack overflow, and one did. An eighth spends half the stack instead of
all of it, which is room for the parser to keep growing.
Still scales with LOGOS_MAX_AST_DEPTH: raising it asserts a deeper stack, and raises both
together as before.