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

[Typechecker | Regression] Intersection with enum types disables switch exhaustion check #8563

Open
lexidor opened this issue Sep 16, 2019 · 3 comments
Assignees

Comments

@lexidor
Copy link
Collaborator

lexidor commented Sep 16, 2019

HHVM Version

HipHop VM 4.23.0-dev (rel)
Compiler: 1568605624_509374463
Repo schema: d3aeac4022c6a43fc3660e7d8141465a7fbb14c2
hackc-9f58f3799749c8d2680054e2c26f95325770390d-4.23.0-dev

Operating System and Version

Ubuntu 18.04

Standalone code, or other way to reproduce the problem

enum NUMBERS: string {
    ONE = 'ONE';
    TWO = 'TWO';
}

<<__EntryPoint>>
function snippet(): void {
    $one = 'ONE';
    $one as NUMBERS;
    switch ($one) {
        case NUMBERS::ONE:
            ;
    }

    $two = 'TWO';
    $two = NUMBERS::assert($two);
    switch ($two) {
        case NUMBERS::ONE:
            ;
    }
}

Actual result

hh_client 
Typing[4019] Switch statement nonexhaustive; the following cases are missing: TWO
   --> src/file.hack
  6 | enum NUMBERS: string {
    |      ^^^^^^^ Enum declared here
 22 |     switch ($two) {
    |             ^^^^

1 error found.

Expected result

Check about $one too.

@lexidor
Copy link
Collaborator Author

lexidor commented Jun 2, 2020

Edited repro, because empty switch{} statements are a parse error in newer hhvm versions.

@fredemmott
Copy link
Contributor

@vsiles @CatherineGasnier 53a12e2 from @sarahhenkens is a suggested fix for this which appears to work, but looks like it's essentially a revert 7824d82 - do you have context to share on that or an alternative approach?

@CatherineGasnier
Copy link
Contributor

I've commented on 53a12e2

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