Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Confusing error message - diverging or ambiguous implicit instead of not found #11823
Apologies if it's a duplicate. There are many issues about confusing error messages, but I couldn't find this one.
scala> :paste // Entering paste mode (ctrl-D to finish) trait Foo[A] trait Bar[A] implicit val fooInt: Foo[Int] = ??? implicit val fooLong: Foo[Long] = ??? def bar[A](implicit foo: Foo[A]): Bar[A] = ??? val barString: Bar[String] = bar // Exiting paste mode, now interpreting. val barString: Bar[String] = bar ^ <pastie>:6: error: ambiguous implicit values: both value fooInt of type => Foo[Int] and value fooLong of type => Foo[Long] match expected type Foo[A]
This often comes up when deriving typeclasses because then we tend to write:
We could of course annotate with
Maybe, but there is no covariance here.
I got interested in the cause and I find it here: