Skip to content

Render line and col in error message for clickability #2268

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
Apr 16, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ trait MessageRendering {
*/
def posStr(pos: SourcePosition, diagnosticLevel: String, message: Message)(implicit ctx: Context): String =
if (pos.exists) Blue({
val file = pos.source.file.toString
val file = s"${pos.source.file.toString}:${pos.line + 1}:${pos.column}"
val errId =
if (message.errorId ne ErrorMessageID.NoExplanationID) {
val errorNumber = message.errorId.errorNumber()
Expand Down
22 changes: 11 additions & 11 deletions tests/repl/errmsgs.check
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
scala> class Inv[T](x: T)
defined class Inv
scala> val x: List[String] = List(1)
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:4:27 ----------------------------------
4 |val x: List[String] = List(1)
| ^
| found: Int(1)
| required: String
|
scala> val y: List[List[String]] = List(List(1))
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:4:38 ----------------------------------
4 |val y: List[List[String]] = List(List(1))
| ^
| found: Int(1)
| required: String
|
scala> val z: (List[String], List[Int]) = (List(1), List("a"))
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:4:41 ----------------------------------
4 |val z: (List[String], List[Int]) = (List(1), List("a"))
| ^
| found: Int(1)
| required: String
|
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:4:50 ----------------------------------
4 |val z: (List[String], List[Int]) = (List(1), List("a"))
| ^^^
| found: String("a")
| required: Int
|
scala> val a: Inv[String] = new Inv(new Inv(1))
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:5:33 ----------------------------------
5 |val a: Inv[String] = new Inv(new Inv(1))
| ^^^^^
| found: Inv[T]
| required: String
|
| where: T is a type variable with constraint >: Int(1)
scala> val b: Inv[String] = new Inv(1)
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:5:29 ----------------------------------
5 |val b: Inv[String] = new Inv(1)
| ^
| found: Int(1)
Expand All @@ -57,15 +57,15 @@ scala> abstract class C {
}
}
}
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:9:17 ----------------------------------
9 | var y: T = x
| ^
|found: C.this.T(C.this.x)
|required: T'
|
|where: T is a type in class C
| T' is a type in the initalizer of value s which is an alias of String
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:13:21 ---------------------------------
13 | val z: T = y
| ^
|found: T(y)
Expand All @@ -74,19 +74,19 @@ scala> abstract class C {
|where: T is a type in the initalizer of value s which is an alias of String
| T' is a type in method f which is an alias of Int
scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
-- [E008] Member Not Found Error: <console> ------------------------------------
-- [E008] Member Not Found Error: <console>:4:59 -------------------------------
4 |class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr
| ^^^^^^^^
| value `barr` is not a member of Foo(foo) - did you mean `foo.bar`?
scala> val x: List[Int] = "foo" :: List(1)
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:4:19 ----------------------------------
4 |val x: List[Int] = "foo" :: List(1)
| ^^^^^
| found: String($1$)
| required: Int
|
scala> { def f: Int = g; val x: Int = 1; def g: Int = 5; }
-- [E038] Reference Error: <console> -------------------------------------------
-- [E038] Reference Error: <console>:5:15 --------------------------------------
5 |{ def f: Int = g; val x: Int = 1; def g: Int = 5; }
| ^
| `g` is a forward reference extending over the definition of `x`
Expand Down
6 changes: 3 additions & 3 deletions tests/repl/imports.check
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defined module o
scala> import o._
import o._
scala> buf += xs
-- [E007] Type Mismatch Error: <console> ---------------------------------------
-- [E007] Type Mismatch Error: <console>:11:7 ----------------------------------
11 |buf += xs
| ^^
| found: scala.collection.immutable.List[Int](o.xs)
Expand All @@ -16,12 +16,12 @@ scala> buf += xs
scala> buf ++= xs
val res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3)
scala> import util.foo
-- Error: <console> ------------------------------------------------------------
-- Error: <console>:8:12 -------------------------------------------------------
8 |import util.foo
| ^^^
| foo is not a member of util
scala> import util.foo.bar
-- [E008] Member Not Found Error: <console> ------------------------------------
-- [E008] Member Not Found Error: <console>:8:12 -------------------------------
8 |import util.foo.bar
| ^^^^^^^^
| value `foo` is not a member of util.type - did you mean `util.Left`?
Expand Down
4 changes: 2 additions & 2 deletions tests/repl/overrides.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scala> class B { override def foo(i: Int): Unit = {}; }
-- [E036] Reference Error: <console> -------------------------------------------
-- [E036] Reference Error: <console>:4:23 --------------------------------------
4 |class B { override def foo(i: Int): Unit = {}; }
| ^
| method foo overrides nothing
Expand All @@ -8,7 +8,7 @@ longer explanation available when compiling with `-explain`
scala> class A { def foo: Unit = {}; }
defined class A
scala> class B extends A { override def foo(i: Int): Unit = {}; }
-- [E037] Reference Error: <console> -------------------------------------------
-- [E037] Reference Error: <console>:5:33 --------------------------------------
5 |class B extends A { override def foo(i: Int): Unit = {}; }
| ^
| method foo has a different signature than the overridden declaration
Expand Down