Skip to content

Unexpected error message when typing wildcard parameters in pattern #14760

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
Linyxus opened this issue Mar 23, 2022 · 1 comment · Fixed by #14761
Closed

Unexpected error message when typing wildcard parameters in pattern #14760

Linyxus opened this issue Mar 23, 2022 · 1 comment · Fixed by #14761

Comments

@Linyxus
Copy link
Contributor

Linyxus commented Mar 23, 2022

Compiler version

3.1.2-RC2

Minimized code

enum SUB[-A, +B]:
  case Refl[X]() extends SUB[X, X]

def foo[C, A >: C <: C, B](e: SUB[B, A]) = e match
  case SUB.Refl() =>

It seems that in the code snippet above, the compiler wrongly assumes that the wildcard argument X$1 (which is the type parameter of class Refl) is a higher-kinded type. And it complains that there is no type parameters supplied to X$1. However, it is simple-kinded.

I found that the bound A >: C <: C is necessary to trigger the error. And we have to match SUB[B, A] instead of SUB[A, B]. Not sure how these conditions are related to this issue.

Output

[info] running (fork) dotty.tools.dotc.Main -classpath /Users/linyxus/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar:/Users/linyxus/Workspace/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.1.3-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.1.3-RC1-bin-SNAPSHOT.jar -color:never issues/simple-kind-error.scala
-- [E141] Type Error: issues/simple-kind-error.scala:5:15 -----------------------------------------------------------------------------------------------------------------------------------------------------------
5 |  case SUB.Refl() =>
  |               ^
  |               Missing type parameters for X$1
  |
  | longer explanation available when compiling with `-explain`
1 error found
[error] Nonzero exit code returned from runner: 1
[error] (scala3-compiler / Compile / runMain) Nonzero exit code returned from runner: 1
[error] Total time: 3 s, completed Mar 23, 2022, 7:59:28 PM

Expectation

The code should compile.

@Linyxus Linyxus added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 23, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 23, 2022
@odersky
Copy link
Contributor

odersky commented Mar 23, 2022

It looks like the GADT constraint solver computes <: AnyKind as the nonParamBounds of X$1. This is clearly wrong. Preparing a fix.

odersky added a commit to dotty-staging/dotty that referenced this issue Mar 23, 2022
@Kordyjan Kordyjan added area:gadt and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 23, 2022
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants