fix: stop treating an embedded NUL as end of input - #6
Merged
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
blotus
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5
nextBy/lookAheadreturned rune0past the end andisEOFtestedch == 0, so a literal NUL in the input was indistinguishable from end-of-input and every!isEOF(ch)scan loop stopped at the first one, dropping the rest with no token and no error.Took direction 1 (sentinel
rune(-1), which decoding can never produce): it keeps the existing "the rune the loop already carries decides" shape for a 3-line change, where deriving EOF from the cursor also means reorderingScan's switch, sincepeekstill has to return something no rune predicate matches orscanUnknownspins atcursor == len. A NUL now falls through toUNKNOWNand scanning continues, matching\x01/\x1f/\x7f.Tests: NUL mid-statement, first, last, alone, repeated, and inside each of the four scan loops (string literal, quoted identifier, line comment, block comment), plus an equivalence test that a NUL lexes exactly like the other control bytes. Existing suite passes unchanged; I also diffed this build against
mainover 139k real NUL-free queries (all threesqlprocessormodes) and 200k generated hostile ones across five dialects — byte-identical.🤖 Generated with Claude Code