Skip to content

Commit

Permalink
Handle stackoverflows when trying to print the maximal constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Sep 2, 2022
1 parent ef3dacf commit 5c16d2c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ trait ConstraintRunInfo { self: Run =>
maxConstraint = c
}
def printMaxConstraint()(using Context): Unit =
val printer = if (ctx.settings.YdetailedStats.value) default else typr
if maxSize > 0 then
printer.println(s"max constraint = ${maxConstraint.nn.show}\nsize = $maxSize")
val printer = if ctx.settings.YdetailedStats.value then default else typr
printer.println(s"max constraint size: $maxSize")
try printer.println(s"max constraint = ${maxConstraint.nn.show}")
catch case ex: StackOverflowError => printer.println("max constraint cannot be printed due to stack overflow")

protected def reset(): Unit = maxConstraint = null
}

0 comments on commit 5c16d2c

Please # to comment.