@@ -14,7 +14,8 @@ fn (mut c Checker) add_error_detail(s string) {
1414}
1515
1616fn (mut c Checker) add_error_detail_with_pos (msg string , pos token.Pos) {
17- c.add_error_detail (util.formatted_error ('details:' , msg, c.file.path, pos))
17+ file_path := if pos.file_idx < 0 { c.file.path } else { c.table.filelist[pos.file_idx] }
18+ c.add_error_detail (util.formatted_error ('details:' , msg, file_path, pos))
1819}
1920
2021fn (mut c Checker) add_instruction_for_option_type () {
@@ -90,13 +91,14 @@ fn (mut c Checker) note(message string, pos token.Pos) {
9091 c.error_details = []
9192 }
9293 // deduplicate notices for the same line
93- kpos := '${c .file .path }:${pos .line_nr }:${message }'
94+ file_path := if pos.file_idx < 0 { c.file.path } else { c.table.filelist[pos.file_idx] }
95+ kpos := '${file_path }:${pos .line_nr }:${message }'
9496 if kpos ! in c.notice_lines {
9597 c.notice_lines[kpos] = true
9698 note := errors.Notice{
9799 reporter: errors.Reporter.checker
98100 pos: pos
99- file_path: c.file.path
101+ file_path: file_path
100102 message: message
101103 details: details
102104 }
@@ -122,20 +124,21 @@ fn (mut c Checker) warn_or_error(message string, pos token.Pos, warn bool) {
122124 details = c.error_details.join ('\n ' )
123125 c.error_details = []
124126 }
127+ file_path := if pos.file_idx < 0 { c.file.path } else { c.table.filelist[pos.file_idx] }
125128 if warn && ! c.pref.skip_warnings {
126129 c.nr_warnings++
127130 if c.pref.message_limit > = 0 && c.nr_warnings > = c.pref.message_limit {
128131 c.should_abort = true
129132 return
130133 }
131134 // deduplicate warnings for the same line
132- kpos := '${c . file . path }:${pos .line_nr }:${message }'
135+ kpos := '${file_path }:${pos .line_nr }:${message }'
133136 if kpos ! in c.warning_lines {
134137 c.warning_lines[kpos] = true
135138 wrn := errors.Warning{
136139 reporter: errors.Reporter.checker
137140 pos: pos
138- file_path: c.file.path
141+ file_path: file_path
139142 message: message
140143 details: details
141144 }
@@ -148,7 +151,7 @@ fn (mut c Checker) warn_or_error(message string, pos token.Pos, warn bool) {
148151 if c.pref.fatal_errors {
149152 util.show_compiler_message ('error:' , errors.CompilerMessage{
150153 pos: pos
151- file_path: c.file.path
154+ file_path: file_path
152155 message: message
153156 details: details
154157 })
@@ -160,13 +163,13 @@ fn (mut c Checker) warn_or_error(message string, pos token.Pos, warn bool) {
160163 return
161164 }
162165 // deduplicate errors for the same line
163- kpos := '${c . file . path }:${pos .line_nr }:${message }'
166+ kpos := '${file_path }:${pos .line_nr }:${message }'
164167 if kpos ! in c.error_lines {
165168 c.error_lines[kpos] = true
166169 err := errors.Error{
167170 reporter: errors.Reporter.checker
168171 pos: pos
169- file_path: c.file.path
172+ file_path: file_path
170173 message: message
171174 details: details
172175 }
0 commit comments