Pmc: Don't case split on wildcard matches (#20642)
Since 8.10, when formatting a pattern match warning, we'd case split on a wildcard match such as ```hs foo :: [a] -> [a] foo [] = [] foo xs = ys where (_, ys@(_:_)) = splitAt 0 xs -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- ([], []) -- ((_:_), []) ``` But that's quite verbose and distracts from which part of the pattern was actually the inexhaustive one. We'd prefer a wildcard for the first pair component here, like it used to be in GHC 8.8. On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the different constructors we could've matched on: ```hs f :: Bool -> () f x = case x of {} -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- False -- True ``` The solution is to communicate that we want a top-level case split to `generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what this patch arranges. Details in `Note [Case split inhabiting patterns]`. Fixes #20642.
Showing
- compiler/GHC/HsToCore/Pmc.hs 42 additions, 18 deletionscompiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs 70 additions, 23 deletionscompiler/GHC/HsToCore/Pmc/Solver.hs
- testsuite/tests/dependent/should_compile/KindEqualities.stderr 1 addition, 5 deletions...uite/tests/dependent/should_compile/KindEqualities.stderr
- testsuite/tests/pmcheck/complete_sigs/T18960b.stderr 4 additions, 4 deletionstestsuite/tests/pmcheck/complete_sigs/T18960b.stderr
- testsuite/tests/pmcheck/complete_sigs/completesig06.stderr 7 additions, 7 deletionstestsuite/tests/pmcheck/complete_sigs/completesig06.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr 3 additions, 3 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase001.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr 5 additions, 5 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase002.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr 7 additions, 7 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase004.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr 6 additions, 6 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase005.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr 2 additions, 2 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase006.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr 6 additions, 6 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase007.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr 4 additions, 4 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase008.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr 3 additions, 3 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase009.stderr
- testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr 8 additions, 8 deletionstestsuite/tests/pmcheck/should_compile/EmptyCase010.stderr
- testsuite/tests/pmcheck/should_compile/T10746.stderr 1 addition, 1 deletiontestsuite/tests/pmcheck/should_compile/T10746.stderr
- testsuite/tests/pmcheck/should_compile/T11336b.stderr 1 addition, 2 deletionstestsuite/tests/pmcheck/should_compile/T11336b.stderr
- testsuite/tests/pmcheck/should_compile/T11822.stderr 9 additions, 11 deletionstestsuite/tests/pmcheck/should_compile/T11822.stderr
- testsuite/tests/pmcheck/should_compile/T15305.stderr 1 addition, 1 deletiontestsuite/tests/pmcheck/should_compile/T15305.stderr
- testsuite/tests/pmcheck/should_compile/T15450.stderr 2 additions, 2 deletionstestsuite/tests/pmcheck/should_compile/T15450.stderr
- testsuite/tests/pmcheck/should_compile/T17977.stderr 4 additions, 7 deletionstestsuite/tests/pmcheck/should_compile/T17977.stderr
Loading
Please register or sign in to comment