Skip to content

Commit

Permalink
Revive original test
Browse files Browse the repository at this point in the history
Make another test to exercise the original large search behavior
  • Loading branch information
odersky committed Nov 9, 2021
1 parent 4fb5b17 commit 739dec3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
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 @@ -183,6 +183,7 @@ class CompilationTests {
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")),
compileFile("tests/neg-custom-args/i13838.scala", defaultOptions.and("-Ximplicit-search-limit", "1000")),
).checkExpectedErrors()
}

Expand Down
26 changes: 26 additions & 0 deletions tests/neg-custom-args/i13838.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Error: tests/neg-custom-args/i13838.scala:10:5 ----------------------------------------------------------------------
10 | foo // error
| ^
|no implicit argument of type Order[X] was found for parameter x$1 of method foo in object FooT
|
|where: X is a type variable
|.
|I found:
|
| FooT.OrderFFooA[F, A](FooT.OrderFFooA[F, A](/* missing */summon[Order[F[Foo[A]]]]))
|
|But given instance OrderFFooA in object FooT produces a diverging implicit search when trying to match type Order[F[Foo[A]]].
-- [E168] Type Warning: tests/neg-custom-args/i13838.scala:10:5 --------------------------------------------------------
10 | foo // error
| ^
| Implicit search problem too large.
| an implicit search was terminated with failure after trying 1000 expressions.
| The root candidate for the search was:
|
| given instance OrderFFooA in object FooT for Order[Any]}
|
| You can change the behavior by setting the `-Ximplicit-search-limit` value.
| Smaller values cause the search to fail faster.
| Larger values might make a very large search problem succeed.

longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ object Foo:
given [A: Eq]: Eq[Foo[A]] = ???

object FooT:
def liftF[F[_], A](fa: F[A]): F[Foo[A]] = map(fa)(???) // error

def foo[X](using Order[X]): Unit = ???
foo // error

def map[F[_], A](ffa: F[Foo[A]])(f: A): Nothing = ???

Expand Down

0 comments on commit 739dec3

Please sign in to comment.