Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
.
  • Loading branch information
lihaoyi committed Sep 1, 2025
commit 236abf267e6ed03b21716daa0ddb90d4be15ac31
4 changes: 2 additions & 2 deletions compiler/test-resources/repl/19184
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scala> def o(s: String) = "o"; def oo(s: String) = "oo"; val o = "o"; val oo = "oo"
def o(s: String): String
def oo(s: String): String
val o: String = o
val oo: String = oo
val o: String = "o"
val oo: String = "oo"
2 changes: 1 addition & 1 deletion compiler/test-resources/repl/i13181
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scala> scala.compiletime.codeOf(1+2)
val res0: String = 1 + 2
val res0: String = "1 + 2"
2 changes: 1 addition & 1 deletion compiler/test-resources/repl/i1369
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scala> print("foo")
foo
scala> "Hello"
val res0: String = Hello
val res0: String = "Hello"
28 changes: 14 additions & 14 deletions compiler/test-resources/repl/i15493
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ scala> NInt(23)
val res0: NInt = NInt@17

scala> res0.toString
val res1: String = NInt@17
val res1: String = "rs$line$1$NInt@17"
Copy link
Contributor Author

@lihaoyi lihaoyi Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's happening here before this PR, but there must be some super sketchy stdout-regexing happening to mangle the .toString so it looks different when returned or println-ed.

scala> res0.toString
val res1: String = NInt@17
                                                                                                                          
scala> println(res0.toString)
rs$line$1$NInt@17

The new behavior is probably better: we special case returning because it uses pprint, println is just println, and if someone wants pprint themselves they can use dotty.shaded.pprint.log

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


scala> 23
val res2: Int = 23
Expand All @@ -17,7 +17,7 @@ scala> NBoolean(true)
val res3: NBoolean = NBoolean@4cf

scala> res3.toString
val res4: String = NBoolean@4cf
val res4: String = "rs$line$5$NBoolean@4cf"

scala> true
val res5: Boolean = true
Expand All @@ -29,7 +29,7 @@ scala> NByte(1)
val res6: NByte = NByte@1

scala> res6.toString
val res7: String = NByte@1
val res7: String = "rs$line$9$NByte@1"

scala> val res8: Byte = 1
val res8: Byte = 1
Expand All @@ -41,7 +41,7 @@ scala> NShort(1)
val res9: NShort = NShort@1

scala> res9.toString
val res10: String = NShort@1
val res10: String = "rs$line$13$NShort@1"

scala> val res11: Short = 1
val res11: Short = 1
Expand All @@ -53,10 +53,10 @@ scala> NLong(1)
val res12: NLong = NLong@1

scala> res12.toString
val res13: String = NLong@1
val res13: String = "rs$line$17$NLong@1"

scala> 1L
val res14: Long = 1
val res14: Long = 1L

scala> class NFloat(val x: Float) extends AnyVal
// defined class NFloat
Expand All @@ -65,7 +65,7 @@ scala> NFloat(1L)
val res15: NFloat = NFloat@3f800000

scala> res15.toString
val res16: String = NFloat@3f800000
val res16: String = "rs$line$21$NFloat@3f800000"

scala> 1.0F
val res17: Float = 1.0F
Expand All @@ -77,7 +77,7 @@ scala> NDouble(1D)
val res18: NDouble = NDouble@3ff00000

scala> res18.toString
val res19: String = NDouble@3ff00000
val res19: String = "rs$line$25$NDouble@3ff00000"

scala> 1.0D
val res20: Double = 1.0
Expand All @@ -89,7 +89,7 @@ scala> NChar('a')
val res21: NChar = NChar@61

scala> res21.toString
val res22: String = NChar@61
val res22: String = "rs$line$29$NChar@61"

scala> 'a'
val res23: Char = 'a'
Expand All @@ -101,7 +101,7 @@ scala> NString("test")
val res24: NString = NString@364492

scala> res24.toString
val res25: String = NString@364492
val res25: String = "rs$line$33$NString@364492"

scala> "test"
val res26: String = "test"
Expand All @@ -113,7 +113,7 @@ scala> CustomToString(23)
val res27: CustomToString = Test23

scala> res27.toString
val res28: String = Test23
val res28: String = "Test23"

scala> class `<>`(x: Int) extends AnyVal
// defined class <>
Expand All @@ -122,7 +122,7 @@ scala> `<>`(23)
val res29: <> = less$greater@17

scala> res29.toString
val res30: String = less$greater@17
val res30: String = "rs$line$40$less$greater@17"

scala> class `🤪`(x: Int) extends AnyVal
// defined class 🤪
Expand All @@ -131,7 +131,7 @@ scala> `🤪`(23)
val res31: 🤪 = uD83E$uDD2A@17

scala> res31.toString
val res32: String = uD83E$uDD2A@17
val res32: String = "rs$line$43$uD83E$uDD2A@17"

scala> object Outer { class Foo(x: Int) extends AnyVal }
// defined object Outer
Expand All @@ -140,7 +140,7 @@ scala> Outer.Foo(23)
val res33: Outer.Foo = Outer$Foo@17

scala> res33.toString
val res34: String = Outer$Foo@17
val res34: String = "rs$line$46$Outer$Foo@17"

scala> Vector.unapplySeq(Vector(2))
val res35: scala.collection.SeqFactory.UnapplySeqWrapper[Int] = scala.collection.SeqFactory$UnapplySeqWrapper@df507bfd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ scala>:settings -Vrepl-max-print-elements:2
scala>:settings -Vrepl-max-print-characters:50

scala> Seq(1,2,3)
val res1: Seq[Int] = List(1, 2) ... large output truncated, print value to show all
val res1: Seq[Int] = List(1, 2, 3)

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
scala> 1.to(10).mkString
val res0: String = 12345678910
val res0: String = "12345678910"

scala>:settings -Vrepl-max-print-characters:10

scala> 1.to(10).mkString
val res1: String = 123456789 ... large output truncated, print value to show all
val res1: String = "12345678910"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old -Vrepl-max-print-elements and -Vrepl-max-print-characters:10 don't work with PPrint. Instead, we can control the max width and height before truncation. As a first pass I'd say we can do that in a follow up, but if people really want I can add those -Vrepl-width and -Vrepl-height in this PR

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ val res0: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
scala>:settings -Vrepl-max-print-elements:20

scala> 1.to(300).toList
val res1: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20) ... large output truncated, print value to show all
val res1: List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300)

Loading