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

Ensure default case folding only happens when default is last #1084

Merged
merged 2 commits into from Oct 28, 2021

Commits on Oct 25, 2021

  1. Ensure default case folding only happens when default is last

    I failed to consider if multiple branches could evaluate to the test condition. Eg,
    
    ```js
    switch (true) {
        case definitely_true:
        default:
          return 'definitely';
        case maybe_true:
          return 'maybe';
    }
    ```
    
    Here, both `definitely_true` and `maybe_true` can be `=== true`. And we can't eliminate the `case definitely_true:`, because it prevents us from falling into the `maybe_true` branch (when it is true).
    jridgewell committed Oct 25, 2021
    Copy the full SHA
    90db20c View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    7315c7d View commit details
    Browse the repository at this point in the history