arainko / ducktape

Automatic and customizable compile time transformations between similar case classes and sealed traits/enums, essentially a thing that glues your code. Scala 3 only. Or is it duct 🤔
https://arainko.github.io/ducktape/
Other
402 stars 8 forks source link

Macro crash due to implicit dependencies #195

Closed taig closed 3 weeks ago

taig commented 1 month ago

I ran into this macro expansion error while taking my very first steps with ducktape:

import scala.collection.immutable.SortedSet
import io.github.arainko.ducktape.to as convertTo
import io.github.arainko.ducktape.Transformer

final class MyClassA
final class MyClassB

given Transformer[MyClassA, MyClassB] = ???

val x: SortedSet[MyClassA] = ???

val y: SortedSet[MyClassB] = x.convertTo[SortedSet[MyClassB]]
Exception occurred while executing macro expansion.
java.util.NoSuchElementException: None.get
    at scala.None$.get(Option.scala:627)
    at scala.None$.get(Option.scala:626)
    at io.github.arainko.ducktape.internal.PlanInterpreter$.recurse(PlanInterpreter.scala:120)
    at io.github.arainko.ducktape.internal.PlanInterpreter$.run(PlanInterpreter.scala:12)
    at io.github.arainko.ducktape.internal.TotalTransformations$.createTransformationBetween(TotalTransformations.scala:27)
    at io.github.arainko.ducktape.internal.TotalTransformations$.inline$createTransformationBetween(TotalTransformations.scala:15)

https://scastie.scala-lang.org/XZGly8FpQSyEooMfm3Ex6g

Turns out that it was only a missing Ordering instance. It would be great if the error message could somehow be more helpful.

arainko commented 1 month ago

Thanks for the report. Ugh, it looks like my laziness came to bite you (the offending line even has a TODO :c) - sorry. I'll get that fixed asap.