-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add an error message class for a function underscore case #3400
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
Add an error message class for a function underscore case #3400
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! ☀️
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.
Can you please rebase your PR?
case class OnlyFunctionsCanBeFollowedByUnderscore(pt: Type)(implicit ctx: Context) | ||
extends Message(OnlyFunctionsCanBeFollowedByUnderscoreID) { | ||
val kind = "Syntax" | ||
val msg = hl"not a function: $pt; cannot be followed by `_'" |
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.
val msg = hl"Not a function: $pt: cannot be followed by ${"_"}"
extends Message(OnlyFunctionsCanBeFollowedByUnderscoreID) { | ||
val kind = "Syntax" | ||
val msg = hl"not a function: $pt; cannot be followed by `_'" | ||
val explanation = "" |
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.
val explanation =
hl"""The syntax ${"x _"} is no longer supported if ${"x"} is not a function.
|To convert to a function value, you need to explicitly write ${"() => x"}"""
implicit val ctx: Context = ictx | ||
|
||
assertMessageCount(1, messages) | ||
|
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.
remove this blank line
assertMessageCount(1, messages) | ||
|
||
val OnlyFunctionsCanBeFollowedByUnderscore(pt) :: Nil = messages | ||
|
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.
remove this blank line
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. Thanks!
@allanrenucci I've noticed that quite a lot of PRs are merged with the merge commit, even if the PR contains only one commit. Is this intentional? Because Github supports different strategies of merging pull requests. You can merge the PR with a merge commit (with a git --no-ff option), or you can squash all commits in the PR in just one and merge the pull request with a fast-forward technique where the merge commit won't be created (this is basically is squash and a fast-forward merge). |
We don't have a strict policy. I'd say we want to have a merge commit + meaningful commits. |
This PR is related to #1589. Specifically, it adds a new error message class for the following case
Typer.scala:1555
(ctx.errorOrMigrationWarning(i"not a function: ${res.tpe}; cannot be followed by _", tree.pos)
)