isUnLiftedType, typeKind, mkForAllTy, mkFunTy,
isUnboxedTupleType, isSubKind,
substTyWith, emptyTvSubst, extendTvInScope,
- TvSubst, TvSubstEnv, setTvSubstEnv, substTy,
+ TvSubst, TvSubstEnv, mkTvSubst, setTvSubstEnv, substTy,
extendTvSubst, composeTvSubst, isInScope,
getTvSubstEnv, getTvInScope )
import TyCon ( isPrimTyCon )
import BasicTypes ( RecFlag(..), Boxity(..), isNonRec )
-import CmdLineOpts
+import StaticFlags ( opt_PprStyle_Debug )
+import DynFlags ( DynFlags, DynFlag(..), dopt )
import Outputable
#ifdef DEBUG
= do
-- Report result size if required
-- This has the side effect of forcing the intermediate to be evaluated
- debugTraceMsg dflags $
- " Result size = " ++ show (coreBindsSize binds)
+ debugTraceMsg dflags 2 $
+ (text " Result size =" <+> int (coreBindsSize binds))
-- Report verbosely, if required
dumpIfSet_core dflags dump_flag pass_name (pprCoreBindings binds)
--
-- Things are *not* OK if:
--
- -- * Unsaturated type app before specialisation has been done;
+ -- * Unsaturated type app before specialisation has been done;
--
- -- * Oversaturated type app after specialisation (eta reduction
+ -- * Oversaturated type app after specialisation (eta reduction
-- may well be happening...);
\begin{code}
= case (initL (lint_binds binds)) of
Nothing -> showPass dflags ("Core Linted result of " ++ whoDunnit)
Just bad_news -> printDump (display bad_news) >>
- ghcExit 1
+ ghcExit dflags 1
where
-- Put all the top-level binders in scope at the start
-- This is because transformation rules can bring something
= do { actual_ty <- lintCoreExpr expr
; checkTys actual_ty ann_ty (mkCaseAltMsg expr actual_ty ann_ty) }
-lintCoreAlt :: Type -- Type of scrutinee; a fixed point of
- -- the substitution
- -> Type -- Type of the alternative
+lintCoreAlt :: OutType -- Type of scrutinee
+ -> OutType -- Type of the alternative
-> CoreAlt
-> LintM ()
lintCoreAlt scrut_ty alt_ty alt@(LitAlt lit, args, rhs) =
do { checkL (null args) (mkDefaultArgsMsg args)
- ; checkTys lit_ty scrut_ty
- (mkBadPatMsg lit_ty scrut_ty)
+ ; checkTys lit_ty scrut_ty (mkBadPatMsg lit_ty scrut_ty)
; checkAltExpr rhs alt_ty }
where
lit_ty = literalType lit
; con_type <- lintTyApps (dataConRepType con) tvs'
; mapM lintBinder ids -- Lint Ids in the refined world
; lintCoreArgs con_type (map Var ids)
- ; checkAltExpr rhs alt_ty
+ ; let refined_alt_ty = substTy (mkTvSubst in_scope refine) alt_ty
+ -- alt_ty is already an OutType, so don't re-apply
+ -- the current substitution. But we must apply the
+ -- refinement so that the check in checkAltExpr is ok
+ ; checkAltExpr rhs refined_alt_ty
} } }
| otherwise -- Scrut-ty is wrong shape