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

Improve compiler error and warning experience #218

Closed
perlun opened this issue Oct 12, 2021 · 0 comments
Closed

Improve compiler error and warning experience #218

perlun opened this issue Oct 12, 2021 · 0 comments
Labels
epic A feature being worked on during a long time
Milestone

Comments

@perlun
Copy link
Collaborator

perlun commented Oct 12, 2021

Moved to GitLab

Please continue to the new version of this issue here: https://gitlab.perlang.org/perlang/perlang/-/issues/218. The GitHub page you are currently reading will not contain the latest information on this issue.


Let's face it. The way we currently emit compiler warnings and errors is rather unsatisfactory. For example, a program like this (before #69 is fully implemented and hence, binary literals do not yet work):

var v = 0b00101010;

...yields the following output:

[line 1] Error at 'b00101010': Expect ';' after variable declaration.

While this works, it's not at all as pretty as it could be:

  • The exact (or at least approximate) column number could be included.
  • For some errors, the line number isn't even included. (I think this happens on runtime exceptions in "native" .NET code being called - this is in fact fine, we should be using a separate error handler for displaying runtime errors.)

What we should be aiming for

Contrast the above with the following Rust program. The program is invalid since there is no 0y-prefix supported by the language.

fn main() {
    let i: i32 = 0y1000000000000000000000000000000;
}

Here's the error message:

image

There are lots of nice things going on here:

  1. The exact line and colum is displayed, making it easy for the programmer to understand what's causing this.
  2. The source line is even included and printed out.
  3. The failing token is underlined to make it "almost impossible" to misunderstand what part of the line caused the issue.

We could pretty much aim for a 1-to-1 experience, similar to the above. For scanning-related bugs, this should be doable, but the further down the processing (the farther away from the source code reading you get), the more complex it will likely be to provide this kind of end-user experience.

It probably makes sense to aim for the "low-hanging fruit" first, i.e. make something reasonably close to the above for scanning-style errors. Then move further down the stack:

  • name resolving errors
  • type resolving errors
  • immutability errors
  • etc

Something like this. There's no rush; I'm more interested in us providing something great than this happening too quickly, with inferior end-user quality.

@perlun perlun added the epic A feature being worked on during a long time label Oct 12, 2021
@perlun perlun added this to the "Later" milestone Oct 12, 2021
@perlun perlun closed this as completed Aug 20, 2024
@perlang-org perlang-org locked as resolved and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
epic A feature being worked on during a long time
Projects
None yet
Development

No branches or pull requests

1 participant