Skip to content
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

Make error reporting resilient to exception thrown while reporting #20158

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import java.io.{BufferedReader, PrintWriter}
import scala.annotation.internal.sharable
import scala.collection.mutable
import core.Decorators.em
import core.handleRecursive

object Reporter {
/** Convert a SimpleReporter into a real Reporter */
Expand Down Expand Up @@ -155,6 +156,12 @@ abstract class Reporter extends interfaces.ReporterResult {
addUnreported(key, 1)
case _ =>
if !isHidden(dia) then // avoid isHidden test for summarized warnings so that message is not forced
try
withMode(Mode.Printing)(doReport(dia))
catch case ex: Throwable =>
// #20158: Don't increment the error count, otherwise we might suppress
// the RecursiveOverflow error and not print any error at all.
handleRecursive("error reporting", dia.message, ex)
dia match {
case w: Warning =>
warnings = w :: warnings
Expand All @@ -168,7 +175,6 @@ abstract class Reporter extends interfaces.ReporterResult {
// match error if d is something else
}
markReported(dia)
withMode(Mode.Printing)(doReport(dia))
end issueUnconfigured

def issueIfNotSuppressed(dia: Diagnostic)(using Context): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
}

if dia.level >= WARNING then
_diagnosticBuf.append(dia)
_consoleReporter.doReport(dia)
_diagnosticBuf.append(dia)
printMessageAndPos(dia, extra)
}
}
Expand Down
16 changes: 16 additions & 0 deletions tests/neg/mt-deskolemize.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trait Expr:
type Value
object Expr:
type Of[V] = Expr { type Value = V }
type ExtractValue[F <: Expr] = F match
case Expr.Of[v] => v
import Expr.ExtractValue

class SimpleLoop1 extends Expr:
type Value = ExtractValue[SimpleLoop2]

class SimpleLoop2 extends Expr:
type Value = ExtractValue[SimpleLoop1]

object Test1:
val x: ExtractValue[SimpleLoop1] = 1 // error
Loading