-
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
Overloading or implicit bug in 3.4.1 #20053
Comments
Minimised a bit more: trait DFVal[+T <: Int, +P]
trait Summon[R, T <: R]
given [R, T <: R]: Summon[R, T] with {}
trait Candidate[R]:
type OutW <: Int
type OutP
given [W <: Int, P, R <: DFVal[W, P]]: Candidate[R] with
type OutW = W
type OutP = P
extension [L <: DFVal[Int, Any]](lhs: L)(using icL: Candidate[L])
def ^^^[R](rhs: R)
(using icR: Candidate[R])
: DFVal[icL.OutW, icL.OutP | icR.OutP] = ???
def ^^^ : Unit = ???
extension [L](lhs: L)
def ^^^[RW <: Int, RP](rhs: DFVal[RW, RP])
(using es: Summon[L, lhs.type])
(using c: Candidate[L])
(using check: c.OutW =:= c.OutW)
: DFVal[c.OutW, c.OutP | RP] = ???
val x: DFVal[8, true] = ???
val z1 = x ^^^ x // Ok
val z2 = z1 ^^^ x // Ok
val zzz = x ^^^ x ^^^ x // Error When |
I will say that further look suggests there is a (false?) overloading ambiguity issue that may cause this: trait DFVal[+T <: Int, +P]
type DFValAny = DFVal[Int, Any]
trait Candidate[R]:
type OutW <: Int
type OutP
given [W <: Int, P, R <: DFVal[W, P]]: Candidate[R] with
type OutW = W
type OutP = P
val x = new DFVal[5, true]{}
object Works1:
extension [L <: DFValAny](lhs: L)(using icL: Candidate[L])
def ^^^(rhs: Any): Unit = ???
extension [L](lhs: L)
def ^^^[R](rhs: R): Unit = ???
val y = x ^^^ x //ok
object Works2:
extension [L <: DFValAny](lhs: L)(using icL: Candidate[L])
def ^^^(rhs: Any): Unit = ???
def ^^^ : Unit = ???
val y = x ^^^ x //ok
object Fail:
extension [L <: DFValAny](lhs: L)(using icL: Candidate[L])
def ^^^(rhs: Any): Unit = ???
def ^^^ : Unit = ???
extension [L](lhs: L)
def ^^^[R](rhs: R): Unit = ???
val y = x ^^^ x //error |
OK, so if I understand correctly, the reason my original code works now on nightly is that #19955 was resolved. But there is still an underlying overloading issue, right? |
Yes that's right, it compiles but picks the wrong (3rd) alternative. |
Based on my analysis at #20054 (comment), it appears adjusting overload resolution to be intuitive wrt. to this issue would definitely be a breaking change. @soronpo You mention that
so the current issue is not a regression per se after all, is it? |
You are correct. The part that has regressed was fixed. I do think the overloading needs to be fixed, but if we can't tie the knot of the rules well, then we should avoid further regressions first. |
This has been decided to be worked on in 3.7.0 (TBD what's the timing on that). |
What kind of warning? It's already an error. I would caution from adding redundant warnings. They only increase technical debt with false positives and specific version suppression. Better no action until 3.7. |
It is not in cases such as those discussed in #20054 (comment) and #20054 (comment)
We plan of warning (in 3.6.0) about the changes in overload resolution which would apply in 3.7.0. |
@Gedochao was warning applied in 3.6.x? I don't think I saw a PR fo it. |
This regression in 3.4.1 first caused me to chase down the wrong rabbit hole of #19955, so it could be related somehow, but I doubt it.
This is a very weird bug, that can disappear if we remove one of the following:
def ^^^ : Unit = ???
(using check: c.OutW =:= c.OutW)
from the thirddef ^^^
declarationThe third
^^^
definition should not be considered for overloading at all because the first one is the more specific.The error also disappear if we split
x ^^^ x ^^^ x
into two separate vals.Compiler version
Last good release: 3.4.1-RC1-bin-20240126-1716bcd-NIGHTLY
First bad release: 3.4.1-RC1-bin-20240129-b20747d-NIGHTLY
bisect: cce2933 in #19096
Minimized code
Output
Expectation
No error.
The text was updated successfully, but these errors were encountered: