-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Type inference bug in Scala 3.1.2 #15160
Comments
I won't be able to look at new issues for the next few months, so I recommend not assigning me, but feel free to re-assign me if a bisection points to one of my commits and no one else can figure it out. |
Bisected to db5956b |
This seems to be intentional. In the interest of not allowing compile-times to blow up, we do not perform implicit searches for uninstantiated top-level type variables. |
While it's uninstantied it can be fully determined by its expected type, so it seems like we could allow it (also this restriction isn't communicated by the error message) |
I am not sure what the criterion could be to allow it here. We have a type variable that's bounded by Also, note that there is a simple workaround: given eq: Eq[Type] = derive[Eq] |
I don't think I'll be able to work on this for the time being. |
👋 from my perspective as a user, if you say there are technical challenges that make this impractical, I believe you. It was surprising to me, as it used to work, and now it doesn't. If this helps compile times, then that may be a useful trade-off. But maybe you can improve the error message a little? I'm beginning to be spoiled by Scala 3's cool error message. IDK 🤷♂️ |
If I understand correctly, the current logic simply does no implicit search if the type passed to it is an uninstantiated type variable, but could we instead force the type variable to be instantiated (recursively, until isUnderspecified returns false) before doing the implicit search? |
Maybe, but where? You can't very well do it during implicit search, the type variable might be in a nested subgoal and there might be another branch that succeeds. So the only viable scheme is to handle global search failure by looking at the variables and selectively instantiating some of them. Similarly to what we do in typedSelect. That could possibly work. It will be very tricky though to get all the info to the points where it is needed. Once could start improving the error message but even that looks hard. |
In fact, shouldn't |
Not sure I understand. Type variables bound in polytypes are usually meant to be instantiated by the implicit search, no? |
) Two improvements for implicit searches involving type variables. 1. We now always add a comment when an implicit search is rejected due to the "too unspecific" criterion of #13886, commit [Refine checking for underspecified implicit queries](db5956b). There have been quite a few regressions that hit that problem, so it is good to know immediately what the issue is. 2. There is now a better wildcard approximation of higher-kinded type applications. This makes several programs (including original #15998) compile, which were classified as not specific enough before. Fixes #15998 Fixes #15820 Fixes #15670 Fixes #15160 Fixes #13986
I'm unsure if I'm reporting this issue in the right place.
Compiler version
3.1.2
— the issue does not happen in3.0.x
or in3.1.1
.First bad commit db5956b in #13886
Minimized code
Noticed it while upgrading to 3.1.2 in monix/newtypes:
Output
Expectation
The code should compile just fine, as it does with
3.1.1
,3.0.2
, or2.13.x
.The text was updated successfully, but these errors were encountered: