1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vet: turn warnings into errors with -W flag (#9575)

This commit is contained in:
Lukas Neubert
2021-04-03 18:30:15 +02:00
committed by GitHub
parent 31f8d5542c
commit 646d46b4dc
2 changed files with 10 additions and 3 deletions

View File

@@ -77,7 +77,7 @@ fn main() {
if vfmt_err_count > 0 {
eprintln('NB: You can run `v fmt -w file.v` to fix these errors automatically')
}
if vt.errors.len > 0 || (vt.opt.is_werror && vt.warns.len > 0) {
if vt.errors.len > 0 {
exit(1)
}
}
@@ -236,13 +236,19 @@ fn (mut vt Vet) warn(msg string, line int, fix vet.FixKind) {
pos := token.Position{
line_nr: line + 1
}
vt.warns << vet.Error{
mut w := vet.Error{
message: msg
file_path: vt.file
pos: pos
kind: .warning
fix: fix
}
if vt.opt.is_werror {
w.kind = .error
vt.errors << w
} else {
vt.warns << w
}
}
fn should_use_color() bool {