[SI-9335] The REPL incorrectly prints some strings with dollars in them Created: 28/May/15  Updated: 28/May/15

Status: Open
Project: Scala Programming Language
Component/s: Repl / Interpreter
Affects Version/s: Scala 2.11.6
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Guillaume Martres Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
mentions SI-4884 getClass.getName doesn't return a rea... CLOSED


scala> val x = "Foo$line3.$read$"
x: String = Foo
scala> x
res66: String = Foo
scala> println(x)

Comment by Seth Tisue [ 28/May/15 ]

This comes up from time to time and is always good for yucks. See also SI-4884

Comment by Guillaume Martres [ 28/May/15 ]

I guess I shoudl also say that I discovered that while playing with reflection:

scala> class A { val x: Int = 1 }
defined class A
scala> val a = classOf[A].getDeclaredFields
a: Array[java.lang.reflect.Field] = Array(private final int A.x)
scala> a(0).toString
res2: String = private final int A.x
scala> a(0).toString.toList
res3: List[Char] = List(p, r, i, v, a, t, e,  , f, i, n, a, l,  , i, n, t,  , $, l, i, n, e, 6, ., $, r, e, a, d, $, $, i, w, $, $, i, w, $, A, ., x)

Comment by A. P. Marki [ 28/May/15 ]

There's a ticket for documenting the REPL, but until then, this ought to be less of a secret:

scala> $intp.isettings.unwrapStrings = false
$intp.isettings.unwrapStrings: Boolean = false
scala> val x = "Foo$line3.$read$"
x: String = Foo$line3.$read$
scala> class A { val x: Int = 1 }
defined class A
scala> classOf[A].getDeclaredFields()(0)
res1: java.lang.reflect.Field = private final int $line7.$read$$iw$$iw$A.x

I wonder if Ammonite resolves the documentation bug already.

Generated at Sun Mar 18 03:06:22 CET 2018 using JIRA 7.0.11#70121-sha1:19d24976997c1d95f06f3e327e087be0b71f28d4.