Skip to content

stage2: Unify compiler error printing #9117

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

Merged
merged 2 commits into from
Jun 18, 2021

Conversation

greenfork
Copy link

Fixes #8872

This introduces the following limitations on printing function in main.zig:

  • Always prints to stderr, can't print to file now
  • Tilde printing ~~~~ is no more, it always points to an error with a caret ^

I tested it with zig ast-check on this file:

const std = @import("std");

pub fn main() !void {
    const a = true && false;
}

and it correctly produces:

error.zig:4:23: error: `&&` is invalid; note that `and` is boolean AND
    const a = true && false;
                      ^

with previous being:

error.zig:4:23: error: `&&` is invalid; note that `and` is boolean AND
    const a = true && false;
                      ~~~~~

Dmitry Matveyev added 2 commits June 14, 2021 22:09
Compilation.AllError.Message interface does not provide configurable
file handle. And since all uses of this function only use stderr,
this can be added later.
@LemonBoy
Copy link
Contributor

with previous being:

Having the error messages highlight the whole span makes them much clearer IMO.

@greenfork
Copy link
Author

Having the error messages highlight the whole span makes them much clearer IMO.

I agree with that. Would you suggest to change this behavior in this PR? This looks like a separate scope and will likely affect all the errors, not just the errors from main.zig. I can create an issue and a follow-up pull request to change it, or I can do it in the current PR.

@LemonBoy
Copy link
Contributor

Would you suggest to change this behavior in this PR?

Whatever you're more comfortable with, this PR looks ready to merge so making a follow-up one is fine.

@greenfork
Copy link
Author

Alright, thank you! I would rather make a follow-up pull request after this one is merged.

@andrewrk andrewrk merged commit b9e7859 into ziglang:master Jun 18, 2021
@andrewrk
Copy link
Member

Nice work 👍

The tilde thing is going to be fun. I suspect it will be non-trivial.

@greenfork greenfork deleted the unify-compiler-error-printing branch June 18, 2021 04:15
andrewrk added a commit that referenced this pull request Jun 20, 2021
greenfork pushed a commit to greenfork/zig that referenced this pull request Jun 22, 2021
Error refactoring in ziglang#9117 removed this style from main.zig file.
This commit adds it back and in addition to all other possible
compiler errors.
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.

unify the two ways that compile errors get printed to stderr
3 participants