Skip to content

False kind inference error, with confusing error message #9950

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

Closed
scabug opened this issue Oct 6, 2016 · 2 comments
Closed

False kind inference error, with confusing error message #9950

scabug opened this issue Oct 6, 2016 · 2 comments
Milestone

Comments

@scabug
Copy link

scabug commented Oct 6, 2016

Below is the output of the REPL when pasting the content of the attached file. First of all, I wouldn't expect any error. Second, this error message is confusing:

    class Option has one type parameter, but type F has one

$ ./scala-2.12.0-RC1/bin/scala
Welcome to Scala 2.12.0-RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala> :paste
// Entering paste mode (ctrl-D to finish)

import scala.language.higherKinds

trait Foo[A] {
  type F[_]
}

object Foo {
  // two identical auxiliary type aliases
  type Aux1[A, F0[_]] = Foo[A] { type F[X] = F0[X] }
  type Aux2[A, F0[_]] = Foo[A] { type F[X] = F0[X] }

  def bar[A, F[_]](a: A)(implicit ev: Foo.Aux1[A, F]): Foo.Aux1[A, F] = ev

  implicit def ev: Foo.Aux1[String, Option] = new Foo[String] { type F[X] = Option[X] }

  val fooStringOption: Foo.Aux2[String, Option] = bar("hi")
}

// Exiting paste mode, now interpreting.

<console>:26: error: inferred kinds of the type arguments (String,Option[X]) do not conform to the expected kinds of the type parameters (type A,type F).
Option[X]'s type parameters do not match type F's expected parameters:
class Option has one type parameter, but type F has one
         val fooStringOption: Foo.Aux2[String, Option] = bar("hi")
                                                         ^
<console>:26: error: type mismatch;
 found   : String("hi")
 required: A
         val fooStringOption: Foo.Aux2[String, Option] = bar("hi")
                                                             ^

scala> 
@scabug
Copy link
Author

scabug commented Oct 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9950?orig=1
Reporter: Tomas Mikula (tomas.mikula-at-gmail.com)
Affected Versions: 2.12.0-RC1
Attachments:

@som-snytt
Copy link

compiles in 2.13 but not 2.12.20

@SethTisue SethTisue added this to the 2.13.0 milestone May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants