Check EmptyCase by simply adding a non-void constraint
We can handle non-void constraints since !1733, so we can now express the strictness of `-XEmptyCase` just by adding a non-void constraint to the initial Uncovered set. For `case x of {}` we thus check that the Uncovered set `{ x | x /~ ⊥ }` is non-empty. This is conceptually simpler than the plan outlined in #17376, because it talks to the oracle directly. In order for this patch to pass the testsuite, I had to fix handling of newtypes in the pattern-match checker (#17248). Since we use a different code path (well, the main code path) for `-XEmptyCase` now, we apparently also handle #13717 correctly. There's also some dead code that we can get rid off now. `provideEvidence` has been updated to provide output more in line with the old logic, which used `inhabitationCandidates` under the hood. A consequence of the shift away from the `UncoveredPatterns` type is that we don't report reduced type families for empty case matches, because the pretty printer is pure and only knows the match variable's type. Fixes #13717, #17248, #17386
Showing
- compiler/GHC/HsToCore/PmCheck.hs 63 additions, 78 deletionscompiler/GHC/HsToCore/PmCheck.hs
- compiler/GHC/HsToCore/PmCheck/Oracle.hs 184 additions, 177 deletionscompiler/GHC/HsToCore/PmCheck/Oracle.hs
- compiler/GHC/HsToCore/PmCheck/Types.hs 43 additions, 43 deletionscompiler/GHC/HsToCore/PmCheck/Types.hs
- compiler/typecheck/TcBinds.hs 9 additions, 2 deletionscompiler/typecheck/TcBinds.hs
- compiler/typecheck/TcSimplify.hs 1 addition, 1 deletioncompiler/typecheck/TcSimplify.hs
- testsuite/tests/dependent/should_compile/KindEqualities.stderr 4 additions, 1 deletion...uite/tests/dependent/should_compile/KindEqualities.stderr
- testsuite/tests/pmcheck/complete_sigs/T17386.hs 18 additions, 0 deletionstestsuite/tests/pmcheck/complete_sigs/T17386.hs
- testsuite/tests/pmcheck/complete_sigs/T17386.stderr 8 additions, 0 deletionstestsuite/tests/pmcheck/complete_sigs/T17386.stderr
- testsuite/tests/pmcheck/complete_sigs/all.T 2 additions, 1 deletiontestsuite/tests/pmcheck/complete_sigs/all.T
- testsuite/tests/pmcheck/complete_sigs/completesig06.stderr 2 additions, 2 deletionstestsuite/tests/pmcheck/complete_sigs/completesig06.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase003.stderr 1 addition, 1 deletiontestsuite/tests/pmcheck/should_compile/EmptyCase003.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr 1 addition, 1 deletiontestsuite/tests/pmcheck/should_compile/EmptyCase005.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr 3 additions, 3 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase007.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr 2 additions, 2 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase008.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr 1 addition, 1 deletiontestsuite/tests/pmcheck/should_compile/EmptyCase009.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr 2 additions, 2 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase010.stderr
- testsuite/tests/pmcheck/should_compile/T10746.stderr 1 addition, 0 deletionstestsuite/tests/pmcheck/should_compile/T10746.stderr
- testsuite/tests/pmcheck/should_compile/T11336b.stderr 1 addition, 1 deletiontestsuite/tests/pmcheck/should_compile/T11336b.stderr
- testsuite/tests/pmcheck/should_compile/T11822.stderr 12 additions, 4 deletionstestsuite/tests/pmcheck/should_compile/T11822.stderr
- testsuite/tests/pmcheck/should_compile/T17248.hs 3 additions, 1 deletiontestsuite/tests/pmcheck/should_compile/T17248.hs
Loading
Please register or sign in to comment