Skip to content

Conversation

LeonMatthes
Copy link
Contributor

Previously, diagnostics only indicated the first character of a warning/error.
While this is often sufficient, in many cases it leads to ambiguity as to what exactly causes the error.

This patch updates the Span type to add a length field and exposes this data to the diagnostic builder in the compiler and lsp.

The patch is only large, as the syntax tests all needed to be updated. This was done via the automatic update mechanism.
The actual code changes are pretty straight-forward.

⚠️ I have not updated the ranges on the existing diagnostics. They mostly seem to make sense, but some suboptimal behavior is possible. Let me know if I should update some of the spans to make them fit better.

Also let me know whether the new syntax of > < for the syntax tests is acceptable.

Compiler Diagnostics

Before:

warning: Expression has no effect!
  --> noops.slint:42:9
   |
42 |         true && false;
   |         ^

After:

warning: Expression has no effect!
  --> noops.slint:44:9
   |
44 |         true && false;
   |         ^^^^^^^^^^^^^

LSP (Screenshots from NVIM)

Before:
image

After:
image

This allows diagnostics to cover not just a single character, but the
entire relevant code region.

ChangeLog: Diagnostics now indicate the range of the error/warning, not just the starting character
If the end of a diagnostic falls on a newline CR of a CRLF, it should
cover the entire CRLF, not just the CR.
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.

1 participant