Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add beautiful error messages. #900

Merged
merged 2 commits into from
Sep 30, 2023
Merged

Add beautiful error messages. #900

merged 2 commits into from
Sep 30, 2023

Conversation

dvander
Copy link
Member

@dvander dvander commented Sep 30, 2023

This is easy now that we have proper location encoding.

The current formatting is debatable, but it's a start.
Example:

test.sp(3) : error 017: undefined symbol "ham"
     3 |     int hello = ham;
-------------------------^

test.sp(4) : error 017: undefined symbol "hhello"
     4 |     return hhello
--------------------^

This requires implementing decoding of SourceLocation to line/col. In
the optimal case, where there are no errors, this has no effect other
than saving 4 bytes on every symbol allocation (of which there are
many). When there are errors, some mildly expensive decoding is needed.
@assyrianic
Copy link

how does this handle macros?

@dvander
Copy link
Member Author

dvander commented Sep 30, 2023

It'll point at the expansion location in the source. We can actually do much better, since we retain the expanded macro text, and column information within it. However, I don't think I'm going to actually make use of this.

Macros are really complicated, entirely unnecessary, and very expensive in both memory use and parsing time. To make things worse, the vast majority of uses are single token replacement, which doesn't benefit from any additional diagnostics. So basically they're bad in every single way and we'll all be better off by pretending they don't exist.

This is easy now that we have proper location encoding.

Example:

    test.sp(3) : error 017: undefined symbol "ham"
         3 |     int hello = ham;
    -------------------------^

    test.sp(4) : error 017: undefined symbol "hhello"
         4 |     return hhello
    --------------------^
@dvander dvander merged commit 0a3a81a into master Sep 30, 2023
19 checks passed
@dvander dvander deleted the sltl branch September 30, 2023 19:27
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.

2 participants