-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Infinite loop in subtyping check #318
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
Good example! We do know that subtyping proof search can lead to infinite http://research.microsoft.com/apps/pubs/default.aspx?id=64041 But when we deal with just classes this can be handled by making all If I remember correctly, in essence the condition excluded deep F-bounds of class C[T <: D[D[T]]] It strikes me that your example can be also seen as a deep F-bound. Both A So, maybe we need a finitary condition for abstract types, similar to the
On Sun, Dec 21, 2014 at 11:43 PM, Samuel Gruetter [email protected]
Martin Odersky |
This is a very interesting paper, especially section 5.2. Btw I found the commit where you implemented this for scalac: scala/scala@152563b But now that type parameters are encoded as abstract type members, we should adapt this "finitary condition" to abstract types, as you suggest. Here's my attempt to adapt the definitions: A set a) For all Note that the same way as "closed under inheritance and decomposition" in the paper is with respect to a class table, "bd-closed" is with respect to a context The bd-closure of a set A context With these definitions, we can claim that a derivation of Then we would need to adapt their procedure which checks if a class table is finitary to get a procedure which checks if a context is finitary. The subtyping algorithm to decide That sounds like a nice plan, except that the condition (b) looks a bit fishy to me: If the types in
Unfortunately, the types used in the paper don't allow bounds for type parameters, which makes it a bit harder to adapt to DOT. You probably meant that in essence, the condition excludes
So you mean by "inlining" the definitions of trait Y {
type A <: { type T >: { type T >: A } }
type B >: { type T >: { type T >: B } }
} If we do this, both scalac and dotty detect an "illegal cyclic reference". |
FYI this is not (or not anymore) an infinite loop
|
The fix for #2397 in PR #2402 turn #318 in an infinite loop again. |
Hi @newca12 - thanks for reporting and pointing us to the pending file. We'll try to get to this during the week! Cheers, |
The infinite loop is still there. (pending/pos/subtypcycle.scala) |
Since dotty 0.6.0-RC1, this now fail immediately with a stack overflow. Stack traceException in thread "main" java.lang.StackOverflowError at java.util.Arrays.copyOfRange(Arrays.java:3484) at java.util.Arrays.copyOfRange(Arrays.java:3441) at java.lang.invoke.MethodType.insertParameterTypes(MethodType.java:396) at java.lang.invoke.MemberName.getInvocationType(MemberName.java:168) at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:167) at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:81) at java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1660) at java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:1617) at java.lang.invoke.MethodHandles$Lookup.getDirectMethodForConstant(MethodHandles.java:1802) at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1751) at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477) at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:661) at dotty.tools.dotc.core.Types$Type.memberExcluding(Types.scala:497) at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:487) at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:1742) at dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:1988) at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2000) at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:1956) at dotty.tools.dotc.core.Types$TypeMap.derivedSelect(Types.scala:3755) at dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedSelect(Types.scala:4022) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.op1$1(TypeOps.scala:61) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:54) at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:3829) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.op1$1(TypeOps.scala:67) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:54) at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:3822) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.op1$1(TypeOps.scala:67) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:54) at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:3831) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.op1$1(TypeOps.scala:67) at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:54) at dotty.tools.dotc.core.TypeOps.asSeenFrom(TypeOps.scala:28) at dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:760) at dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1073) at dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1066) at dotty.tools.dotc.core.Denotations$PreDenotation.asSeenFrom(Denotations.scala:131) at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1599) at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:514) at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:658) at dotty.tools.dotc.core.Types$Type.memberExcluding(Types.scala:497) at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:487) at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:1742) at dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:1988) at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2000) at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:1956) at dotty.tools.dotc.core.Types$TypeMap.derivedSelect(Types.scala:3755) at dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedSelect(Types.scala:4022) ... |
This now handles all errors from scala#4368 to scala#4372 and also scala#318.
This now handles all errors from scala#4368 to scala#4372 and also scala#318.
This now handles all errors from scala#4368 to scala#4372 and also scala#318.
This now handles all errors from scala#4368 to scala#4372 and also scala#318.
#4385 was meant to cover this too, so closing. I added |
Backport "Add enum type param support in sourceSymbol" to 3.3 LTS
While looking for counterexamples to narrowing in DOT, I found this example:
Which sends dotty into an infinite loop checking if
y.A <: y.B
.scalac
has the same problem, see SI-9056.The text was updated successfully, but these errors were encountered: