-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Error on TypedefOrDcl #3325
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
Error on TypedefOrDcl #3325
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
Whoops, just signed the CLA, @dotty-bot.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test case?
hl"""`=', `>:', or `<:' expected""" | ||
|
||
val explanation = | ||
hl"""|In Scala, type parameters and abstract types may be constrained by a type bound. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove "In Scala"
extends Message(ExpectedTypeBoundOrEqualsID) { | ||
val kind = "Syntax" | ||
val msg = | ||
hl"""`=', `>:', or `<:' expected""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use backquotes. Interpolated strings will be highlighted. For example here:
val msg = hl"${"="}, ${">:"}, or ${"<:"} expected"
@@ -2156,7 +2156,7 @@ object Parsers { | |||
case SUPERTYPE | SUBTYPE | SEMI | NEWLINE | NEWLINES | COMMA | RBRACE | EOF => | |||
TypeDef(name, lambdaAbstract(tparams, typeBounds())).withMods(mods).setComment(in.getDocComment(start)) | |||
case _ => | |||
syntaxErrorOrIncomplete("`=', `>:', or `<:' expected") | |||
syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could display the faulty token it in the error message:
hl"... expected, but ${Tokens.showToken(found)} found"
Show faulty token in the error message Don't use backquotes. Remove "In Scala" in explanation message
@allanrenucci I changed what you requested and added a test at the end of ErrorMessagesTests.scala. |
""".stripMargin | ||
}.expect { (ictx, messages) => | ||
implicit val ctx: Context = ictx | ||
val defn = ictx.definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need defn
here.
I think it's ok now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you 🎉
Tackles #1589. More specifically, it provides a detailed explanation for the error message in Parsers.scala:2150 : "
=',
>:', or `<:' expected".