Repository navigation
fix(query): name trailing tokens instead of mislabeling as EOF - #1453
Conversation
…input as EOF The query parser classified a parse error as "unexpected end of input" whenever `found()` was `None`. But chumsky's `end()` combinator — which rejects leftover tokens after a valid prefix — also reports `found() == None`, so `SELECT … GROUP BY account WHERE …` and `SELECT account FOOBAR` were both labeled EOF even though the error span pointed at the real offending token (WHERE / FOOBAR). Classify by the error span instead: a position at or past the end of the input is a genuine EOF; otherwise name the unexpected token at that position. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates rustledger-query’s query parser error classification so trailing tokens after a valid query prefix are reported as unexpected tokens (e.g., WHERE, FOOBAR) instead of being mislabeled as an unexpected EOF, and adds a regression test for the behavior.
Changes:
- Adjusts EOF vs trailing-token detection by using the error span position relative to input length.
- Introduces a regression test asserting trailing tokens are named and that the error span points at the trailing token.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs main branch (2026-06-20)
What do these numbers mean?
|
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
CI clippy (--all-targets) flagged clippy::match_wildcard_for_single_variants in the new test; use a refutable let-else instead of a wildcard match arm. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Addresses Copilot on #1453: - Only disambiguate EOF-vs-trailing-token in the found()==None case; when chumsky reports a concrete token, keep its richer message (e.to_string()). - Rename the test to the test_ prefix used by the rest of the module. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Addressed both: the classifier now only special-cases the ambiguous |
What
The query parser reported "unexpected end of input" for any trailing tokens after a valid prefix:
The classifier used
e.found().is_none()to mean EOF — but chumsky'send()combinator (which rejects leftover tokens) also reportsfound() == None, so trailing tokens were mislabeled even though the error span pointed straight at them.How
Classify by the error span position instead: a position at or past the end of the input is a genuine EOF; otherwise name the unexpected token at that position.
Verify
Test
trailing_tokens_are_named_not_mislabeled_eof; fullrustledger-querysuite, clippy, fmt green.🤖 Generated with Claude Code