Skip to content
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

Skolems escape with -Xstrict-inference #7990

Closed
scabug opened this issue Nov 21, 2013 · 9 comments
Closed

Skolems escape with -Xstrict-inference #7990

scabug opened this issue Nov 21, 2013 · 9 comments

Comments

@scabug
Copy link

scabug commented Nov 21, 2013

With -Xstrict-inference, per #6680:

The inferred type of blah below should have something like forSome {type A >: AnyVal} at the end of it; instead, it refers to the (now free) type variable A from BoxF.

scala> sealed abstract class Box[+A]; case class BoxF[A](f: A => A) extends Box[A]
defined class Box
defined class BoxF

scala> def blah = ((BoxF((_:Int)+1):Box[AnyVal]) match {case BoxF(f) => f; case _ => ???})
blah: A => A

scala> def blah2 = (blah, blah)
blah2: (A => A, A => A)

scala> blah2 : ((A => A, A => A) forSome {type A})
res0: (A => A, A => A) forSome { type A } = (<function1>,<function1>)

I shouldn't be able to give the ascription that resulted in res0.

Notwithstanding what seems to be merely a printing issue (the two A s in the blah4 definition seem to be different internally, as expected), when I throw out the free variable explicitly I get what I expect.

scala> def blah3 = blah : ((A => A) forSome {type A})
blah3: A => A forSome { type A }

scala> def blah4 = (blah3, blah3)
blah4: (A => A, A => A) forSome { type A; type A }

scala> blah4 : ((A => A, A => A) forSome {type A})
<console>:14: error: type mismatch;
 found   : (A(in value res1) => A(in value res1), (some other)A(in value res1) => (some other)A(in value res1)) where type (some other)A(in value res1), type A(in value res1)
 required: (A => A, A => A) forSome { type A }

              blah4 : ((A => A, A => A) forSome {type A})
              ^
@scabug
Copy link
Author

scabug commented Nov 21, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7990?orig=1
Reporter: Stephen Compall (s11001001)
Affected Versions: 2.11.0-M7
See #6680, #7952, #7991

@scabug
Copy link
Author

scabug commented Nov 21, 2013

@retronym said:
Just for reference, running with -Ydebug -uniqid helps to disambiguate printed symbols.

@scabug
Copy link
Author

scabug commented Nov 22, 2013

@retronym said:
See also #7952 for unsoundness with mixed covariant/invariant types in pattern matching.

@scabug
Copy link
Author

scabug commented Nov 22, 2013

@retronym said:
A little work in the right direction: https://github.com/retronym/scala/compare/ticket;7990?expand=1

@scabug
Copy link
Author

scabug commented Nov 22, 2013

@retronym said:
Also relevant: scala/scala@29bcade

@scabug
Copy link
Author

scabug commented Nov 22, 2013

@retronym said:
/cc Adriaan

@SethTisue
Copy link
Member

closing on the assumption that -Xstrict-inference isn't maintained anymore. correct me if I'm wrong

@milessabin
Copy link

If that's the case then we probably need an issue to rip the strictInference code paths out.

@SethTisue
Copy link
Member

scala/scala#6593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants