From 40dc80079d21af2de07a97d1f4e759e07f69e716 Mon Sep 17 00:00:00 2001 From: "Eliyaan (Nopana)" <103932369+Eliyaan@users.noreply.github.com> Date: Sun, 23 Jul 2023 07:03:30 +0200 Subject: [PATCH] native: fix the file path used for warning messages (#18948) --- vlib/v/gen/native/gen.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/native/gen.v b/vlib/v/gen/native/gen.v index da13515474..218d40d3e7 100644 --- a/vlib/v/gen/native/gen.v +++ b/vlib/v/gen/native/gen.v @@ -43,6 +43,7 @@ mut: stack_var_pos int stack_depth int debug_pos int + current_file &ast.File = unsafe { nil } errors []errors.Error warnings []errors.Warning 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]}') } */ + g.current_file = file if file.errors.len > 0 { 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) { 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 { g.warnings << errors.Warning{ - file_path: g.pref.path + file_path: g.current_file.path pos: pos reporter: .gen message: s