Skip to content

Commit 447b8bf

Browse files
committed
fix error messages
1 parent 302e1de commit 447b8bf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

compiler/test/dotty/tools/debug/DebugStepAssert.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.sun.jdi.Location
44
import dotty.tools.io.JPath
55
import dotty.tools.readLines
66

7+
import scala.annotation.tailrec
8+
79
/**
810
* A debug step and an associated assertion to validate the step.
911
* A sequence of DebugStepAssert is parsed from the check file in tests/debug
@@ -41,8 +43,9 @@ private[debug] object DebugStepAssert:
4143
val multiLineError = s"error$trailing".r
4244
val allLines = readLines(checkFile.toFile)
4345

46+
@tailrec
4447
def loop(lines: List[String], acc: List[DebugStepAssert[?]]): List[DebugStepAssert[?]] =
45-
given CheckFileLocation = CheckFileLocation(checkFile, allLines.size - lines.size + 1)
48+
given location: CheckFileLocation = CheckFileLocation(checkFile, allLines.size - lines.size + 1)
4649
lines match
4750
case Nil => acc.reverse
4851
case break(className , lineStr) :: tail =>
@@ -66,18 +69,21 @@ private[debug] object DebugStepAssert:
6669
val step = DebugStepAssert(Eval(expr), assertion)
6770
loop(tail2, step :: acc)
6871
case trailing() :: tail => loop(tail, acc)
69-
case invalid :: tail => throw new Exception(s"Cannot parse debug step: $invalid")
72+
case invalid :: tail =>
73+
throw new Exception(s"Cannot parse debug step: $invalid ($location)")
7074

7175
def parseEvalAssertion(lines: List[String]): (Either[String, String] => Unit, List[String]) =
72-
given CheckFileLocation = CheckFileLocation(checkFile, allLines.size - lines.size + 1)
76+
given location: CheckFileLocation = CheckFileLocation(checkFile, allLines.size - lines.size + 1)
7377
lines match
7478
case Nil => throw new Exception(s"Missing result or error")
79+
case trailing() :: tail => parseEvalAssertion(tail)
7580
case result(expected) :: tail => (checkResult(expected), tail)
7681
case error(expected) :: tail => (checkError(Seq(expected)), tail)
7782
case multiLineError() :: tail0 =>
7883
val (expected, tail1) = tail0.span(_.startsWith(" "))
7984
(checkError(expected.map(_.stripPrefix(" "))), tail1)
80-
case invalid :: _ => throw new Exception(s"Cannot parse as result or error: $invalid")
85+
case invalid :: _ =>
86+
throw new Exception(s"Cannot parse as result or error: $invalid ($location)")
8187

8288
loop(allLines, Nil)
8389
end parseCheckFile

compiler/test/dotty/tools/debug/DebugTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DebugTests:
1515
import DebugTests.*
1616
@Test def debug: Unit =
1717
implicit val testGroup: TestGroup = TestGroup("debug")
18-
// compileFile("tests/debug/eval-mutable-variables.scala", TestConfiguration.defaultOptions).checkDebug()
18+
// compileFile("tests/debug/eval-private-members-in-parent.scala", TestConfiguration.defaultOptions).checkDebug()
1919
compileFilesInDir("tests/debug", TestConfiguration.defaultOptions).checkDebug()
2020

2121
object DebugTests extends ParallelTesting:
@@ -110,6 +110,7 @@ object DebugTests extends ParallelTesting:
110110
assert(result)
111111
catch
112112
case _: TimeoutException => throw new DebugStepException("Timeout", step.location)
113+
case e: DebugStepException => throw e
113114
case NonFatal(e) =>
114115
throw new Exception(s"Debug step failed unexpectedly: ${step.location}", e)
115116
end for

0 commit comments

Comments
 (0)