Repository navigation
Conversation
A long sequence of comment lines inside [[ ... ]] could exhaust the call stack before reaching the expression. Scan those comments in a loop while keeping ordinary newline tokens, token offsets and pending heredocs intact. Add a 20,000-comment regression and preservation cases for CRLF, lexer windows, embedded hashes and heredocs. All 2,064 tests pass across the test files, along with build, typecheck, lint and formatting. The five focused tests also pass as compiled JavaScript on Node 20; the source tests ran on Node 24. Bash accepts and executes the same large input.
webpro
left a comment
There was a problem hiding this comment.
Thanks, Éverton! This is a legitimate robustness fix. Inside [[ ]] the lexer skips newlines in readNext, so every comment line added a frame, and main throws RangeError: Maximum call stack size exceeded from parse() somewhere between four and eight thousand consecutive comment lines inside one test command, while the same run of comments in normal mode parses fine. Bash accepts comments there, and the README promises a partial AST rather than an exception for excessive input, so this needs fixing even though no real script looks like that.
The loop is equivalent to the recursion where it matters: comments still stop at the newline, so normal mode keeps emitting the newline token and consuming pending heredocs there, test mode keeps skipping newlines, and EOF and CRLF behave as before; your tests cover each of those. Since readNext is the hottest function in the lexer, I benchmarked the branch against main on the README fixtures in isolated runs: throughput is unchanged within run-to-run spread. It merges cleanly with main and the full suite passes on the merged tree.
A long sequence of comment lines inside [[ ... ]] could exhaust the call stack before reaching the expression. Scan those comments in a loop while keeping ordinary newline tokens, token offsets and pending heredocs intact.
Add a 20,000-comment regression and preservation cases for CRLF, lexer windows, embedded hashes and heredocs. All 2,064 tests pass across the test files, along with build, typecheck, lint and formatting. The five focused tests also pass as compiled JavaScript on Node 20; the source tests ran on Node 24. Bash accepts and executes the same large input.