Skip to content

Scala 3 REPL regression compared to Scala 2: echoed strings are trimmed when they shouldn't, loosing e.g. newline-characters #11558

Closed
@bjornregnell

Description

@bjornregnell

Compiler version

3.0.0-RC2-bin-20210227-07d9dd2-NIGHTLY

Minimized code

The Scala 3 REPL trim all string values before echoing, which means that leading whitespace newline is lost and multi-line strings will get first line miss-aligned etc.

scala> case class Box(x: String) { override def toString = s"\n$x" }                                                           
// defined case class Box

Output

scala> Box("new line is lost")
val res0: Box = new line is lost

scala> Box("1 2 3\n1 2 3\n1 2 3")
val res1: Box = 1 2 3
1 2 3
1 2 3

Expectation

Welcome to Scala 2.13.4 (OpenJDK 64-Bit Server VM, Java 11.0.10).
Type in expressions for evaluation. Or try :help.

scala> case class Box(x: String) { override def toString = s"\n$x" }
class Box

scala> Box("new line is NOT lost")
val res0: Box =

new line is NOT lost

scala> Box("1 2 3\n1 2 3\n1 2 3")
val res1: Box =

1 2 3
1 2 3
1 2 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions