-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
java.lang.UnsupportedOperationException: Position.point on NoPosition in chimney 0.8.0 #411
Comments
|
Hey, thanks for the ticket! I would need:
I don't see our macros in the stack trace, so I can only guess there is a bug in the compiler which we haven't triggered before and are triggering now(?). When I google It doesn't have to be super minimized or using only Chimney, just remove all NDA-company-specific details. Alternatively I found a similar ticker for scala/bug#10604. I am not sure if it is still relevant but you might try increasing the stack size and see if that's an issue with hidden StackOverflow inside a compiler. |
Scala version is 2.13.12. |
I was able to pinpoint the error to an interaction with Circe, specifically if there is a configured codec |
|
When I am testing your code in Scastie it compiles. Could you check if setting e.g. |
We're already at |
But indeed the Scastie is working fine 😕 |
The issue seems to be with the compiler setting As soon as I disable this setting, the code compiles. |
Unfortunatelly, I still cannot reproduce. I created this Scala CLI snippet, but it runs without issues. //> using scala 2.13.12
//> using options -Wmacros:both -verbose -Xlog-implicits
//> using dep io.scalaland::chimney::0.8.0
//> using dep io.circe::circe-generic::0.14.6
//> using dep io.circe::circe-generic-extras::0.14.3
import io.circe.Codec
import io.circe.generic.extras.Configuration
import io.circe.generic.extras.semiauto.deriveConfiguredCodec
import io.circe.generic.semiauto.deriveCodec
import io.scalaland.chimney.dsl._
object ChimneyBug {
private def handleEvent(state: State, event: Event) =
(state, event) match {
case (active: State.Active, updated: Event.A) =>
// Working: active.using(updated).patch
active.patchUsing(updated)
}
sealed trait Event
object Event {
case class A(
a: String,
) extends Event
implicit val configuration = Configuration.default.withDiscriminator("class").withDefaults
implicit val codec: Codec[Event] = deriveConfiguredCodec
// Working: implicit val codec: Codec[Event] = deriveCodec
}
sealed trait State
object State {
case class Active(
a: String,
) extends State
implicit val configuration = Configuration.default.withDiscriminator("class").withDefaults
implicit val codec: Codec[State] = deriveConfiguredCodec
// Working: implicit val codec: Codec[Event] = deriveCodec
}
def test = handleEvent(ChimneyBug.State.Active("A"), ChimneyBug.Event.A("B"))
}
object Main {
def main(args: Array[String]): Unit =
println(ChimneyBug.test)
}
There must be something more to your setup which produces the error. Do you use the newest sbt, are you using Windows? |
Please also add the option |
Alternatively Any of them in combination with |
I commented on the Scala ticket that it is failing just sorting warnings by position: probably it's not defensive about unpositioned trees produced by the macro. In that case, the workaround is not to lint it with |
Thanks! |
I have seen these errors quite often recently in my code base (using upgraded to 0.8.0 chimney for conversions to scalapb-generated hierarchy), usually appearing at some point when adding more and more of data structures. The only pattern I have found was related to missing internal conversions in the ADT for chimney, however instead of expected macro compile error for missing transformations, it was bluntly reported by NoPosition. |
@codesurf42 if it's not |
Since this issue seem to be related to a compiler's bug, I'll close it for now. When the fix is released I'll add the information about it to the documentation. |
Hi there,
my codebase was working fine with Chimney 0.7.x, but now I'm hitting a serious compilation exception:
java.lang.UnsupportedOperationException: Position.point on NoPosition
.Unfortunately there's no hint where this might happen. We're using
transformInto
,into.withXYZ.transform
,using.ignoreRedundantPatcherFields.patch
all over the place, sometimes even wrapped.Full stack trace:
Since the stack trace might not be very helpful, can you give me a hint in what kind of construct this might be occurring? We're making extensive use of Chimney so this is kind of tedious to debug.
The text was updated successfully, but these errors were encountered: