@@ -38,10 +38,13 @@ abstract class DiffMaker:
3838 def doFail (blockLineNum : Int , msg : String ): Unit =
3939 System .err.println(fansi.Color .Red (" FAILURE: " ).toString + msg)
4040 def unhandled (blockLineNum : Int , exc : Throwable ): Unit =
41- unexpected(" exception" , blockLineNum, () => N )
41+ unexpected(" exception" , blockLineNum, N , () => N )
4242
43- final def unexpected (what : Str , blockLineNum : Int , mkExtraInfo : () => Opt [Any ]): Unit =
43+ final def unexpected (what : Str , blockLineNum : Int , srcLoc : Opt [ Str ], mkExtraInfo : () => Opt [Any ]): Unit =
4444 output(s " FAILURE: Unexpected $what" )
45+ srcLoc match
46+ case S (loc) => output(s " FAILURE LOCATION: $loc" )
47+ case N => ()
4548 mkExtraInfo() match
4649 case S (info : Product ) => output(s " FAILURE INFO: ${info.showAsTree}" )
4750 case S (info) => output(s " FAILURE INFO: $info" )
@@ -174,34 +177,34 @@ abstract class DiffMaker:
174177 parseErrors += 1
175178 if expectParseErrors.isUnset && ! tolerateErrors then
176179 failures += globalStartLineNum
177- unexpected(" lexing error" , blockLineNum, d.mkExtraInfo)
180+ unexpected(" lexing error" , blockLineNum, S (d.srcLoc), d.mkExtraInfo)
178181 case Diagnostic .Source .Parsing =>
179182 parseErrors += 1
180183 if expectParseErrors.isUnset && ! tolerateErrors then
181184 failures += globalStartLineNum
182185 // doFail(fileName, blockLineNum, "unexpected parse error at ")
183- unexpected(" parse error" , blockLineNum, d.mkExtraInfo)
186+ unexpected(" parse error" , blockLineNum, S (d.srcLoc), d.mkExtraInfo)
184187 // report(blockLineNum, d :: Nil, showRelativeLineNums.isSet)
185188 case Diagnostic .Source .Typing =>
186189 typeErrors += 1
187190 if expectTypeErrors.isUnset && ! tolerateErrors then
188191 failures += globalStartLineNum
189- unexpected(" type error" , blockLineNum, d.mkExtraInfo)
192+ unexpected(" type error" , blockLineNum, S (d.srcLoc), d.mkExtraInfo)
190193 case Diagnostic .Source .Compilation =>
191194 compilationErrors += 1
192195 if expectCodeGenErrors.isUnset && ! tolerateErrors then
193196 failures += globalStartLineNum
194- unexpected(" compilation error" , blockLineNum, d.mkExtraInfo)
197+ unexpected(" compilation error" , blockLineNum, S (d.srcLoc), d.mkExtraInfo)
195198 case Diagnostic .Source .Runtime =>
196199 runtimeErrors += 1
197200 if ! expectRuntimeOrCodeGenErrors && ! tolerateErrors then
198201 failures += globalStartLineNum
199- unexpected(" runtime error" , blockLineNum, d.mkExtraInfo)
202+ unexpected(" runtime error" , blockLineNum, S (d.srcLoc), d.mkExtraInfo)
200203 case Diagnostic .Kind .Warning =>
201204 warnings += 1
202205 if expectWarnings.isUnset && ! tolerateErrors then
203206 failures += globalStartLineNum
204- unexpected(" warning" , blockLineNum, d.mkExtraInfo)
207+ unexpected(" warning" , blockLineNum, S (d.srcLoc), d.mkExtraInfo)
205208 case Diagnostic .Kind .Internal =>
206209 if ! tolerateErrors then
207210 failures += globalStartLineNum
@@ -215,23 +218,23 @@ abstract class DiffMaker:
215218 // Use `todo` when the errors are expected but not yet implemented.
216219 if expectParseErrors.isSet && parseErrors == 0 && todo.isUnset && breakme.isUnset then
217220 failures += globalStartLineNum
218- unexpected(" lack of parse error" , blockLineNum, () => N )
221+ unexpected(" lack of parse error" , blockLineNum, N , () => N )
219222 if expectTypeErrors.isSet && typeErrors == 0 && todo.isUnset && breakme.isUnset then
220223 failures += globalStartLineNum
221- unexpected(" lack of type error" , blockLineNum, () => N )
224+ unexpected(" lack of type error" , blockLineNum, N , () => N )
222225 if expectCodeGenErrors.isSet && compilationErrors == 0 && todo.isUnset && breakme.isUnset then
223226 failures += globalStartLineNum
224- unexpected(" lack of compilation error" , blockLineNum, () => N )
227+ unexpected(" lack of compilation error" , blockLineNum, N , () => N )
225228 if expectRuntimeErrors.isSet && runtimeErrors == 0 && todo.isUnset && breakme.isUnset then
226229 failures += globalStartLineNum
227- unexpected(" lack of runtime error" , blockLineNum, () => N )
230+ unexpected(" lack of runtime error" , blockLineNum, N , () => N )
228231 if expectWarnings.isSet && warnings == 0 && todo.isUnset && breakme.isUnset then
229232 failures += globalStartLineNum
230- unexpected(" lack of warnings" , blockLineNum, () => N )
233+ unexpected(" lack of warnings" , blockLineNum, N , () => N )
231234
232235 if fixme.isSet && (parseErrors + typeErrors + compilationErrors + runtimeErrors) == 0 then
233236 failures += globalStartLineNum
234- unexpected(" lack of error to fix" , blockLineNum, () => N )
237+ unexpected(" lack of error to fix" , blockLineNum, N , () => N )
235238
236239
237240
0 commit comments