Skip to content

type inference regression in scalaz: #8290

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
scabug opened this issue Feb 15, 2014 · 5 comments
Closed

type inference regression in scalaz: #8290

scabug opened this issue Feb 15, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Feb 15, 2014

Regressed in the last few days. I'm minimizing.

[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:34: no type parameters for method @>>>: (g: scalaz.typelevel.Func[G,scalaz.Applicative,Int,C])scalaz.typelevel.Func[[α]scalaz.IndexedStateT[[+X]X,Boolean,Boolean,G[α]],scalaz.Applicative,Char,C] exist so that it can be applied to arguments (scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Int,Int])
[info] [error]  --- because ---
[info] [error] argument expression's type is not compatible with formal parameter type;
[info] [error]  found   : scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Int,Int]
[info] [error]  required: scalaz.typelevel.Func[?G,scalaz.Applicative,Int,?C]
[info] [error]     } @>>> AppFuncU { (x: Int) => x }
[info] [error]       ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:34: type mismatch;
[info] [error]  found   : scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Int,Int]
[info] [error]  required: scalaz.typelevel.Func[G,scalaz.Applicative,Int,C]
[info] [error]     } @>>> AppFuncU { (x: Int) => x }
[info] [error]                     ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:37: inferred type arguments [scalaz.typelevel.HNilFunc[scalaz.Applicative,Char,Int]] do not conform to method consA's type parameter bounds [T <: scalaz.typelevel.HListFunc[scalaz.Applicative,Char,C]]
[info] [error]     val countAll = countChar :: countLine :: (countWord consA AppFunc.HNil[Char, Int])
[info] [error]                                                         ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:37: type mismatch;
[info] [error]  found   : scalaz.typelevel.HNilFunc[scalaz.Applicative,Char,Int]
[info] [error]  required: T
[info] [error]     val countAll = countChar :: countLine :: (countWord consA AppFunc.HNil[Char, Int])
[info] [error]                                                                           ^
[info] [error] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/scalaz-ed3e47fa9f094bafa5a3d1e31a267bb37099953b/example/src/main/scala/scalaz/example/WordCount.scala:40: recursive value x$4 needs type
[info] [error]     val charCount :: lineCount ::  wordCountState :: HNil = countAll traverse text
[info] [error]  
@scabug
Copy link
Author

scabug commented Feb 15, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8290?orig=1
Reporter: @retronym
See #7753

@scabug
Copy link
Author

scabug commented Feb 15, 2014

@retronym said:
/cc adriaan: dbuild caught another one

@scabug
Copy link
Author

scabug commented Feb 15, 2014

@retronym said:
Behaviour changed at #7753 / c0edf768912

@scabug
Copy link
Author

scabug commented Feb 15, 2014

@retronym said:
Diff of -Xprint:typer of WordCount.scala: https://gist.github.com/retronym/9024155

@scabug
Copy link
Author

scabug commented Feb 15, 2014

@retronym said:
Not sure if we can do much about this.

We are inferring an equivalent type here:

-      val countChar: scalaz.typelevel.Func[scalaz.Unapply[scalaz.Applicative,Int]{type M[X] = Int; type A = Int}#M,scalaz.Applicative,Char,Int] = scalaz.typelevel.AppFuncU.apply[Char, Int](((c: Char) => 1))(scalaz.this.Unapply.unapplyA[scalaz.Applicative, Int](scalaz.this.Applicative.monoidApplicative[Int](scalaz.std.anyVal.intInstance)));
+      val countChar: scalaz.typelevel.Func[[X]Int,scalaz.Applicative,Char,Int] = scalaz.typelevel.AppFuncU.apply[Char, Int](((c: Char) => 1))(scalaz.this.Unapply.unapplyA[scalaz.Applicative, Int](scalaz.this.Applicative.monoidApplicative[Int](scalaz.std.anyVal.intInstance)));

But later one, we're unable to unify the PolyType [X]Int with the HKTypeVar ?G

res1 = {scala.reflect.internal.Types$ClassNoArgsTypeRef@3182}"Int"
res2 = {scala.reflect.internal.Types$AppliedTypeVar@3322}"?G[_]"
substitutes = {scala.collection.immutable.$colon$colon@3329}"::" size = 1
tp1 = {scala.reflect.internal.Types$PolyType@3169}"[X]Int"
tp2 = {scala.reflect.internal.Types$PolyType@3316}"[_]?G[_]"
tparams1 = {scala.collection.immutable.$colon$colon@3181}"::" size = 1
(0)  = {scala.reflect.internal.Symbols$AbstractTypeSymbol@3207}"type X"
tparams2 = {scala.collection.immutable.$colon$colon@3190}"::" size = 1
(0)  = {scala.reflect.internal.Symbols$AbstractTypeSymbol@3194}"type _"
      (tparams1 corresponds tparams2)(cmp) && (sub1(res1) <:< sub2(res2))
Int <:< ?G[X]
-----------------------
this = {scala.reflect.internal.Types$ClassNoArgsTypeRef@3182}"Int"
scala.reflect.internal.tpe.TypeComparers$class.cmp$1(scala.reflect.internal.SymbolTable, scala.reflect.internal.Symbols$Symbol, scala.reflect.internal.Symbols$Symbol, scala.collection.immutable.List, scala.collection.immutable.List, boolean, scala.collection.immutable.List) = true
that = {scala.reflect.internal.Types$AppliedTypeVar@3364}"?G[X]"

Which hits #2712.

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

No branches or pull requests

2 participants