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

scanner,parser,checker: do show the first error on -Wfatal-errors

This commit is contained in:
Delyan Angelov 2022-06-28 14:05:32 +03:00
parent 64b8284419
commit 6165b119f6
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 15 additions and 2 deletions

View File

@ -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++

View File

@ -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()

View File

@ -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 {