Skip to content

Conversation

juleswritescode
Copy link
Collaborator

@juleswritescode juleswritescode commented Oct 12, 2025

Currently, if you type select case in a file, the LSP will crash.

The reason is that we forgot to handle the EOF token in the case() function in the splitter.

I feel that, since we deal with incomplete statements all the time, it's better to bubble up an Err if we reach EOF:

  • it's an unrecoverable error and should immediately stop splitting
  • this way, we'll never forget adding the EOF to any statement again

But it's a bit invasive, so WDYT?

(Pretty sure this fixes #540, it's the same kind of error)

Comment on lines -153 to -156
p.advance();
break;
}
SyntaxKind::EOF => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: we do not need to handle EOF below anymore

Copy link
Collaborator

@psteinroe psteinroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! maybe we could add our own Result type that always returns the eof error to make sure we don't accidentally bubble up another error and handle it in the wrong way?

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.

pgt_statement_splitter error

2 participants