forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#13266 from dwijnand/repl-diagnostic-print
- Loading branch information
Showing
29 changed files
with
183 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
scala> object Foo { val bar = new Object { def baz = 1 }; bar.baz } | ||
-- Error: | ||
-- [E008] Not Found Error: ----------------------------------------------------- | ||
1 | object Foo { val bar = new Object { def baz = 1 }; bar.baz } | ||
| ^^^^^^^ | ||
| value baz is not a member of Object | ||
| value baz is not a member of Object | ||
1 error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,110 @@ | ||
scala> class Inv[T](x: T) | ||
// defined class Inv | ||
scala> val x: List[String] = List(1) | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val x: List[String] = List(1) | ||
| ^ | ||
| Found: (1 : Int) | ||
| Required: String | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> val y: List[List[String]] = List(List(1)) | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val y: List[List[String]] = List(List(1)) | ||
| ^ | ||
| Found: (1 : Int) | ||
| Required: String | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> val z: (List[String], List[Int]) = (List(1), List("a")) | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val z: (List[String], List[Int]) = (List(1), List("a")) | ||
| ^ | ||
| Found: (1 : Int) | ||
| Required: String | ||
-- Error: | ||
longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val z: (List[String], List[Int]) = (List(1), List("a")) | ||
| ^^^ | ||
| Found: ("a" : String) | ||
| Required: Int | ||
longer explanation available when compiling with `-explain` | ||
2 errors found | ||
scala> val a: Inv[String] = new Inv(new Inv(1)) | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val a: Inv[String] = new Inv(new Inv(1)) | ||
| ^^^^^^^^^^ | ||
| Found: Inv[Int] | ||
| Required: String | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> val b: Inv[String] = new Inv(1) | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val b: Inv[String] = new Inv(1) | ||
| ^ | ||
| Found: (1 : Int) | ||
| Required: String | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; } | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; } | ||
| ^ | ||
|Found: (C.this.x : C.this.T) | ||
|Required: T² | ||
| | ||
|where: T is a type in class C | ||
| T² is a type in the initializer of value s which is an alias of String | ||
-- Error: | ||
longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; } | ||
| ^ | ||
|Found: (y : T) | ||
|Required: T² | ||
| | ||
|where: T is a type in the initializer of value s which is an alias of String | ||
| T² is a type in method f which is an alias of Int | ||
longer explanation available when compiling with `-explain` | ||
2 errors found | ||
scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr | ||
-- Error: | ||
-- [E008] Not Found Error: ----------------------------------------------------- | ||
1 | class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr | ||
| ^^^^^^^^ | ||
| value barr is not a member of Foo - did you mean foo.bar? | ||
1 error found | ||
scala> val x: List[Int] = "foo" :: List(1) | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | val x: List[Int] = "foo" :: List(1) | ||
| ^^^^^ | ||
| Found: ("foo" : String) | ||
| Required: Int | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> while ((( foo ))) {} | ||
-- Error: | ||
-- [E006] Not Found Error: ----------------------------------------------------- | ||
1 | while ((( foo ))) {} | ||
| ^^^ | ||
| Not found: foo | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> val a: iDontExist = 1 | ||
-- Error: | ||
-- [E006] Not Found Error: ----------------------------------------------------- | ||
1 | val a: iDontExist = 1 | ||
| ^^^^^^^^^^ | ||
| Not found: type iDontExist | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> def foo1(x: => Int) = x _ | ||
-- Error: | ||
-- [E099] Syntax Error: -------------------------------------------------------- | ||
1 | def foo1(x: => Int) = x _ | ||
| ^^^ | ||
|Only function types can be followed by _ but the current expression has type Int | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> def foo2(x: => Int): () => Int = x _ | ||
-- Error: | ||
-- [E099] Syntax Error: -------------------------------------------------------- | ||
1 | def foo2(x: => Int): () => Int = x _ | ||
| ^^^ | ||
|Only function types can be followed by _ but the current expression has type Int | ||
longer explanation available when compiling with `-explain` | ||
1 error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
scala> val xs = scala.collection.mutable.ListBuffer[Int] | ||
-- Error: | ||
-- [E081] Type Error: ---------------------------------------------------------- | ||
1 | val xs = scala.collection.mutable.ListBuffer[Int] | ||
| ^ | ||
| Missing parameter type | ||
| | ||
| I could not infer the type of the parameter elems. | ||
1 error found | ||
scala> val xs = scala.collection.mutable.ListBuffer[Int]() | ||
val xs: scala.collection.mutable.ListBuffer[Int] = ListBuffer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
scala> try 1 | ||
-- Warning: | ||
1 warning found | ||
-- [E000] Syntax Warning: ------------------------------------------------------ | ||
1 | try 1 | ||
| ^^^^^ | ||
| A try without catch or finally is equivalent to putting | ||
| its body in a block; no exceptions are handled. | ||
longer explanation available when compiling with `-explain` | ||
val res0: Int = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
scala> object Lives { class Private { def foo1: Any = new Private.C1; def foo2: Any = new Private.C2 }; object Private { class C1 private {}; private class C2 {} } } | ||
-- Error: | ||
-- Error: ---------------------------------------------------------------------- | ||
1 | object Lives { class Private { def foo1: Any = new Private.C1; def foo2: Any = new Private.C2 }; object Private { class C1 private {}; private class C2 {} } } | ||
| ^^^^^^^^^^ | ||
|constructor C1 cannot be accessed as a member of Lives.Private.C1 from class Private. | ||
1 error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
scala> class Foo extends Bar // with one tab | ||
-- Error: | ||
-- [E006] Not Found Error: ----------------------------------------------------- | ||
1 | class Foo extends Bar // with one tab | ||
| ^^^ | ||
| Not found: type Bar | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> class Foo extends Bar // with spaces | ||
-- Error: | ||
-- [E006] Not Found Error: ----------------------------------------------------- | ||
1 | class Foo extends Bar // with spaces | ||
| ^^^ | ||
| Not found: type Bar | ||
longer explanation available when compiling with `-explain` | ||
1 error found | ||
scala> class Foo extends Bar // with tabs | ||
-- Error: | ||
-- [E006] Not Found Error: ----------------------------------------------------- | ||
1 | class Foo extends Bar // with tabs | ||
| ^^^ | ||
| Not found: type Bar | ||
longer explanation available when compiling with `-explain` | ||
1 error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
scala> def x | ||
-- Error: | ||
-- [E019] Syntax Error: -------------------------------------------------------- | ||
1 | def x | ||
| ^ | ||
| Missing return type | ||
longer explanation available when compiling with `-explain` | ||
scala> def x: Int | ||
-- Error: | ||
-- [E067] Syntax Error: -------------------------------------------------------- | ||
1 | def x: Int | ||
| ^ | ||
|Declaration of method x not allowed here: only classes can have declared but undefined members | ||
1 error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
scala> class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } } | ||
-- Error: | ||
-- Error: ---------------------------------------------------------------------- | ||
1 | class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } } | ||
| ^^^ | ||
| foo is not accessible from constructor arguments | ||
| foo is not accessible from constructor arguments | ||
1 error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
scala> def foo(x: Option[Int]) = x match { case None => } | ||
-- Warning: | ||
1 warning found | ||
-- [E029] Pattern Match Exhaustivity Warning: ---------------------------------- | ||
1 | def foo(x: Option[Int]) = x match { case None => } | ||
| ^ | ||
| match may not be exhaustive. | ||
| | ||
| It would fail on pattern case: Some(_) | ||
def foo(x: Option[Int]): Unit | ||
longer explanation available when compiling with `-explain` | ||
def foo(x: Option[Int]): Unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
scala> object test { type ::[A, B]; def a: Int :: Int = ???; def b: Int = a } | ||
-- Error: | ||
-- [E007] Type Mismatch Error: ------------------------------------------------- | ||
1 | object test { type ::[A, B]; def a: Int :: Int = ???; def b: Int = a } | ||
| ^ | ||
| Found: Int :: Int | ||
| Required: Int | ||
longer explanation available when compiling with `-explain` | ||
1 error found |
Oops, something went wrong.