Skip to content

Handle non-local return in trace #12063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions compiler/src/dotty/tools/dotc/reporting/trace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,23 @@ trait TraceSyntax:
while logctx.reporter.isInstanceOf[StoreReporter] do logctx = logctx.outer
def margin = ctx.base.indentTab * ctx.base.indent
def doLog(s: String) = if isForced then println(s) else report.log(s)
def finalize(result: Any, note: String) =
def finalize(msg: String) =
if !finalized then
ctx.base.indent -= 1
doLog(s"$margin${trailing(result)}$note")
doLog(s"$margin$msg")
finalized = true
try
doLog(s"$margin$leading")
ctx.base.indent += 1
val res = op
finalize(res, "")
finalize(trailing(res))
res
catch case ex: Throwable =>
finalize("<missing>", s" (with exception $ex)")
throw ex
catch
case ex: runtime.NonLocalReturnControl[T] =>
finalize(trailing(ex.value))
throw ex
case ex: Throwable =>
val msg = s"<== $q = <missing> (with exception $ex)"
finalize(msg)
throw ex
end TraceSyntax