Skip to content

Fix missing error message #5832

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 3 commits into from
Feb 2, 2019
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
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import config.Printers.cyclicErrors

class TypeError(msg: String) extends Exception(msg) {
def this() = this("")
def toMessage(implicit ctx: Context): Message = getMessage
def toMessage(implicit ctx: Context): Message = super.getMessage
override def getMessage: String = throw new Exception("Use toMessage instead for TypeError")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be annoying but at least no error messages will be empty due to this bug in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it helped find the problem in Formatting.scala. Thanks for suggesting it 👍

}

class MalformedType(pre: Type, denot: Denotation, absMembers: Set[Name]) extends TypeError {
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/printing/Formatting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ object Formatting {
case NonFatal(ex)
if !ctx.mode.is(Mode.PrintShowExceptions) &&
!ctx.settings.YshowPrintErrors.value =>
s"[cannot display due to $ex, raw string = ${arg.toString}]"
val msg = ex match { case te: TypeError => te.toMessage case _ => ex.getMessage }
s"[cannot display due to $msg, raw string = ${arg.toString}]"
}
case _ => arg.toString
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ class RefChecks extends MiniPhase { thisPhase =>
tree
} catch {
case ex: TypeError =>
ctx.error(ex.getMessage, tree.sourcePos)
ctx.error(ex.toMessage, tree.sourcePos)
tree
}

Expand Down