-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compiler is overly secretive when it fails to infer the type of parameters #18042
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
Comments
I might tackle this myself, if not, it might be a good candidate for a Spree, as it leads through multiple parts of the compiler with a clear goal in mind ? |
Thinking more about this, I believe this would be helpful even in cases where the type to be inferred is underdetermined (as opposed to overdetermined like in my example) (Which is why I renamed this issue) |
This also has the upside of making the solution much simpler: No need to wonder about this question of under- vs over-determination, just always be precise |
This is a famous tpolecat request. I can't find a Scala 2 ticket, however. I have a memory of reading it recently, because it said that it happens more often than you might think. |
This looks very hard, and it's not clear at all the wins are large enough to warrant any complication in the compiler's code base. For me, |
There are actually two things being proposed, which are different in terms of scope:
From this moment on, this issue is about 2. |
This issue was picked for the Issue Spree No. 33 of 11 July 2023 which takes place in 7 days. @Sporarum, @sankalpgambhir will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
which I apparently opened on tpolecat's behalf. In 2021, already a long time past, I noted that the message was not improved in Scala 3. That ticket also mentions the lint which is missing here:
as a backstop. |
@sankalpgambhir as this is your first Spree, welcome! To get started hacking on the Dotty codebase, you will need to clone it, compile it and open it in VS Code using the following commands: git clone https://github.com/lampepfl/dotty.git
cd dotty
sbt compile
code . Then you will need to setup Metals to use the SBT build server. To do it, run the "Switch Build Server" VS Code command (by default the shortcut to open the VS Code command palette is ![]() ![]() To learn more: https://dotty.epfl.ch/docs/contributing/getting-started.html. |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
Scala 3.3.0
Minimized code & Output
https://scastie.scala-lang.org/Te6OUPEKTnmMn304qWsPew
Expectation
The fact the inference fails hides a more essential issue:
There is no type such that this succeeds.
(Except if there are implicit conversions, with the following, inferring
Int
would work:)
Even considering this point, a better error would be something like:
It displays more information, naturally leading the user to realize
x => x
would not work in any caseThe text was updated successfully, but these errors were encountered: