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

Wrong warning on matching union types #16899

Closed
scf37 opened this issue Feb 13, 2023 · 2 comments · Fixed by #17382
Closed

Wrong warning on matching union types #16899

scf37 opened this issue Feb 13, 2023 · 2 comments · Fixed by #17382

Comments

@scf37
Copy link

scf37 commented Feb 13, 2023

Compiler version

3.2.2

Minimized code

sealed trait Unset

def foo(v: Unset|Option[Int]): Unit = v match
  case v: Unset => ()
  case v: Option[Int] => ()

Output

the type test for Option[Int] cannot be checked at runtime

Expectation

No warning. Unset is sealed trait and therefore this match should be exhaustive. For example, v: String|Option[Int] compiles without warning.

@scf37 scf37 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 13, 2023
@jchyb jchyb added area:typer area:pattern-matching and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 13, 2023
@Decel Decel mentioned this issue Mar 8, 2023
@SethTisue
Copy link
Member

SethTisue commented Mar 28, 2023

Agree this is a bug, and significant enough that I hope to see it get attention. This is fairly basic stuff, and as the report above shows, there are some forms of it that do already work.

And it came up on Discord today, so that's a second user who hit it.

I see there was an attempt to fix it which is now abandoned. I also see @dwijnand was interested enough to comment on the PR. Dale, not sure your remaining level of interest.

@liufengyun
Copy link
Contributor

Also encountered this one. It's a little annoying. Working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment