Skip to content

Panic: assertion failed: start.raw <= end.raw on a WITH followed by a blank line and an indented CTE #785

Description

@edjubert

Describe the bug

check panics on a valid query when a WITH keyword is followed by a blank line and
the CTE definition is indented. The panic aborts the whole run, so a single file of this
shape stops check from finishing over a directory.

This is the same assertion as the already-closed #303, but a different trigger, and it
reproduces on 0.25.7.

To Reproduce

repro.sql (4 lines, note the leading whitespace on line 3):

WITH

 x AS (SELECT 1 AS a)
SELECT x.a FROM x;
$ postgres-language-server check repro.sql
Encountered an unexpected error

Source Location: crates/pgls_text_size/src/range.rs:50:9
Thread Name: main
Message: assertion failed: start.raw <= end.raw

Both conditions are required. Removing either one avoids the panic:

Input Result
WITH + blank line + indented CTE (tab, 1 space or 4 spaces) panic
WITH + blank line + unindented CTE no panic
WITH + no blank line + indented CTE no panic

Expected behavior

No panic. A diagnostic is fine, a crash is not, especially since it terminates the run
and leaves the remaining files unchecked.

System information

  • postgres-language-server 0.25.7
  • macOS (aarch64), release binary postgres-language-server_aarch64-apple-darwin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions