-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update error msg for Parsers.scala:1738 and 1739 #1629
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
Conversation
@ljdelight Awesome 👍 - quick tip: you can make the 'error printer' (of dotc or dotr) syntax highlight the example code (the Person class): see previous PRs related to errors :-) |
6fec962
to
2a070c3
Compare
Neat! I had tried to get syntax highlighting using those inline
I'm not sure how it works, and thanks for the tip |
| | ||
|Here's an example class with primary and auxiliary constructors: | ||
| | ||
|$code""".stripMargin |
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.
Perhaps the reason as to why somebody would create an auxiliary constructor with an implicit parameter is because they get the error: could not find implicit value for parameter X: Type
.
It might be worth mentioning that with auxiliary constructors calling a primary constructor that has an implicit argslist, the implicit value has to be explicitly specified at the callsite.
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.
Great feedback, I'll get this done today :D
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.
I'm a bit over my head (learning scala from coursera, on week 7) with creating an example for the other case. I've been looking at math.Ordering
and I cannot create a simple example; and my example in this PR actually does against the general consensus of not using basic types in implicit
. Do you think I should remove the example and not have one? I'm considering adding more text to the explanation to help with the case of an implicit primary constructor, thoughts @felixmulder?
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.
For the sake of progress - perhaps omit the implicit
example? This can always be improved later on :)
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.
Updated the text 👍
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.
Basically I think this looks good, but perhaps provide an explanation and way to use aux constructors if the user has an implicit argument list in the main constructor.
2a070c3
to
7be5b82
Compare
These error messages are for aux ctors needing non-implicit params. I'm testing the error messages with this code ``` class Square(val len: Int) { // typical cases: // (1) this() parens are forgotten, (2) argument set as implicit def this(implicit width: Double) = this(0) def this = { this(4) } } class MyList(val s: String) { def this ```
7be5b82
to
7c47361
Compare
Thanks @ljdelight! 🎉 |
These error messages are for aux ctors needing non-implicit params. I'm testing the error messages with this code