zig.vim icon indicating copy to clipboard operation
zig.vim copied to clipboard

errorformat is incorrect

Open jasoneveleth opened this issue 2 years ago • 2 comments

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

jasoneveleth avatar Jun 27 '23 14:06 jasoneveleth

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}'

owallb avatar May 06 '24 00:05 owallb

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.

xz47sv avatar Jun 18 '24 07:06 xz47sv