Skip to content

REPL silently hides the fact that rendering of large structures are elided (no ... is shown as in Scala2 REPL) #11377

Closed
@bjornregnell

Description

@bjornregnell

Compiler version

3.0.0-M4-bin-20210209-a66eaf3-NIGHTLY

Minimized code + Output

scala> val xs = collection.immutable.ArraySeq.fill(100)(0)

scala> val ys = xs :+ 11111  // works as expected, last elem is 11111
val ys: scala.collection.immutable.ArraySeq[Int] = ArraySeq(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11111)

scala> val xs = collection.immutable.ArraySeq.fill(1000)(0)  

scala> val ys = xs :+ 11111  // HERE THE LAST printed elem by the REPL echo is 0 (sic!) 
val ys: scala.collection.immutable.ArraySeq[Int] = ArraySeq(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
[... many zeros and commas elided by me, the reporter]
0, 0, 0, 0, 0, 0, 0)

scala> ys.toString  // but this works, last line of output is as expeced: 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11111)

This is happening because of this:
https://github.com/lampepfl/dotty/blob/a7cb965fc9b106c9c85965afed96bda34e9063f5/compiler/src/dotty/tools/repl/Rendering.scala#L32

Expectation

When large structures are elided the REPL printout should end with ... as in Scala2 REPL to indicate that not everything is shown.

It is especially confusing that it ends with ,0) instead of , ... as this made me think that all elements where in the output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions