Skip to content
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

False positive of "Unreachable case" warning under macro type match #18507

Closed
soronpo opened this issue Sep 3, 2023 · 1 comment · Fixed by #18510
Closed

False positive of "Unreachable case" warning under macro type match #18507

soronpo opened this issue Sep 3, 2023 · 1 comment · Fixed by #18510
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices area:pattern-matching itype:bug regression This worked in a previous version but doesn't anymore

Comments

@soronpo
Copy link
Contributor

soronpo commented Sep 3, 2023

Compiler version

Fails on 3.3.1-RC7
Fails on latest nightly (3.4.0-RC1-bin-20230901-89e8dba-NIGHTLY)
Last good release: 3.3.1-RC1-bin-20230301-0df5ae2-NIGHTLY
First bad release: 3.3.1-RC1-bin-20230302-8020c77-NIGHTLY
First bad commit: 6b36cd9

Minimized code

//> using options -Xfatal-warnings
import scala.quoted.*

trait DFValOf[T]

def calcWidth(x: List[Type[Any]])(using Quotes): Unit =
  x.collect { case '[DFValOf[t]] => ???}

Output

7 |  x.collect { case '[DFValOf[t]] => ???}
  |                   ^^^^^^^^^^^^^
  |                   Unreachable case

Expectation

No warning (no error under fatal-warnings).

@soronpo soronpo added itype:bug area:pattern-matching regression This worked in a previous version but doesn't anymore area:metaprogramming:quotes Issues related to quotes and splices labels Sep 3, 2023
@dwijnand dwijnand self-assigned this Sep 4, 2023
@dwijnand
Copy link
Member

dwijnand commented Sep 4, 2023

The compiler is right here (not a regression) because Type[DFValOf[t]] is provably disjoint from Type[Any], seeing as Type is invariant.

However, if I switch to List[Type[?]] then the compiler also thinks that Type[DFValOf[t]] and Type[?] are disjoint... So I'll submit a fix for that version of the program.

@dwijnand dwijnand linked a pull request Sep 4, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices area:pattern-matching itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants