Skip to content

fix(parse): name an unrecognized statement in strict mode - #344

Merged
tiagolauer merged 1 commit into
masterfrom
fix/303-unrecognized-statement
Aug 2, 2026
Merged

fix(parse): name an unrecognized statement in strict mode#344
tiagolauer merged 1 commit into
masterfrom
fix/303-unrecognized-statement

Conversation

@tiagolauer

Copy link
Copy Markdown
Owner

Fixes #303.

The bug

StrictRow<DB, 'truncate users'>       // never
StrictRow<DB, 'selct id from users'>  // never - a keyword typo
StrictRow<DB, ''>                     // never

Failing loudly is right. The message is the problem — and on the version the issue was filed against it was QueryTypeError<'unknown table: ''>, which names no table and points a selct typo at entirely the wrong layer. The [never] guard from #275 has since turned that into a bare never, which is honest but still explains nothing.

The fix

Strict mode reports QueryTypeError<'unsupported or unrecognized statement'>, in the same shape as the multiple-statements error the parser already produces.

Loose mode keeps returning never rather than degrading into { [x: string]: unknown }, which is what #275 deliberately put in place — a query the parser cannot read should not come back looking like a successful parse.

Verification

tests/unrecognized-statement.test-d.ts, nine cases. Four red on master:

tests/unrecognized-statement.test-d.ts(18,3): error TS2344: Type 'false' does not satisfy the constraint 'true'.
tests/unrecognized-statement.test-d.ts(22,34): ...
tests/unrecognized-statement.test-d.ts(24,33): ...
tests/unrecognized-statement.test-d.ts(27,3): ...
  • truncate users, the selct typo and the empty query, through both StrictRow and StrictQuery
  • loose mode pinned as never

Controls: a plain SELECT, an UPDATE with RETURNING, the stacked-statement error, and loose mode on a valid query are all unchanged.

tsc --noEmit clean, 192 runtime tests pass, budget 191,574 (912 below master — the strict branch replaces work the never path was doing downstream).

    StrictRow<DB, 'truncate users'>       // was never
    StrictRow<DB, 'selct id from users'>  // was never
    StrictRow<DB, ''>                     // was never

Failing is right - there is no row to produce - but `never` explains
nothing, and the reported symptom was worse: before the #275 guard landed,
the never flowed into StarRow/FirstUnknownTable and came out as
`unknown table: ''`, a message naming no table and pointing a keyword typo
at entirely the wrong layer.

Strict mode now reports `unsupported or unrecognized statement`, alongside
the multiple-statements error that already reads this way. Loose mode keeps
returning never rather than degrading into an index signature, which is what

Fixes #303

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tiagolauer
tiagolauer force-pushed the fix/303-unrecognized-statement branch from 8d6ee75 to ab7d2e4 Compare August 2, 2026 13:04
@tiagolauer
tiagolauer merged commit affcb1e into master Aug 2, 2026
12 checks passed
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.

Unrecognized statements produce an empty-name strict error message

1 participant