ziglang / zig.vim

Vim configuration for Zig
MIT License
448 stars 56 forks source link

errorformat is incorrect #97

Open jasoneveleth opened 1 year ago

jasoneveleth commented 1 year ago

This plugin doesn't set the errorformat, and so multiline failures like:

/home/jason/src/my-language/src/main.zig:359:22: error: unable to resolve inferred error set
    try readDelimited(ps, ')');
        ~~~~~~~~~~~~~^~~~~~~~~
referenced by:
    macros: /home/jason/src/my-language/src/main.zig:218:20
    read: /home/jason/src/my-language/src/main.zig:494:41
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

Don't get interpreted properly. I propose a different errorformat (and I would like to make a pull request). Here is my new errorformat:

"    macros: /home/jason/src/my-language/src/main.zig:218:20
set efm=\ \ \ \ %m:\ %f:%l:%c
"/home/jason/src/my-language/src/main.zig:359:22: error: unable to resolve inferred error set
set efm+=%f:%l:%c:\ %t%.%#:\ %m
"[matches anything]
set efm+=%C%m
owallb commented 4 months ago

Nice! You may also want to consider adding %-G%.%#. As I understand, it will match anything else and ignore it. It is useful when there are compile time prints or similar, because it will otherwise parse the error numbers incorrectly.

For example, the following has only 1 error but is marked as error 307 (out of 316):

:set efm?
  errorformat=%f:%l:%c: %t%.%#: %m
:make
<316 lines truncated>
(307 of 316) error: expected type 'type', found 'error{Unreachable,EatenByAGrue}'
:clist
307 exercises/058_quiz7.zig:312 col 84 error: expected type 'type', found 'error{Unreachable,EatenByAGrue}'

With %-G%.%# it will instead be 1:

:set efm?
  errorformat=%f:%l:%c: %t%.%#: %m,%-G%.%#
:make
<316 lines truncated>
(1 of 1) error: expected type 'type', found 'error{Unreachable,EatenByAGrue}'
:clist
 1 exercises/058_quiz7.zig:312 col 84 error: expected type 'type', found 'error{Unreachable,EatenByAGrue}'
xz47sv commented 2 months ago

This plugin doesn't set the errorformat, and so multiline failures like:

/home/jason/src/my-language/src/main.zig:359:22: error: unable to resolve inferred error set
    try readDelimited(ps, ')');
        ~~~~~~~~~~~~~^~~~~~~~~
referenced by:
    macros: /home/jason/src/my-language/src/main.zig:218:20
    read: /home/jason/src/my-language/src/main.zig:494:41
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

Don't get interpreted properly. I propose a different errorformat (and I would like to make a pull request). Here is my new errorformat:

"    macros: /home/jason/src/my-language/src/main.zig:218:20
set efm=\ \ \ \ %m:\ %f:%l:%c
"/home/jason/src/my-language/src/main.zig:359:22: error: unable to resolve inferred error set
set efm+=%f:%l:%c:\ %t%.%#:\ %m
"[matches anything]
set efm+=%C%m

The %.%#: should be replaced with %*[^:]:, i.e. %f:%l:%c:\ %t%*[^:]:\ %m, because %.%# is greedy and if there is more than one : it will skip them.