Skip to content

fix(diagnostics): prevent panics in indented multiline frames - #791

Open
edjubert wants to merge 2 commits into
supabase-community:mainfrom
edjubert:edjubert/diagnostic-frame-indent-panic
Open

fix(diagnostics): prevent panics in indented multiline frames#791
edjubert wants to merge 2 commits into
supabase-community:mainfrom
edjubert:edjubert/diagnostic-frame-indent-panic

Conversation

@edjubert

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

Rendering a multiline syntax diagnostic can panic when its span ends at column zero
of an indented line.

This happens with a WITH statement followed by a blank line and an indented CTE.

Fixes #785.

What is the new behavior?

Both diagnostic frame renderers clamp the last-line marker start to the span end
before constructing the range.

The CLI now reports the syntax diagnostic normally instead of panicking.

Additional context

Regression coverage includes:

  • generic diagnostic frame rendering
  • the original CLI reproduction with an indented CTE after a blank line

Validation:

  • cargo test -p pgls_diagnostics
  • cargo test -p pgls_cli check_indented_cte_after_blank_line_does_not_panic
  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings

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.

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

1 participant