From 6b08cbcb7a821cbbd15291d3a27b8900a233e904 Mon Sep 17 00:00:00 2001 From: eyelash Date: Fri, 1 May 2020 12:44:15 +0200 Subject: [PATCH] compiler: print warnings in magenta --- vlib/v/util/errors.v | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vlib/v/util/errors.v b/vlib/v/util/errors.v index 3f436997b5..fa06f28645 100644 --- a/vlib/v/util/errors.v +++ b/vlib/v/util/errors.v @@ -70,14 +70,14 @@ pub fn formatted_error(kind, emsg, filepath string, pos token.Position) string { } column := imax(0, pos.pos - p - 1) position := '${path}:${pos.line_nr+1}:${util.imax(1,column+1)}:' - scontext := source_context(source, column, pos).join('\n') + scontext := source_context(kind, source, column, pos).join('\n') final_position := if emanager.support_color { term.bold(position) } else { position } mut final_kind := kind if emanager.support_color { final_kind = if kind.contains('error') { term.bold(term.red(kind)) } else { - term.bold(term.bright_blue(kind)) + term.bold(term.magenta(kind)) } } final_msg := emsg // if emanager.support_color { term.bold(emsg) } else { emsg } @@ -86,7 +86,7 @@ pub fn formatted_error(kind, emsg, filepath string, pos token.Position) string { return '$final_position $final_kind $final_msg $final_context'.trim_space() } -pub fn source_context(source string, column int, pos token.Position) []string { +pub fn source_context(kind, source string, column int, pos token.Position) []string { mut clines := []string{} if source.len == 0 { return clines @@ -99,7 +99,11 @@ pub fn source_context(source string, column int, pos token.Position) []string { sline := source_lines[iline] mut cline := '${iline+1:5d}| ' + sline.replace('\t', tab_spaces) if iline == pos.line_nr && emanager.support_color { - cline = term.red(cline) + cline = if kind.contains('error') { + term.red(cline) + } else { + term.magenta(cline) + } } clines << cline //