Skip to content

Commit

Permalink
No longer print VBAR in the middle of the message
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Grigg <tomegrigg@gmail.com>
  • Loading branch information
kiendang and griggt committed Oct 26, 2021
1 parent 968dd1b commit f4936b3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
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

0 comments on commit f4936b3

Please sign in to comment.