Skip to content
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

Compilation fails when source is generated with spread operator #270

Closed
JamesMcIntosh opened this issue Jun 20, 2024 · 6 comments
Closed

Comments

@JamesMcIntosh
Copy link
Contributor

JamesMcIntosh commented Jun 20, 2024

We have been having intermittent issues with the tzdb plugin where it generates the tzdb_java.scala using the spread operator.

Seems it might be related to:
cquiroz/scala-java-time#66

[error] /opt/atlassian/pipelines/agent/build/scala/application/admin/target/scala-2.12/src_managed/main/tzdb/tzdb_java.scala:174:346: illegal start of simple expression                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ^
[error]     val America_Puerto_Rico: scala.scalajs.js.Dynamic = js.Dynamic.literal(("s", -15865), ("w", -15865), ("t", scala.scalajs.js.Array[scala.scalajs.js.Array[Int]](scala.scalajs.js.Array[Int](1899087, 43200, -15865, -14400))), ("l", scala.scalajs.js.Array[scala.scalajs.js.Array[Int]](scala.scalajs.js.Array[Int](1899087, 43200, -15865, -14400), ...(1942123, 0, -14400, -10800), scala.scalajs.js.Array[Int](1945273, 7200, -10800, -14400))), ("r", ...()))
[error]                                                                                                                                                                                                                                                                                                                                                          ^
[error] /opt/atlassian/pipelines/agent/build/scala/application/admin/target/scala-2.12/src_managed/main/tzdb/tzdb_java.scala:175:3: ')' expected but '}' found.
[error]   }

The spread operator is some times even being referenced as the val type.

 val Asia_Qostanay: ... = js.Dynamic.literal(("s", 15268), ("w", 15268), ("t", ...(scala.scalajs.js.Array[Int](1924123, 0, 15268, 14400)

When there is no spread operator it compiles correctly.

    val America_Puerto_Rico: scala.scalajs.js.Dynamic = js.Dynamic.literal(("s", -15865), ("w", -15865), ("t", scala.scalajs.js.Array[scala.scalajs.js.Array[Int]](scala.scalajs.js.Array[Int](1899087, 43200, -15865, -14400))), ("l", scala.scalajs.js.Array[scala.scalajs.js.Array[Int]](scala.scalajs.js.Array[Int](1899087, 43200, -15865, -14400), scala.scalajs.js.Array[Int](1942123, 0, -14400, -10800), scala.scalajs.js.Array[Int](1945273, 7200, -10800, -14400))), ("r", scala.scalajs.js.Array[scala.scalajs.js.Array[Int]]()))

Our build environment is

JDK 11
val scalaVersion = "2.12.12"
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("io.github.cquiroz" % "sbt-tzdb" % "3.0.0")

I have also tried with an older scala-js 1.3.0.

@JamesMcIntosh
Copy link
Contributor Author

Hi @cquiroz, could you give me a quick point in the right direction to what generates these lines of code?
Thanks!
James

@cquiroz
Copy link
Owner

cquiroz commented Jun 25, 2024

Interesting, I can't easily think why it would do that
At any rate the generating code is at
https://github.com/cquiroz/kuyfi/blob/master/src/main/scala/kuyfi/TZDBCodeGenerator.scala

@JamesMcIntosh
Copy link
Contributor Author

Thanks @cquiroz, I looked through the code and also the source for treehugger which is used to do the codegen.

The Type.toString method seems like a likely candidate, if it recurses 50 times then it will return "..."

https://github.com/eed3si9n/treehugger/blob/bf6afbde14956fa6c5a850317ec37cbb934615fa/library/src/main/scala/treehugger/Types.scala#L29

The abstract class Type is a child of the Types trait which has the tostringRecursions count.

I wonder if toString is being called in parallel thus intermittently blowing out the recursive check. I need to check if our build is building TZDB in parallel too as it is contained in two Scala.js modules.

@JamesMcIntosh
Copy link
Contributor Author

Hi @cquiroz,

The two modules were being generated in parallel each with their own TZDB plugin.
I've moved the TZDB generation to a parent CrossProject so it is only generated once, this appears to have fixed the issue.
Thanks for such a helpful project and for pointing me in the right direction for the codegen!

Many thanks
James

@cquiroz
Copy link
Owner

cquiroz commented Jun 27, 2024

Oh that's interesting, would it be possible to add a comment to the README about this?

@JamesMcIntosh
Copy link
Contributor Author

I've submitted a PR which makes a basic dependant configuration suggestion, feel free to change it round as there's a few ways to write that up. #271

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

2 participants