Skip to content

Fix #13026: No longer print VBAR and padding in the middle of the message #13829

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

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 7 additions & 5 deletions compiler/src/dotty/tools/dotc/printing/Texts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ object Texts {
case Str(s, lines) =>
if (numberWidth != 0) {
val ln = lines.show
val pad = (numberWidth - ln.length - 1)
assert(pad >= 0)
sb.append(" " * pad)
sb.append(ln)
sb.append("|")
if (ln.nonEmpty) {
val pad = (numberWidth - ln.length - 1)
assert(pad >= 0)
sb.append(" " * pad)
sb.append(ln)
sb.append("|")
}
}
sb.append(s)
case _ =>
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class CompilationTests {
compileFile("tests/neg-custom-args/i7314.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
compileFile("tests/neg-custom-args/feature-shadowing.scala", defaultOptions.and("-Xfatal-warnings", "-feature")),
compileDir("tests/neg-custom-args/hidden-type-errors", defaultOptions.and("-explain")),
compileFile("tests/neg-custom-args/i13026.scala", defaultOptions.and("-print-lines")),
).checkExpectedErrors()
}

Expand Down
18 changes: 18 additions & 0 deletions tests/neg-custom-args/i13026.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- [E007] Type Mismatch Error: tests/neg-custom-args/i13026.scala:1:13 -------------------------------------------------
1 |val x: Int = "not an int" // error
| ^^^^^^^^^^^^
| Found: ("not an int" : String)
| Required: Int

longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg-custom-args/i13026.scala:2:13 -------------------------------------------------
2 |val y: Int = "not an int" // error
| ^^^^^^^^^^^^
| Found: ("not an int" : String)
| Required: Int

longer explanation available when compiling with `-explain`
-- [E008] Not Found Error: tests/neg-custom-args/i13026.scala:3:20 -----------------------------------------------------
3 |def foo(x: Any) = x.foo // error
| ^^^^^
| value foo is not a member of Any
3 changes: 3 additions & 0 deletions tests/neg-custom-args/i13026.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val x: Int = "not an int" // error
val y: Int = "not an int" // error
def foo(x: Any) = x.foo // error