You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it looks like the compiler wasted a lot of recursion stacks and failed to compile something equivalent to type B;type A <: B
[Error] /home/peng/git/dottyspike/core/src/main/scala/com/tribbloids/spike/dotty/improvement/IncrementalPoset.scala:16:12:Recursion limit exceeded.
Maybe there is an illegal cyclic reference?If that's not the case, you could also try to increase the stacksize using the -XssJVM option.
For the unprocessed stack trace, compile with-Xno-decode-stacktraces.
A recurring operation is (inner to outer):
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
...
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
find-member C1.A
find-member C1.B
Expectation
In worst case, the error for above code should be equivalent to its inlined form:
objectC2 {
/* <--------illegal cyclic type reference: upper bound com.tribbloids.spike.dotty.improvement.IncrementalPoset.SubType1.C2.B of type A refers back to the type itself Run with -explain-cyclic for more details.*/typeA<:BtypeB>:A
} // should be equivalent to:objectC3 { // <------- no errortypeBtypeA<:B
}
But I don't think it's a good solution, the above declaration doesn't introduce any cycles/monotonicity violation despite having cyclic reference, it should be legit.
Preferably, the compiler should use an algorithm to incrementally build a subtype Heyting semilattice by detecting cycles upon adding each new declaration, eventually leading to a semilattice of types and e-classes with a holistic bound representation. The latest of such algorithm is able to do it in almost linear time (https://www.youtube.com/watch?v=Im2aAL2J988), integrating it into the compiler should pose little obstacle
Afterwards the following cases can benefit from the same impl:
objectSubType2 {
objectC1 {
typeA<:BtypeB<:A
} // v3.5.2: illegal cyclic type reference error// expectation: cycle with <=1 trait detected, should add A and B into an e-class and keep compiling, which leads to the equivalent form:objectC2 {
typeAtypeB=A
}
}
objectSubType2_traits {
traitX {
traitBtraitAextendsB
}
traitY {
typeA;
typeB<:A
}
objectC1extendsXwithY// v3.5.2: succeed, really shouldn't happen// expectation: cycle with >=2 traits detected, should throw an error immediately
}
objectSubType3 {
objectC1 {
typeA<:BtypeB<:CtypeC<:A
} // v3.5.2: illegal cyclic type reference error// should be equivalent to:objectC2 {
typeAtypeB=AtypeC=A
}
}
objectTypeClass3 { // functionally equivalent to SubType3traitA; traitB; traitCgiven (
using
b: B
):A=???given (
using
c: C
):B=???given (
using
a: A
):C=???
{ // succeed in v3.5.2, but search can be fastergivenC=???
summon[A]
summon[B]
}
{ // succeed in v3.5.2, but search can be fastergivenA=???
summon[C]
summon[B]
}
}
objectTransitiveConversion3 { // functionally equivalent to SubType3traitA; traitB; traitCgivenidentity[_X]:Conversion[_X, _X] = { x =>
x
}
given [_B](
using
cc: Conversion[_B, B]
):Conversion[A, _B] =???given [_C](
using
cc: Conversion[_C, C]
):Conversion[B, _C] =???given [_A](
using
cc: Conversion[_A, A]
):Conversion[C, _A] =???vara:A=???varb:B=???varc:C=???
a = c
/* implicit not found error in v3.5.2 Found: (com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.c : com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3. C)Required: com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.AExplanation===========Tree: com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.cI tried to show that (com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.c : com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3. C)conforms to com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.Abut none of the attempts shown below succeeded: ==> (com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.c : com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3. C ) <: com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.A CachedTermRef CachedTypeRef ==> com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.C <: com.tribbloids.spike.dotty.improvement.IncrementalPoset.TransitiveConversion3.A CachedTypeRef CachedTypeRef = falseThe tests were made under the empty constraint*/
}
Obviously it would be far beyond the scope of the "Recursion limit exceeded." bug, so feel free to suggest to move it elsewhere (e.g. Scala Contributor forum or another ticket)
The text was updated successfully, but these errors were encountered:
Compiler version
3.5.2
Output
it looks like the compiler wasted a lot of recursion stacks and failed to compile something equivalent to
type B;type A <: B
Expectation
In worst case, the error for above code should be equivalent to its inlined form:
But I don't think it's a good solution, the above declaration doesn't introduce any cycles/monotonicity violation despite having cyclic reference, it should be legit.
Preferably, the compiler should use an algorithm to incrementally build a subtype Heyting semilattice by detecting cycles upon adding each new declaration, eventually leading to a semilattice of types and e-classes with a holistic bound representation. The latest of such algorithm is able to do it in almost linear time (https://www.youtube.com/watch?v=Im2aAL2J988), integrating it into the compiler should pose little obstacle
Afterwards the following cases can benefit from the same impl:
Obviously it would be far beyond the scope of the "Recursion limit exceeded." bug, so feel free to suggest to move it elsewhere (e.g. Scala Contributor forum or another ticket)
The text was updated successfully, but these errors were encountered: