Commit 6f8550a3 authored by Sebastian Graf's avatar Sebastian Graf Committed by Marge Bot

Move pattern match checker modules to GHC.HsToCore.PmCheck

parent 97811ef5
Pipeline #10756 passed with stages
in 408 minutes and 31 seconds
......@@ -11,7 +11,7 @@ Pattern Matching Coverage Checking.
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE LambdaCase #-}
module Check (
module GHC.HsToCore.PmCheck (
-- Checking and printing
checkSingle, checkMatches, checkGuardMatches,
needToRunPmCheck, isMatchContextPmChecked,
......@@ -24,9 +24,9 @@ module Check (
import GhcPrelude
import PmTypes
import PmOracle
import PmPpr
import GHC.HsToCore.PmCheck.Types
import GHC.HsToCore.PmCheck.Oracle
import GHC.HsToCore.PmCheck.Ppr
import BasicTypes (Origin, isGenerated)
import CoreSyn (CoreExpr, Expr(Var))
import CoreUtils (exprType)
......@@ -331,7 +331,7 @@ checkMatches dflags ctxt vars matches = do
(vcat (map ppr matches)))
res <- case matches of
-- Check EmptyCase separately
-- See Note [Checking EmptyCase Expressions] in PmOracle
-- See Note [Checking EmptyCase Expressions] in GHC.HsToCore.PmCheck.Oracle
[] | [var] <- vars -> checkEmptyCase' var
_normal_match -> checkMatches' vars matches
dsPmWarn dflags ctxt res
......@@ -388,7 +388,7 @@ checkMatches' vars matches
-- | Check an empty case expression. Since there are no clauses to process, we
-- only compute the uncovered set. See Note [Checking EmptyCase Expressions]
-- in "PmOracle" for details.
-- in "GHC.HsToCore.PmCheck.Oracle" for details.
checkEmptyCase' :: Id -> DsM PmResult
checkEmptyCase' x = do
delta <- getPmDelta
......@@ -458,9 +458,9 @@ mkPmLitPattern :: PmLit -> PatVec
mkPmLitPattern lit@(PmLit _ val)
-- We translate String literals to list literals for better overlap reasoning.
-- It's a little unfortunate we do this here rather than in
-- 'PmOracle.trySolve' and 'PmOracle.addRefutableAltCon', but it's so much
-- 'GHC.HsToCore.PmCheck.Oracle.trySolve' and 'GHC.HsToCore.PmCheck.Oracle.addRefutableAltCon', but it's so much
-- simpler here.
-- See Note [Representation of Strings in TmState] in PmOracle
-- See Note [Representation of Strings in TmState] in GHC.HsToCore.PmCheck.Oracle
| PmLitString s <- val
, let mk_char_lit c = mkPmLitPattern (PmLit charTy (PmLitChar c))
= foldr (\c p -> mkListPatVec charTy (mk_char_lit c) p)
......@@ -890,7 +890,7 @@ the paper. This Note serves as a reference for these new features.
variables. The information about the shape of a variable is encoded in
the oracle state 'Delta' instead.
* Handling of uninhabited fields like `!Void`.
See Note [Strict argument type constraints] in PmOracle.
See Note [Strict argument type constraints] in GHC.HsToCore.PmCheck.Oracle.
* Efficient handling of literal splitting, large enumerations and accurate
redundancy warnings for `COMPLETE` groups through the oracle.
-}
......@@ -1161,7 +1161,7 @@ pmcheck (_:_) _ [] _ _ = panic "pmcheck: cons-nil"
addPmConCts :: Delta -> Id -> PmAltCon -> [EvVar] -> PatVec -> DsM (Maybe (Delta, ValVec))
addPmConCts delta x con dicts field_pats = do
-- mk_id will re-use the variable name if possible. The x ~ x is easily
-- discharged by the oracle at no overhead (see 'PmOracle.addVarVarCt').
-- discharged by the oracle at no overhead (see 'GHC.HsToCore.PmCheck.Oracle.addVarVarCt').
let mk_id (PmVar _ x) = pure (Just x)
mk_id p@PmCon{} = Just <$> mkPmId (pmPatType p)
mk_id PmGrd{} = pure Nothing -- PmGrds have arity 0, so just forget about them
......
......@@ -10,7 +10,7 @@ Authors: George Karachalias <george.karachalias@cs.kuleuven.be>
-- 'addTmCt', 'addVarCoreCt', 'addRefutableAltCon' and 'addTypeEvidence' for
-- adding facts to the oracle, and 'provideEvidenceForEquation' to turn a
-- 'Delta' into a concrete evidence for an equation.
module PmOracle (
module GHC.HsToCore.PmCheck.Oracle (
DsM, tracePm, mkPmId,
Delta, initDelta, canDiverge, lookupRefuts, lookupSolution,
......@@ -28,7 +28,7 @@ module PmOracle (
import GhcPrelude
import PmTypes
import GHC.HsToCore.PmCheck.Types
import DynFlags
import Outputable
......
......@@ -2,7 +2,7 @@
-- | Provides factilities for pretty-printing 'Delta's in a way appropriate for
-- user facing pattern match warnings.
module PmPpr (
module GHC.HsToCore.PmCheck.Ppr (
pprUncovered
) where
......@@ -23,8 +23,8 @@ import Util
import Maybes
import Data.List.NonEmpty (NonEmpty, nonEmpty, toList)
import PmTypes
import PmOracle
import GHC.HsToCore.PmCheck.Types
import GHC.HsToCore.PmCheck.Oracle
-- | Pretty-print the guts of an uncovered value vector abstraction, i.e., its
-- components and refutable shapes associated to any mentioned variables.
......
......@@ -8,9 +8,9 @@ Author: George Karachalias <george.karachalias@cs.kuleuven.be>
{-# LANGUAGE TupleSections #-}
-- | Types used through-out pattern match checking. This module is mostly there
-- to be imported from "TcRnTypes". The exposed API is that of "PmOracle" and
-- "Check".
module PmTypes (
-- to be imported from "TcRnTypes". The exposed API is that of
-- "GHC.HsToCore.PmCheck.Oracle" and "GHC.HsToCore.PmCheck".
module GHC.HsToCore.PmCheck.Types (
-- * Representations for Literals and AltCons
PmLit(..), PmLitValue(..), PmAltCon(..), pmLitType, pmAltConType,
......
module PmTypes where
module GHC.HsToCore.PmCheck.Types where
import GhcPrelude ()
......
......@@ -29,7 +29,7 @@ import {-# SOURCE #-} Match( matchWrapper )
import DsMonad
import DsGRHSs
import DsUtils
import Check ( needToRunPmCheck, addTyCsDs, checkGuardMatches )
import GHC.HsToCore.PmCheck ( needToRunPmCheck, addTyCsDs, checkGuardMatches )
import GHC.Hs -- lots of things
import CoreSyn -- lots of things
......
......@@ -25,7 +25,7 @@ import DsListComp
import DsUtils
import DsArrows
import DsMonad
import Check ( checkGuardMatches )
import GHC.HsToCore.PmCheck ( checkGuardMatches )
import Name
import NameEnv
import FamInstEnv( topNormaliseType )
......
......@@ -25,7 +25,7 @@ import CoreUtils (bindNonRec)
import BasicTypes (Origin(FromSource))
import DynFlags
import Check (needToRunPmCheck, addTyCsDs, addPatTmCs, addScrutTmCs)
import GHC.HsToCore.PmCheck (needToRunPmCheck, addTyCsDs, addPatTmCs, addScrutTmCs)
import DsMonad
import DsUtils
import Type ( Type )
......
......@@ -70,7 +70,7 @@ import BasicTypes ( Origin )
import DataCon
import ConLike
import TyCon
import PmTypes
import GHC.HsToCore.PmCheck.Types
import Id
import Module
import Outputable
......
......@@ -25,7 +25,7 @@ import GHC.Hs
import TcHsSyn
import TcEvidence
import TcRnMonad
import Check
import GHC.HsToCore.PmCheck
import CoreSyn
import Literal
import CoreUtils
......
......@@ -333,10 +333,10 @@ Library
CoreStats
MkCore
PprCore
PmOracle
PmPpr
PmTypes
Check
GHC.HsToCore.PmCheck.Oracle
GHC.HsToCore.PmCheck.Ppr
GHC.HsToCore.PmCheck.Types
GHC.HsToCore.PmCheck
Coverage
Desugar
DsArrows
......
......@@ -167,7 +167,7 @@ import TcType
import Annotations
import InstEnv
import FamInstEnv
import {-# SOURCE #-} PmTypes (Delta)
import {-# SOURCE #-} GHC.HsToCore.PmCheck.Types (Delta)
import IOEnv
import RdrName
import Name
......
-- | The following match demonstrates why we need to detect cyclic solutions
-- when extending 'PmOracle.tm_pos'.
-- when extending 'GHC.HsToCore.PmCheck.Oracle.tm_pos'.
--
-- TLDR; solving @x :-> y@ where @x@ is the representative of @y@'s equivalence
-- class can easily lead to a cycle in the substitution.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment