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

Regression in 2.12.9 with large string interpolation #11665

Closed
anilkumarmyla opened this issue Aug 5, 2019 · 4 comments

Comments

@anilkumarmyla
Copy link

commented Aug 5, 2019

Small reproducible sample which compiles fine but fails during runtime. This runs fine with 2.12.8 upto a reasonable limit but fails right at size=33 with 2.12.9

scala> val a: Int = 1
a: Int = 1

scala> val b: String = s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a" // 32 times
b: String = 11111111111111111111111111111111

scala> val b: String = s"$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a" // 33 times
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')
  ... 36 elided

Also happens with any Long/Float/Double values

val a: Int = 1
val a: Long = 1L
val a: Float = 1.1f
val a: Double = 1.1d

Note that when val a: String = "y" 2.12.8 fails with StackOverFlow error for large interpolation (128 times), 2.12.9 works fine

@SethTisue

This comment has been minimized.

Copy link
Member

commented Aug 5, 2019

@retronym problem with scala/scala#7996 ?

@retronym

This comment has been minimized.

Copy link
Member

commented Aug 6, 2019

Darn. I've submitted a PR to fix.

xuwei-k added a commit to scalikejdbc/scalikejdbc that referenced this issue Aug 6, 2019

@SethTisue SethTisue added the has PR label Aug 6, 2019

@som-snytt

This comment has been minimized.

Copy link

commented Aug 7, 2019

The workaround is to slap .toString at multiples of 32.

test(33, s"${a.toString}$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a${a.toString}")
test(34, s"${a.toString}$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a${a.toString}$a")

Oh, someone should write a Scalafix!

We need Scalatempfix, the migration tool which rewrites your code for one release only, then rewrites it back again.

@ShaneDelmore

This comment has been minimized.

Copy link

commented Aug 7, 2019

Point release scalafixes aren't a terrible idea. 2.12.8->2.12.9 would add them, 2.12.9->2.12.10 would remove them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.