diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-08-10 17:58:17 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-08-13 03:44:52 -0400 |
commit | 55dec4dc6e8f8430810d212c73e78ffbb92e0a48 (patch) | |
tree | 2880ec2360764311c30afdba74ace624ef642cb1 /compiler/GHC/HsToCore/Binds.hs | |
parent | 7831fe05021caa90d4696ca91ae2b31a82e65b3d (diff) | |
download | haskell-55dec4dc6e8f8430810d212c73e78ffbb92e0a48.tar.gz |
PmCheck: Better long-distance info for where bindings (#18533)
Where bindings can see evidence from the pattern match of the `GRHSs`
they belong to, but not from anything in any of the guards (which belong
to one of possibly many RHSs).
Before this patch, we did *not* consider said evidence, causing #18533,
where the lack of considering type information from a case pattern match
leads to failure to resolve the vanilla COMPLETE set of a data type.
Making available that information required a medium amount of
refactoring so that `checkMatches` can return a
`[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each
`GRHSs` of the match group. The first component of the pair is the
covered set of the pattern, the second component is one covered set per
RHS.
Fixes #18533.
Regression test case: T18533
Diffstat (limited to 'compiler/GHC/HsToCore/Binds.hs')
-rw-r--r-- | compiler/GHC/HsToCore/Binds.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/GHC/HsToCore/Binds.hs b/compiler/GHC/HsToCore/Binds.hs index 2a61406792..5e01bc7a8f 100644 --- a/compiler/GHC/HsToCore/Binds.hs +++ b/compiler/GHC/HsToCore/Binds.hs @@ -33,7 +33,7 @@ import {-# SOURCE #-} GHC.HsToCore.Match ( matchWrapper ) import GHC.HsToCore.Monad import GHC.HsToCore.GuardedRHSs import GHC.HsToCore.Utils -import GHC.HsToCore.PmCheck ( addTyCsDs, checkGuardMatches ) +import GHC.HsToCore.PmCheck ( addTyCsDs, checkGRHSs ) import GHC.Hs -- lots of things import GHC.Core -- lots of things @@ -78,7 +78,6 @@ import GHC.Types.Unique.Set( nonDetEltsUniqSet ) import GHC.Utils.Monad import qualified GHC.LanguageExtensions as LangExt import Control.Monad -import Data.List.NonEmpty ( nonEmpty ) {-********************************************************************** * * @@ -185,8 +184,8 @@ dsHsBind dflags b@(FunBind { fun_id = L loc fun dsHsBind dflags (PatBind { pat_lhs = pat, pat_rhs = grhss , pat_ext = NPatBindTc _ ty , pat_ticks = (rhs_tick, var_ticks) }) - = do { rhss_deltas <- checkGuardMatches PatBindGuards grhss - ; body_expr <- dsGuarded grhss ty (nonEmpty rhss_deltas) + = do { rhss_deltas <- checkGRHSs PatBindGuards grhss + ; body_expr <- dsGuarded grhss ty rhss_deltas ; let body' = mkOptTickBox rhs_tick body_expr pat' = decideBangHood dflags pat ; (force_var,sel_binds) <- mkSelectorBinds var_ticks pat body' |