Skip to content

Commit 5eef0c6

Browse files
Merge pull request #13829 from kiendang/fix-13026
Fix #13026: No longer print VBAR and padding in the middle of the message
2 parents 608344a + f4936b3 commit 5eef0c6

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

compiler/src/dotty/tools/dotc/printing/Texts.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ object Texts {
106106
case Str(s, lines) =>
107107
if (numberWidth != 0) {
108108
val ln = lines.show
109-
val pad = (numberWidth - ln.length - 1)
110-
assert(pad >= 0)
111-
sb.append(" " * pad)
112-
sb.append(ln)
113-
sb.append("|")
109+
if (ln.nonEmpty) {
110+
val pad = (numberWidth - ln.length - 1)
111+
assert(pad >= 0)
112+
sb.append(" " * pad)
113+
sb.append(ln)
114+
sb.append("|")
115+
}
114116
}
115117
sb.append(s)
116118
case _ =>

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class CompilationTests {
182182
compileFile("tests/neg-custom-args/i7314.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
183183
compileFile("tests/neg-custom-args/feature-shadowing.scala", defaultOptions.and("-Xfatal-warnings", "-feature")),
184184
compileDir("tests/neg-custom-args/hidden-type-errors", defaultOptions.and("-explain")),
185+
compileFile("tests/neg-custom-args/i13026.scala", defaultOptions.and("-print-lines")),
185186
).checkExpectedErrors()
186187
}
187188

tests/neg-custom-args/i13026.check

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- [E007] Type Mismatch Error: tests/neg-custom-args/i13026.scala:1:13 -------------------------------------------------
2+
1 |val x: Int = "not an int" // error
3+
| ^^^^^^^^^^^^
4+
| Found: ("not an int" : String)
5+
| Required: Int
6+
7+
longer explanation available when compiling with `-explain`
8+
-- [E007] Type Mismatch Error: tests/neg-custom-args/i13026.scala:2:13 -------------------------------------------------
9+
2 |val y: Int = "not an int" // error
10+
| ^^^^^^^^^^^^
11+
| Found: ("not an int" : String)
12+
| Required: Int
13+
14+
longer explanation available when compiling with `-explain`
15+
-- [E008] Not Found Error: tests/neg-custom-args/i13026.scala:3:20 -----------------------------------------------------
16+
3 |def foo(x: Any) = x.foo // error
17+
| ^^^^^
18+
| value foo is not a member of Any

tests/neg-custom-args/i13026.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
val x: Int = "not an int" // error
2+
val y: Int = "not an int" // error
3+
def foo(x: Any) = x.foo // error

0 commit comments

Comments
 (0)