Uh oh!
There was an error while loading. Please reload this page.
stage2: Add "tilde pointing" to errors for multi-character offenses - #9201
stage2: Add "tilde pointing" to errors for multi-character offenses#9201greenfork wants to merge 1 commit into
Conversation
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.
Here's a fun test case, how does this look? test {
constx: i32=1;
consty: i32=1;
foo(x+y);
}
fnfoo(x: bool) void {
_=x;
}Related: test {
constx: i32=1;
consty: i32=1;
foo(x+// x is the first operandy// y is the second operand
);
}
fnfoo(x: bool) void {
_=x;
}I have a feeling tilde pointing is going to be a bit more complicated than this implementation. We might want to enable it on a per-error-message basis. |
greenfork
commented
Jun 23, 2021
Thank you for these counter-examples. Funnily enough they produce same error which also doesn't work as expected: and if I change it to use pub fn main then these errors: So yes, this looks like a lot more work to do. I think I don't have enough understanding to implement it. I will try to come up with a list of questions and maybe attend a weekly stage 2 meeting. |
andrewrk
commented
Jun 23, 2021
Ah the instructions for running the example would be: |
greenfork
commented
Jun 24, 2021
More on formatting:
Examples from gcc and clang for multiline errors: |
greenfork
commented
Jun 25, 2021
I will close this PR for now as it appears quite complex. I don't know whether there should be an issue created or there will be a more broad RFC-like issue such as "friendlier errors" so I will leave it as is. |
Error refactoring in #9117 removed this style from main.zig file. This commit adds it back and in addition to all other possible compiler errors.
I added the
lexeme_lengthtoCompilation.AllErrors.Messagein order to get more reliable data where it can be done. As an alternative we can use a similar approach as forCompilation.AllErrors.addfor all errors sinceMessagehas bothsource_lineandcolumnpresent. But it doesn't look very good to me.Sketchy implementation in
Compilation.AllErrors.addis inspired byhttps://github.com/ziglang/zig/blob/master/lib/std/zig/ast.zig#L97-L116
I tried to test all paths with the following snippets,
zig run: