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

native: fix the file path used for warning messages (#18948)

This commit is contained in:
Eliyaan (Nopana) 2023-07-23 07:03:30 +02:00 committed by GitHub
parent ac0ae1966a
commit 40dc80079d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,7 @@ mut:
stack_var_pos int stack_var_pos int
stack_depth int stack_depth int
debug_pos int debug_pos int
current_file &ast.File = unsafe { nil }
errors []errors.Error errors []errors.Error
warnings []errors.Warning warnings []errors.Warning
syms []Symbol syms []Symbol
@ -346,6 +347,7 @@ pub fn gen(files []&ast.File, table &ast.Table, out_name string, pref_ &pref.Pre
eprintln('warning: ${file.warnings[0]}') eprintln('warning: ${file.warnings[0]}')
} }
*/ */
g.current_file = file
if file.errors.len > 0 { if file.errors.len > 0 {
g.n_error(file.errors[0].str()) g.n_error(file.errors[0].str())
} }
@ -1055,10 +1057,10 @@ pub fn (mut g Gen) n_error(s string) {
pub fn (mut g Gen) warning(s string, pos token.Pos) { pub fn (mut g Gen) warning(s string, pos token.Pos) {
if g.pref.output_mode == .stdout { if g.pref.output_mode == .stdout {
util.show_compiler_message('warning:', pos: pos, file_path: g.pref.path, message: s) util.show_compiler_message('warning:', pos: pos, file_path: g.current_file.path, message: s)
} else { } else {
g.warnings << errors.Warning{ g.warnings << errors.Warning{
file_path: g.pref.path file_path: g.current_file.path
pos: pos pos: pos
reporter: .gen reporter: .gen
message: s message: s