Skip to content

dotty REPL shows the Array hexcode instead of actual elements #4067

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

Closed
prayagupa opened this issue Mar 4, 2018 · 3 comments
Closed

dotty REPL shows the Array hexcode instead of actual elements #4067

prayagupa opened this issue Mar 4, 2018 · 3 comments

Comments

@prayagupa
Copy link

prayagupa commented Mar 4, 2018

Minor issue that dotty REPL shows "hex representation of hashcode" of the array instead of showing elements in it.

scala> val data = Array(1, 3, 5, 7, 11).map(x => x * x) 
val data: Array[Int] = [I@6eda012b
scala> data.toString 
val res11: String = "[I@6eda012b"

while "scalac REPL" shows the elements which I think is expected in REPL.

scala> val data = Array(1, 3, 5, 7, 11).map(x => x * x)
data: Array[Int] = Array(1, 9, 25, 49, 121)

scala> data.toString
res11: String = [I@3071d086

Seq works fine in dotty REPL.

scala> Seq(1, 3, 5, 7, 11).map(x => x * x) 
val res12: Seq[Int] = List(1, 9, 25, 49, 121)

Solution probably is to use java.lang.Arrays.toString or different toString.

scala> java.util.Arrays.toString(Array(1, 3, 5, 7, 11)) 
val res19: String = "[1, 3, 5, 7, 11]"

environment

$ dotc -version
Dotty compiler version 0.6.0-RC1 -- Copyright 2002-2018, LAMP/EPFL

$ dotr -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
@allanrenucci
Copy link
Contributor

A simple solution would be to add an implicit Show instance for Array in https://github.com/lampepfl/dotty/blob/master/library/src/dotty/Show.scala

@jendrikw
Copy link

jendrikw commented Mar 6, 2018

I want to try this in the next few days.

@pgabara
Copy link

pgabara commented Mar 27, 2018

Hi @jendrikw.

Sorry but I missed your update. I hope you did not start work on it yet.
Cheers!

allanrenucci added a commit that referenced this issue Mar 27, 2018
Fix #4067 dotty REPL shows the Array hexcode instead of actual elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants