Skip to content

Fix #2495: Improve error message #3804

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
Jan 15, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,15 @@ object messages {
val msg = {
val ofFun =
if (MethodType.syntheticParamNames(args.length + 1) contains param.name)
i" of expanded function $tree"
i" of expanded function:\n$tree"
else
""

i"""missing parameter type for parameter ${param.name}$ofFun, expected = $pt
|The argument types of an anonymous function must be fully known. (SLS 8.5)"""
i"""missing parameter type
|
|The argument types of an anonymous function must be fully known. (SLS 8.5)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to have this general reference at the end, and put more specific information before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of the missing parameter type explaination.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also follows the old format in scalac that users said was clearer.

|Expected type: $pt
|Missing type for parameter ${param.name}$ofFun"""
}

val explanation =
Expand Down
5 changes: 4 additions & 1 deletion compiler/test-resources/repl/errorThenValid
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
scala> val xs = scala.collection.mutable.ListBuffer[Int]
1 | val xs = scala.collection.mutable.ListBuffer[Int]
| ^
|missing parameter type for parameter elems, expected = ?
|missing parameter type
|
|The argument types of an anonymous function must be fully known. (SLS 8.5)
|Expected type: ?
|Missing type for parameter elems
scala> val xs = scala.collection.mutable.ListBuffer[Int]()
val xs: scala.collection.mutable.ListBuffer[Int] = ListBuffer()