Skip to content

Commit 95e4631

Browse files
committed
Handle non-local return in trace
1 parent 85a03ee commit 95e4631

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

compiler/src/dotty/tools/dotc/reporting/trace.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,23 @@ trait TraceSyntax:
7474
while logctx.reporter.isInstanceOf[StoreReporter] do logctx = logctx.outer
7575
def margin = ctx.base.indentTab * ctx.base.indent
7676
def doLog(s: String) = if isForced then println(s) else report.log(s)
77-
def finalize(result: Any, note: String) =
77+
def finalize(msg: String) =
7878
if !finalized then
7979
ctx.base.indent -= 1
80-
doLog(s"$margin${trailing(result)}$note")
80+
doLog(s"$margin$msg")
8181
finalized = true
8282
try
8383
doLog(s"$margin$leading")
8484
ctx.base.indent += 1
8585
val res = op
86-
finalize(res, "")
86+
finalize(trailing(res))
8787
res
88-
catch case ex: Throwable =>
89-
finalize("<missing>", s" (with exception $ex)")
90-
throw ex
88+
catch
89+
case ex: runtime.NonLocalReturnControl[T] =>
90+
finalize(trailing(ex.value))
91+
throw ex
92+
case ex: Throwable =>
93+
val msg = s"<== $q = <missing> (with exception $ex)"
94+
finalize(msg)
95+
throw ex
9196
end TraceSyntax

0 commit comments

Comments
 (0)