Skip to content

Regression in 2.12.9 with large string interpolation #11665

@anilkumarmyla

Description

@anilkumarmyla

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions