Skip to content

fix(syntax): accept function calls nested up to 256 deep - #234

Merged
kvlonge merged 1 commit into
mainfrom
fix/function-call-depth
Nov 15, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/function-call-depth

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Why

The complexity guard refused function calls nested more than 64 deep, but Snowflake's receipts show it parsing ABS, COALESCE and arithmetic nested 100 deep, so valid statements were refused (two receipts were listed as disagreements).

Changes

  • fix(syntax): the default function-call depth limit is 256, the limit the shared parse layer already uses. Deeper nesting is still refused with E_GUARD_FUNCTION_NESTING_DEPTH_EXCEEDED.
  • The depth probe gains an analysed construct of nested calls, so parsing plus analysis of them is held to the probe's time bound.
  • The two resolved ABS and COALESCE entries leave receipt-disagreements.toml.

Verification

  • A guard test parses 256 nested calls and refuses 257; the 256 case fails on the previous limit.
  • make depth-probe (gate) and make depth-probe-debug (dev): every construct in every native parser is clean on a 2 MiB thread, including the new analysed construct within its 500 ms bound.
  • Stack: the parser grows its stack on demand (stacker, a default feature in every build including the wheel). A dev build parses 256 nested calls on a 64 KiB thread, so a Windows main thread or the Python caller's thread does not bound the new depth. On wasm the parser depth guard (32) still caps recursion.
  • syntax-coverage diff exits 0; make check-ci passes on the final head.

The complexity guard refused function calls nested more than 64 deep,
while Snowflake parses ABS, COALESCE and arithmetic nested 100 deep, so
valid statements were refused. The default limit is now 256, the limit
the shared parse layer already uses, and deeper nesting is still refused
with the guard's function nesting error.

The depth probe parses nested calls on a 2 MiB thread in every native
parser and profile, and a new analysed construct holds parsing and
analysis of nested calls to the probe's time bound. The parser grows its
stack on demand, so the caller's thread size, including a Windows main
thread or the Python wheel's, does not bound the new depth; on wasm the
parser depth guard still caps recursion.

The ABS and COALESCE receipts this resolves leave the disagreement list.
@kvlonge
kvlonge enabled auto-merge November 15, 2026 02:36
@kvlonge
kvlonge added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit a236172 Nov 15, 2026
9 checks passed
@kvlonge
kvlonge deleted the fix/function-call-depth branch November 15, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant