Skip to content

Commit

Permalink
Add tests to verify that crash is fixed elsewhere. Fixes #19328 (#19329)
Browse files Browse the repository at this point in the history
Adding tests for crash reproduction #19328 that I reported, that was
already fixed in nightly.

I added the `pos` ones just in case, as protection against potential
regressions. So far I managed to reproduce the crash only when the
implicit was missing, as in `neg` tests. I can remove the `pos` tests if
you think these are excessive.

I ran only my own tests locally, they passed.

Fixes #19328

cc @soronpo
  • Loading branch information
nicolasstucki authored Feb 1, 2024
2 parents c80333e + 8d7eda4 commit a3d3cf8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/neg/i19328.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- [E172] Type Error: tests/neg/i19328.scala:14:5 ----------------------------------------------------------------------
14 | bar // error: missing implicit (should not crash)
| ^
| No given instance of type Boolean was found for parameter bool of method bar in object i19328
14 changes: 14 additions & 0 deletions tests/neg/i19328.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import scala.language.implicitConversions

object i19328:

trait Foo[B]
given foo[C]: Foo[C] = new Foo[C] {}

type Id[A] = A

implicit def wrapId[A](a: A): Id[A] = a

def bar(using bool: Boolean): Unit = ()

bar // error: missing implicit (should not crash)
4 changes: 4 additions & 0 deletions tests/neg/i19328conversion.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- [E172] Type Error: tests/neg/i19328conversion.scala:13:5 ------------------------------------------------------------
13 | bar // error: missing implicit (should not crash)
| ^
| No given instance of type Boolean was found for parameter bool of method bar in object i19328conversion
13 changes: 13 additions & 0 deletions tests/neg/i19328conversion.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object i19328conversion:

trait Foo[B]
given foo[C]: Foo[C] = new Foo[C] {}

type Id[A] = A

given wrapId[A]: Conversion[A, Id[A]] with
def apply(x: A): Id[A] = x

def bar(using bool: Boolean): Unit = ()

bar // error: missing implicit (should not crash)

0 comments on commit a3d3cf8

Please sign in to comment.