From 6165b119f6c871c54937a5d25ae294e425af4324 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 28 Jun 2022 14:05:32 +0300 Subject: [PATCH] scanner,parser,checker: do show the first error on -Wfatal-errors --- vlib/v/checker/checker.v | 5 +++++ vlib/v/parser/parser.v | 8 ++++++-- vlib/v/scanner/scanner.v | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 110eced6b6..c7f89e5602 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3687,6 +3687,11 @@ fn (mut c Checker) warn_or_error(message string, pos token.Pos, warn bool) { } if !warn { if c.pref.fatal_errors { + ferror := util.formatted_error('error:', message, c.file.path, pos) + eprintln(ferror) + if details.len > 0 { + eprintln('Details: $details') + } exit(1) } c.nr_errors++ diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 1792de0076..b4d8b4b165 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1824,10 +1824,12 @@ pub fn (mut p Parser) note(s string) { } pub fn (mut p Parser) error_with_pos(s string, pos token.Pos) ast.NodeError { + mut kind := 'error:' if p.pref.fatal_errors { + ferror := util.formatted_error(kind, s, p.file_name, pos) + eprintln(ferror) exit(1) } - mut kind := 'error:' if p.pref.output_mode == .stdout && !p.pref.check_only { if p.pref.is_verbose { print_backtrace() @@ -1864,10 +1866,12 @@ pub fn (mut p Parser) error_with_pos(s string, pos token.Pos) ast.NodeError { } pub fn (mut p Parser) error_with_error(error errors.Error) { + mut kind := 'error:' if p.pref.fatal_errors { + ferror := util.formatted_error(kind, error.message, error.file_path, error.pos) + eprintln(ferror) exit(1) } - mut kind := 'error:' if p.pref.output_mode == .stdout && !p.pref.check_only { if p.pref.is_verbose { print_backtrace() diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 38b675ffb0..130c9eab71 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -1546,6 +1546,10 @@ pub fn (mut s Scanner) error(msg string) { exit(1) } else { if s.pref.fatal_errors { + eprintln(util.formatted_error('error:', msg, s.file_path, pos)) + if details.len > 0 { + eprintln(details) + } exit(1) } if s.pref.message_limit >= 0 && s.errors.len >= s.pref.message_limit {