Skip to content

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

Merged
merged 2 commits into from
Oct 30, 2017
Merged

Add an error message class for a function underscore case #3400

merged 2 commits into from
Oct 30, 2017

Conversation

maseev
Copy link
Contributor

@maseev maseev commented Oct 29, 2017

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))

Copy link
Member

@dottybot dottybot left a 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! ☀️

@allanrenucci allanrenucci self-assigned this Oct 30, 2017
Copy link
Contributor

@allanrenucci allanrenucci left a 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 `_'"
Copy link
Contributor

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 = ""
Copy link
Contributor

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)

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this blank line

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@allanrenucci allanrenucci merged commit 13c5455 into scala:master Oct 30, 2017
@maseev
Copy link
Contributor Author

maseev commented Oct 30, 2017

@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).

@allanrenucci
Copy link
Contributor

We don't have a strict policy. I'd say we want to have a merge commit + meaningful commits.
If you squash with GitHub, you don't get a merge commit.
We tend not to ask external contributors to squash their commits, but ideally they should

@maseev maseev deleted the iss1589-underscore-only-for-functions branch October 30, 2017 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants