Skip to content

Implicit search produces mistyped tree #8976

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

Closed
Katrix opened this issue May 13, 2020 · 1 comment
Closed

Implicit search produces mistyped tree #8976

Katrix opened this issue May 13, 2020 · 1 comment

Comments

@Katrix
Copy link
Contributor

Katrix commented May 13, 2020

Was told to create an issue for this:
https://gitter.im/lampepfl/dotty?at=5ebb35eb8c044c191498af5c

Minimized code

trait Cons[X, Y]

def solve[X, Y](using Cons[X, Y] =:= Cons[1, Cons[2, Y]]) = ()

@main def main = solve

Expectation

My first expectation for the above code was that it wouldn't compile at all. Not sure if that's the correct answer though. I'd also expect that if it did compile, I could supply the types printed by -Xprint:typer, and it would continue to compile.

The code does not compile with Scala 2.

@smarter
Copy link
Member

smarter commented May 13, 2020

That definitely shouldn't compile, -Ycheck:typer output:

Exception in thread "main" java.lang.AssertionError: assertion failed:
Found:    Cons[(1 : Int), Cons[(2 : Int), ?]] =:= Cons[(1 : Int), Cons[(2 : Int), ?]]
Required: Cons[(1 : Int), Cons[(2 : Int), ?]] =:= Cons[(1 : Int), Cons[(2 : Int), Cons[(2 : Int), ?]]]
found: ??
expected: ??
tree = <:<.refl[Cons[(1 : Int), Cons[(2 : Int), ?]]]

@smarter smarter changed the title Weird behavior with infinite type Implicit search produces mistyped tree May 13, 2020
@odersky odersky self-assigned this May 18, 2020
odersky added a commit to dotty-staging/dotty that referenced this issue May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants