Skip to content

Add an error message class for the method's missing arguments #3394

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

Closed
wants to merge 1 commit into from
Closed

Add an error message class for the method's missing arguments #3394

wants to merge 1 commit into from

Conversation

maseev
Copy link
Contributor

@maseev maseev commented Oct 27, 2017

This PR is related to #1589. Specifically, it adds a new error message class for the following case Typer.scala:1898 (def missingArgs)

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! ☀️

@@ -1908,7 +1908,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def methodStr = err.refStr(methPart(tree).tpe)

def missingArgs(mt: MethodType) = {
ctx.error(em"missing arguments for $methodStr", tree.pos)
ctx.error(MissingArgumentsForMethod(methodStr), tree.pos)
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is tricky. The idea of error messages is to contains useful information not only for the compiler but also for tools such as IDE. A string is not very helpful for an IDE. Ideally we would want to include the symbol of the method as well as the missing arguments. It should be something like:

case class MissingArgumentsForMethod(method: Symbol, missings: List[Symbol])(implicit ctx: Context)

You should look at what def methodStr is doing in order to get this information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally agree that providing useful information for IDEs is a must, but here's the thing, this error message is about using a so-called nullary method which is described in this document.

So, there are actually no missing arguments which a user forgot to provide because a method doesn't accept any arguments.

Maybe the initial error message is a little bit ambiguous. Because when I see this:

scala> def greet(): String = "hello" 
def greet(): String
scala> greet 
1 |greet
  |^^^^^
  |missing arguments for method greet

It makes me think that I forgot to provide the actual arguments for the method when the actual problem is that Dotty is stricter than Scala in terms of calling nullary methods.

Copy link
Contributor

@allanrenucci allanrenucci Oct 28, 2017

Choose a reason for hiding this comment

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

I agree the error message as well as the name of the message is ambiguous. If this message only applies for missing empty parameter list, then I would update the message accordingly

@allanrenucci
Copy link
Contributor

Superseded by #3407

@maseev maseev deleted the iss1589-missing-arguments-for-method branch October 30, 2017 17:42
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