tek / splain

better implicit errors for scala
MIT License
370 stars 29 forks source link

splain 0.4.1 on scala 2.13... breaks by-name implicits ? #29

Closed chwthewke closed 4 years ago

chwthewke commented 4 years ago

Hello,

I'm somewhat confused, but I think I have a weird one here.

Apparently, using splain breaks the new in Scala 2.13 "by-name implicits", such as used for generic derivation in Typelevel Kittens (https://github.com/typelevel/kittens)

A short example such as:

import cats.Show
import cats.derived.semi
import cats.instances.string._

case class Inner( x: Option[Int] )

object Inner {
  implicit val innerShow: Show[Inner] =
    Show.show( _.x.fold( "*" )( _.toString ) )
}

case class Outer( name: String, inner: Inner )

object Outer {
  implicit val outerShow: Show[Outer] = semi.show[Outer]
}

compiles fine without splain but fails with splain. The failing output is:

[error] !I ev: MkShow[Outer]
[error] Lazy.instance invalid because
[error] !I ev: <byname>[MkShow[Outer]]
[error]     implicit val outerShow: Show[Outer] = semi.show[Outer]

which seems to point towards a by-name implicit in kittens (which should indeed occur somewhere in the expected derivation).

Should it be useful, I've put a minimal-ish reproduction at https://github.com/chwthewke/splain-by-name (not so minimal because it starts from my usual template sadly, but I took care to disable anything that could interfere so it should reproduce nicely). The project has two modules with the same source, one with splain active, the other without. It targets scala 2.13.1 but from other testing I think 2.13.0 is similarly affected.

Thank you

tek commented 4 years ago

thanks! will take a look

tek commented 4 years ago

here we go. damn default arguments! :imp: :smile: I did quite a bit of (unrelated) restructuring, so there might be unintended side effects. If something is weird, please report!

chwthewke commented 4 years ago

Whoa that was fast! Many thanks!