Skip to content

Fix #327: grow parser statement arrays instead of silently truncating - #342

Merged
InauguralPhysicist merged 1 commit into
mainfrom
fix-327-stmt-cap
Jul 1, 2026
Merged

Fix #327: grow parser statement arrays instead of silently truncating#342
InauguralPhysicist merged 1 commit into
mainfrom
fix-327-stmt-cap

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

Summary

  • parse() and parse_block silently dropped statements past a fixed 4096 cap (program level: tail never ran, rc=0; block level: a big define lost its return and yielded null)
  • Both statement arrays now grow on demand; blocks no longer preallocate 32KB each (~8MB reserved at max nesting before)
  • MAX_STMTS removed from eigenscript.h (parser was its only user)

Closes #327.

Removing the cap exposed a pre-existing O(n²) compile cost on programs with many unique module-scope names — filed separately as #341 (normal and single-name generated programs unaffected).

Validation

  • New suite section [111] test_stmt_cap.eigs: 4200-statement program + 4200-statement function body run in full (both silently truncated before); 40ms
  • Original repros verified: 100k-statement program now runs every statement; 4100-statement block returns 4099 instead of null
  • Release suite 2350/2350; ASan+UBSan detect_leaks=1 2350/2350, leak tally 0

🤖 Generated with Claude Code

parse() and parse_block stored statements into fixed 4096-entry arrays
and silently discarded everything past the cap — a 100k-statement
program executed only its first 4096 statements and exited 0; a define
body past the cap lost its return and yielded null. Both arrays now
grow on demand (and blocks no longer preallocate 32KB each — 256-deep
nesting used to reserve ~8MB).

Removing the cap exposes a pre-existing quadratic compile cost on
programs with tens of thousands of unique module-scope names (NameSet
linear-scan dedup) — filed as #341; single-name programs are linear.

Regression: suite [111] test_stmt_cap.eigs (4200-statement program and
block run in full, 40ms). Release + ASan(detect_leaks=1) 2350/2350,
leak tally 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@InauguralPhysicist
InauguralPhysicist merged commit e472b6c into main Jul 1, 2026
13 checks passed
@InauguralPhysicist
InauguralPhysicist deleted the fix-327-stmt-cap branch July 1, 2026 23:07
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.

MAX_STMTS (4096) silently truncates programs and blocks — tail statements dropped, rc=0

1 participant