Simon Peyton Jones pushed to branch wip/T23162-spj at Glasgow Haskell Compiler / GHC

Commits:

11 changed files:

Changes:

  • compiler/GHC/Iface/Tidy/StaticPtrTable.hs
    ... ... @@ -62,25 +62,35 @@ Here is a running example:
    62 62
        f x = let k = map toUpper
    
    63 63
              in ...(static k)...
    
    64 64
     
    
    65
    -* The renamer looks for out-of-scope names in the body of the static
    
    65
    +(SF1) The renamer looks for out-of-scope names in the body of the static
    
    66 66
       form, as always. If all names are in scope, the free variables of the
    
    67 67
       body are stored in AST at the location of the static form.
    
    68 68
     
    
    69
    -* The typechecker verifies that all free variables occurring in the
    
    69
    +(SF2) The typechecker verifies that all free variables occurring in the
    
    70 70
       static form are floatable to top level (see Note [Meaning of
    
    71 71
       IdBindingInfo] in GHC.Tc.Types).  In our example, 'k' is floatable.
    
    72 72
       Even though it is bound in a nested let, we are fine.
    
    73 73
     
    
    74 74
       See the call to `checkClosedInStaticForm` in the HsStatic case of `tcExpr`.
    
    75 75
     
    
    76
    -* The desugarer replaces the static form with an application of the
    
    76
    +(SF3) The typechecker also wraps the constraints from a static form in an
    
    77
    +  implication, with ic_info = StaticFormSkol.  When we try to solve such an
    
    78
    +  implication, we do so with /no Givens/; see `nestImplicTcS`. For example:
    
    79
    +     g :: Show a => StaticPtr (a -> String)
    
    80
    +     g = static show
    
    81
    +  If the @Show a0@ constraint that the body of the static form produces was
    
    82
    +  resolved in the context of the enclosing expression, then the body of the
    
    83
    +  static form wouldn't be closed because the Show dictionary would come from
    
    84
    +  g's context instead of coming from the top level.
    
    85
    +
    
    86
    +(SF4) The desugarer replaces the static form with an application of the
    
    77 87
       function 'makeStatic' (defined in module GHC.StaticPtr.Internal of
    
    78 88
       base).  So we get
    
    79 89
     
    
    80 90
        f x = let k = map toUpper
    
    81 91
              in ...fromStaticPtr (makeStatic location k)...
    
    82 92
     
    
    83
    -* The simplifier runs the FloatOut pass which moves the calls to 'makeStatic'
    
    93
    +(SF5) The simplifier runs the FloatOut pass which moves the calls to 'makeStatic'
    
    84 94
       to the top level. Thus the FloatOut pass is always executed, even when
    
    85 95
       optimizations are disabled.  So we get
    
    86 96
     
    
    ... ... @@ -106,7 +116,7 @@ Here is a running example:
    106 116
       Making the binding exported also has a necessary effect during the
    
    107 117
       CoreTidy pass.
    
    108 118
     
    
    109
    -* The CoreTidy pass replaces all bindings of the form
    
    119
    +(SF6) The CoreTidy pass replaces all bindings of the form
    
    110 120
     
    
    111 121
       b = /\ ... -> makeStatic location value
    
    112 122
     
    
    ... ... @@ -116,12 +126,12 @@ Here is a running example:
    116 126
     
    
    117 127
       where a distinct key is generated for each binding.
    
    118 128
     
    
    119
    -* If we are compiling to object code we insert a C stub (generated by
    
    129
    +(SF7) If we are compiling to object code we insert a C stub (generated by
    
    120 130
       sptModuleInitCode) into the final object which runs when the module is loaded,
    
    121 131
       inserting the static forms defined by the module into the RTS's static pointer
    
    122 132
       table.
    
    123 133
     
    
    124
    -* If we are compiling for the byte-code interpreter, we instead explicitly add
    
    134
    +(SF8) If we are compiling for the byte-code interpreter, we instead explicitly add
    
    125 135
       the SPT entries (recorded in CgGuts' cg_spt_entries field) to the interpreter
    
    126 136
       process' SPT table using the addSptEntry interpreter message. This happens
    
    127 137
       in upsweep after we have compiled the module (see GHC.Driver.Make.upsweep').
    

  • compiler/GHC/Tc/Gen/Expr.hs
    ... ... @@ -568,26 +568,30 @@ tcExpr (HsProc x pat cmd) res_ty
    568 568
     tcExpr (HsStatic fvs expr) res_ty
    
    569 569
       = do  { res_ty          <- expTypeToType res_ty
    
    570 570
             ; (co, (p_ty, expr_ty)) <- matchExpectedAppTy res_ty
    
    571
    -        ; (expr', lie)    <- captureConstraints $
    
    572
    -            addErrCtxt (StaticFormCtxt expr) $
    
    573
    -              tcCheckPolyExprNC expr expr_ty
    
    571
    +        ; (expr', lie) <- captureConstraints $
    
    572
    +                          addErrCtxt (StaticFormCtxt expr) $
    
    573
    +                          tcCheckPolyExprNC expr expr_ty
    
    574
    +
    
    575
    +        -- Emit an implication that captures the constraints of `expr`,
    
    576
    +        -- but with a `ic_info` of StaticFormSkol
    
    577
    +        -- See #13499 for an explanation of why this is the right thing to do:
    
    578
    +        -- the enclosing skolems must be in scope.
    
    579
    +        ; tc_lvl <- getTcLevel  -- No need to bump the level
    
    580
    +        ; (implic, ev_binds) <- buildImplicationFor tc_lvl StaticFormSkol [] [] lie
    
    581
    +        ; emitImplications implic
    
    582
    +        ; let expr'' = mkLHsWrap (mkWpLet ev_binds) expr'
    
    574 583
     
    
    575 584
             -- Check that the free variables of the static form are closed.
    
    576 585
             -- It's OK to use nonDetEltsUniqSet here as the only side effects of
    
    577 586
             -- checkClosedInStaticForm are error messages.
    
    587
    +        -- See (SF2) Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable
    
    578 588
             ; mapM_ checkClosedInStaticForm $ nonDetEltsUniqSet fvs
    
    579 589
     
    
    580 590
             -- Require the type of the argument to be Typeable.
    
    581 591
             ; typeableClass <- tcLookupClass typeableClassName
    
    582 592
             ; typeable_ev <- emitWantedEvVar StaticOrigin $
    
    583
    -                  mkTyConApp (classTyCon typeableClass)
    
    584
    -                             [liftedTypeKind, expr_ty]
    
    585
    -
    
    586
    -        -- Insert the constraints of the static form in a global list for later
    
    587
    -        -- validation.  See #13499 for an explanation of why this really isn't the
    
    588
    -        -- right thing to do: the enclosing skolems aren't in scope any more!
    
    589
    -        -- Static forms really aren't well worked out yet.
    
    590
    -        ; emitStaticConstraints lie
    
    593
    +                         mkTyConApp (classTyCon typeableClass)
    
    594
    +                                    [liftedTypeKind, expr_ty]
    
    591 595
     
    
    592 596
             -- Wrap the static form with the 'fromStaticPtr' call.
    
    593 597
             ; fromStaticPtr <- newMethodFromName StaticOrigin fromStaticPtrName
    
    ... ... @@ -595,9 +599,11 @@ tcExpr (HsStatic fvs expr) res_ty
    595 599
             ; let wrap = mkWpEvVarApps [typeable_ev] <.> mkWpTyApps [expr_ty]
    
    596 600
             ; loc <- getSrcSpanM
    
    597 601
             ; static_ptr_ty_con <- tcLookupTyCon staticPtrTyConName
    
    598
    -        ; return $ mkHsWrapCo co $ HsApp noExtField
    
    599
    -                            (L (noAnnSrcSpan loc) $ mkHsWrap wrap fromStaticPtr)
    
    600
    -                            (L (noAnnSrcSpan loc) (HsStatic (fvs, mkTyConApp static_ptr_ty_con [expr_ty]) expr'))
    
    602
    +        ; return $ mkHsWrapCo co $
    
    603
    +          HsApp noExtField
    
    604
    +              (L (noAnnSrcSpan loc) $ mkHsWrap wrap fromStaticPtr)
    
    605
    +              (L (noAnnSrcSpan loc) (HsStatic (fvs, mkTyConApp static_ptr_ty_con [expr_ty])
    
    606
    +                                              expr''))
    
    601 607
             }
    
    602 608
     
    
    603 609
     tcExpr (HsEmbTy _ _)      _ = failWith (TcRnIllegalTypeExpr TypeKeywordSyntax)
    

  • compiler/GHC/Tc/Solver.hs
    ... ... @@ -102,17 +102,14 @@ captureTopConstraints :: TcM a -> TcM (a, WantedConstraints)
    102 102
     -- calling this, so that the reportUnsolved has access to the most
    
    103 103
     -- complete GlobalRdrEnv
    
    104 104
     captureTopConstraints thing_inside
    
    105
    -  = do { static_wc_var <- TcM.newTcRef emptyWC ;
    
    106
    -       ; (mb_res, lie) <- TcM.updGblEnv (\env -> env { tcg_static_wc = static_wc_var } ) $
    
    107
    -                          TcM.tryCaptureConstraints thing_inside
    
    108
    -       ; stWC <- TcM.readTcRef static_wc_var
    
    105
    +  = do { (mb_res, lie) <- TcM.tryCaptureConstraints thing_inside
    
    109 106
     
    
    110 107
            -- See GHC.Tc.Utils.Monad Note [Constraints and errors]
    
    111 108
            -- If the thing_inside threw an exception, but generated some insoluble
    
    112 109
            -- constraints, report the latter before propagating the exception
    
    113 110
            -- Otherwise they will be lost altogether
    
    114 111
            ; case mb_res of
    
    115
    -           Just res -> return (res, lie `andWC` stWC)
    
    112
    +           Just res -> return (res, lie)
    
    116 113
                Nothing  -> do { _ <- simplifyTop lie; failM } }
    
    117 114
                     -- This call to simplifyTop is the reason
    
    118 115
                     -- this function is here instead of GHC.Tc.Utils.Monad
    

  • compiler/GHC/Tc/Solver/Default.hs
    ... ... @@ -275,13 +275,13 @@ solveImplicationUsingUnsatGiven :: (EvVar, Type) -> Implication -> TcS Implicati
    275 275
     solveImplicationUsingUnsatGiven
    
    276 276
       unsat_given@(given_ev,_)
    
    277 277
       impl@(Implic { ic_wanted = wtd, ic_tclvl = tclvl, ic_binds = ev_binds_var
    
    278
    -               , ic_need_implic = inner })
    
    278
    +               , ic_need_implic = inner, ic_info = skol_info })
    
    279 279
       | isCoEvBindsVar ev_binds_var
    
    280 280
       -- We can't use Unsatisfiable evidence in kinds.
    
    281 281
       -- See Note [Coercion evidence only] in GHC.Tc.Types.Evidence.
    
    282 282
       = return impl
    
    283 283
       | otherwise
    
    284
    -  = do { wcs <- nestImplicTcS ev_binds_var tclvl $ go_wc wtd
    
    284
    +  = do { wcs <- nestImplicTcS skol_info ev_binds_var tclvl $ go_wc wtd
    
    285 285
            ; setImplicationStatus $
    
    286 286
              impl { ic_wanted = wcs
    
    287 287
                   , ic_need_implic = inner `extendEvNeedSet` given_ev } }
    
    ... ... @@ -1135,7 +1135,7 @@ disambigProposalSequences orig_wanteds wanteds proposalSequences allConsistent
    1135 1135
            ; tclvl             <- TcS.getTcLevel
    
    1136 1136
            -- Step (3) in Note [How type-class constraints are defaulted]
    
    1137 1137
            ; successes <- fmap catMaybes $
    
    1138
    -                      nestImplicTcS fake_ev_binds_var (pushTcLevel tclvl) $
    
    1138
    +                      nestImplicTcS DefaultSkol fake_ev_binds_var (pushTcLevel tclvl) $
    
    1139 1139
                           mapM firstSuccess proposalSequences
    
    1140 1140
            ; traceTcS "disambigProposalSequences {" (vcat [ ppr wanteds
    
    1141 1141
                                                           , ppr proposalSequences
    

  • compiler/GHC/Tc/Solver/Equality.hs
    ... ... @@ -1681,7 +1681,6 @@ canEqCanLHSHetero ev eq_rel swapped lhs1 ps_xi1 ki1 xi2 ps_xi2 ki2
    1681 1681
                                                 in unSwap swapped (uType uenv') ki1 ki2
    
    1682 1682
                           -- mkKindEqLoc: any new constraints, arising from the kind
    
    1683 1683
                           -- unification, say they thay come from unifying xi1~xi2
    
    1684
    -                      -- ...AndEmit: emit any unsolved equalities
    
    1685 1684
     
    
    1686 1685
                    -- Kick out any inert constraints mentioning the unified variables
    
    1687 1686
                    ; kickOutAfterUnification unifs
    
    ... ... @@ -1697,14 +1696,13 @@ canEqCanLHSHetero ev eq_rel swapped lhs1 ps_xi1 ki1 xi2 ps_xi2 ki2
    1697 1696
                    -- Emit the deferred constraints
    
    1698 1697
                 do { emitChildEqs ev eqs
    
    1699 1698
     
    
    1700
    --- This assert is commented out because of #26453. Reinstate it when #26453 is fixed
    
    1701
    ---               ; assertPpr (not (isEmptyCts eqs))
    
    1702
    ---                           (vcat [ppr ev, ppr ki1, ppr ki2, ppr unifs, ppr eqs]) $
    
    1703
    ---                   -- assert: the constraints won't be empty because the two kinds differ,
    
    1704
    ---                   -- and there are no unifications, so we must have emitted one or
    
    1705
    ---                   -- more constraints
    
    1699
    +               ; assertPpr (not (isEmptyCts eqs))
    
    1700
    +                           (vcat [ppr ev, ppr ki1, ppr ki2, ppr unifs, ppr eqs]) $
    
    1701
    +                   -- assert: the constraints won't be empty because the two kinds differ,
    
    1702
    +                   -- and there are no unifications, so we must have emitted one or
    
    1703
    +                   -- more constraints
    
    1706 1704
     
    
    1707
    -               ; finish (rewriterSetFromCts eqs) kind_co }}
    
    1705
    +                 finish (rewriterSetFromCts eqs) kind_co }}
    
    1708 1706
                              -- rewriterSetFromCts: record in the /type/ unification xi1~xi2 that
    
    1709 1707
                              -- it has been rewritten by any (unsolved) constraints in `cts`; that
    
    1710 1708
                              -- stops xi1~xi2 from unifying until `cts` are solved. See (EIK2).
    

  • compiler/GHC/Tc/Solver/Monad.hs
    ... ... @@ -1199,20 +1199,12 @@ setTcLevelTcS :: TcLevel -> TcS a -> TcS a
    1199 1199
     setTcLevelTcS lvl (TcS thing_inside)
    
    1200 1200
      = TcS $ \ env -> TcM.setTcLevel lvl (thing_inside env)
    
    1201 1201
     
    
    1202
    -nestImplicTcS :: EvBindsVar
    
    1202
    +nestImplicTcS :: SkolemInfoAnon -> EvBindsVar
    
    1203 1203
                   -> TcLevel -> TcS a
    
    1204 1204
                   -> TcS a
    
    1205
    -nestImplicTcS ev_binds_var inner_tclvl (TcS thing_inside)
    
    1205
    +nestImplicTcS skol_info ev_binds_var inner_tclvl (TcS thing_inside)
    
    1206 1206
       = TcS $ \ env@(TcSEnv { tcs_inerts = old_inert_var }) ->
    
    1207
    -    do { inerts <- TcM.readTcRef old_inert_var
    
    1208
    -
    
    1209
    -       -- resetInertcans: initialise the inert_cans from the inert_givens of the
    
    1210
    -       -- parent so that the child is not polluted with the parent's inert Wanteds
    
    1211
    -       -- See Note [trySolveImplication] in GHC.Tc.Solver.Solve
    
    1212
    -       -- All other InertSet fields are inherited
    
    1213
    -       ; let nest_inert = pushCycleBreakerVarStack $
    
    1214
    -                          resetInertCans           $
    
    1215
    -                          inerts
    
    1207
    +    do { nest_inert <- mk_nested_inert_set skol_info old_inert_var
    
    1216 1208
            ; new_inert_var <- TcM.newTcRef nest_inert
    
    1217 1209
            ; new_wl_var    <- TcM.newTcRef emptyWorkList
    
    1218 1210
            ; let nest_env = env { tcs_ev_binds = ev_binds_var
    
    ... ... @@ -1230,6 +1222,25 @@ nestImplicTcS ev_binds_var inner_tclvl (TcS thing_inside)
    1230 1222
            ; checkForCyclicBinds ev_binds
    
    1231 1223
     #endif
    
    1232 1224
            ; return res }
    
    1225
    +  where
    
    1226
    +    mk_nested_inert_set skol_info old_inert_var
    
    1227
    +      -- For an implication that comes from a static form (static e),
    
    1228
    +      -- start with a completely empty inert set; in particular, no Givens
    
    1229
    +      -- See (SF3) in Note [Grand plan for static forms]
    
    1230
    +      -- in GHC.Iface.Tidy.StaticPtrTable
    
    1231
    +      | StaticFormSkol <- skol_info
    
    1232
    +      = return (emptyInertSet inner_tclvl)
    
    1233
    +
    
    1234
    +      | otherwise
    
    1235
    +      = do { inerts <- TcM.readTcRef old_inert_var
    
    1236
    +
    
    1237
    +           -- resetInertCans: initialise the inert_cans from the inert_givens of the
    
    1238
    +           -- parent so that the child is not polluted with the parent's inert Wanteds
    
    1239
    +           -- See Note [trySolveImplication] in GHC.Tc.Solver.Solve
    
    1240
    +           -- All other InertSet fields are inherited
    
    1241
    +           ; return (pushCycleBreakerVarStack $
    
    1242
    +                     resetInertCans           $
    
    1243
    +                     inerts) }
    
    1233 1244
     
    
    1234 1245
     nestFunDepsTcS :: TcS a -> TcS a
    
    1235 1246
     nestFunDepsTcS (TcS thing_inside)
    

  • compiler/GHC/Tc/Solver/Solve.hs
    ... ... @@ -394,7 +394,7 @@ trySolveImplication (Implic { ic_tclvl = tclvl
    394 394
                                 , ic_wanted = wanteds
    
    395 395
                                 , ic_env    = ct_loc_env
    
    396 396
                                 , ic_info   = info })
    
    397
    -  = nestImplicTcS ev_binds_var tclvl $
    
    397
    +  = nestImplicTcS info ev_binds_var tclvl $
    
    398 398
         do { let loc    = mkGivenLoc tclvl info ct_loc_env
    
    399 399
                  givens = mkGivens loc given_ids
    
    400 400
            ; solveSimpleGivens givens
    
    ... ... @@ -427,7 +427,7 @@ solveImplication imp@(Implic { ic_tclvl = tclvl
    427 427
     
    
    428 428
              -- Solve the nested constraints
    
    429 429
            ; (has_given_eqs, given_insols, residual_wanted)
    
    430
    -            <- nestImplicTcS ev_binds_var tclvl $
    
    430
    +            <- nestImplicTcS info ev_binds_var tclvl $
    
    431 431
                    do { let loc    = mkGivenLoc tclvl info ct_loc_env
    
    432 432
                             givens = mkGivens loc given_ids
    
    433 433
                       ; solveSimpleGivens givens
    

  • compiler/GHC/Tc/Types.hs
    ... ... @@ -689,9 +689,6 @@ data TcGblEnv
    689 689
             tcg_top_loc :: RealSrcSpan,
    
    690 690
             -- ^ The RealSrcSpan this module came from
    
    691 691
     
    
    692
    -        tcg_static_wc :: TcRef WantedConstraints,
    
    693
    -          -- ^ Wanted constraints of static forms.
    
    694
    -        -- See Note [Constraints in static forms].
    
    695 692
             tcg_complete_matches :: !CompleteMatches,
    
    696 693
             -- ^ Complete matches defined in this module.
    
    697 694
     
    
    ... ... @@ -706,27 +703,6 @@ data TcGblEnv
    706 703
     -- Definition sites of orphan identities will be identity modules, not semantic
    
    707 704
     -- modules.
    
    708 705
     
    
    709
    --- Note [Constraints in static forms]
    
    710
    --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    711
    ---
    
    712
    --- When a static form produces constraints like
    
    713
    ---
    
    714
    --- f :: StaticPtr (Bool -> String)
    
    715
    --- f = static show
    
    716
    ---
    
    717
    --- we collect them in tcg_static_wc and resolve them at the end
    
    718
    --- of type checking. They need to be resolved separately because
    
    719
    --- we don't want to resolve them in the context of the enclosing
    
    720
    --- expression. Consider
    
    721
    ---
    
    722
    --- g :: Show a => StaticPtr (a -> String)
    
    723
    --- g = static show
    
    724
    ---
    
    725
    --- If the @Show a0@ constraint that the body of the static form produces was
    
    726
    --- resolved in the context of the enclosing expression, then the body of the
    
    727
    --- static form wouldn't be closed because the Show dictionary would come from
    
    728
    --- g's context instead of coming from the top level.
    
    729
    -
    
    730 706
     tcVisibleOrphanMods :: TcGblEnv -> ModuleSet
    
    731 707
     tcVisibleOrphanMods tcg_env
    
    732 708
         = mkModuleSet (tcg_mod tcg_env : imp_orphs (tcg_imports tcg_env))
    

  • compiler/GHC/Tc/Types/Constraint.hs
    ... ... @@ -1447,6 +1447,9 @@ data Implication
    1447 1447
     
    
    1448 1448
           ic_info  :: SkolemInfoAnon,    -- See Note [Skolems in an implication]
    
    1449 1449
                                          -- See Note [Shadowing in a constraint]
    
    1450
    +         -- NB: Mostly ic_info is just there to help with error messages
    
    1451
    +         --     but StaticFormSkol has a deeper significance; see (SF3) in
    
    1452
    +         --     Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable
    
    1450 1453
     
    
    1451 1454
           ic_skols :: [TcTyVar],     -- Introduced skolems; always skolem TcTyVars
    
    1452 1455
                                      -- Their level numbers should be precisely ic_tclvl
    

  • compiler/GHC/Tc/Types/Origin.hs
    ... ... @@ -334,6 +334,11 @@ data SkolemInfoAnon
    334 334
     
    
    335 335
       | UnkSkol CallStack
    
    336 336
     
    
    337
    +  | DefaultSkol         -- Used (only) during defaulting
    
    338
    +
    
    339
    +  | StaticFormSkol      -- Attached to an implication constraint that captures
    
    340
    +                        -- the constraints from (static e)
    
    341
    +
    
    337 342
     
    
    338 343
     -- | Use this when you can't specify a helpful origin for
    
    339 344
     -- some skolem type variable.
    
    ... ... @@ -393,6 +398,8 @@ pprSkolInfo ReifySkol = text "the type being reified"
    393 398
     
    
    394 399
     pprSkolInfo RuntimeUnkSkol     = text "Unknown type from GHCi runtime"
    
    395 400
     pprSkolInfo ArrowReboundIfSkol = text "the expected type of a rebound if-then-else command"
    
    401
    +pprSkolInfo StaticFormSkol     = text "a static expression"
    
    402
    +pprSkolInfo DefaultSkol        = text "a constraint being defaulted"
    
    396 403
     
    
    397 404
     -- unkSkol
    
    398 405
     -- For type variables the others are dealt with by pprSkolTvBinding.
    

  • compiler/GHC/Tc/Utils/Monad.hs
    ... ... @@ -108,7 +108,7 @@ module GHC.Tc.Utils.Monad(
    108 108
       getTcEvBindsMap, setTcEvBindsMap, updTcEvBinds,
    
    109 109
       getTcEvTyCoVars, chooseUniqueOccTc,
    
    110 110
       getConstraintVar, setConstraintVar,
    
    111
    -  emitConstraints, emitStaticConstraints, emitSimple, emitSimples,
    
    111
    +  emitConstraints, emitSimple, emitSimples,
    
    112 112
       emitImplication, emitImplications, ensureReflMultiplicityCo,
    
    113 113
       emitDelayedErrors, emitHole, emitHoles, emitNotConcreteError,
    
    114 114
       discardConstraints, captureConstraints, tryCaptureConstraints,
    
    ... ... @@ -296,7 +296,6 @@ initTcGblEnv hsc_env hsc_src keep_rn_syntax mod loc =
    296 296
          ; zany_n_var           <- newIORef 0
    
    297 297
          ; dependent_files_var  <- newIORef []
    
    298 298
          ; dependent_dirs_var   <- newIORef []
    
    299
    -     ; static_wc_var        <- newIORef emptyWC
    
    300 299
          ; cc_st_var            <- newIORef newCostCentreState
    
    301 300
          ; th_topdecls_var      <- newIORef []
    
    302 301
          ; th_foreign_files_var <- newIORef []
    
    ... ... @@ -396,7 +395,6 @@ initTcGblEnv hsc_env hsc_src keep_rn_syntax mod loc =
    396 395
               , tcg_defaulting_plugins  = []
    
    397 396
               , tcg_hf_plugins          = []
    
    398 397
               , tcg_top_loc             = loc
    
    399
    -          , tcg_static_wc           = static_wc_var
    
    400 398
               , tcg_complete_matches    = []
    
    401 399
               , tcg_cc_st               = cc_st_var
    
    402 400
               , tcg_next_wrapper_num    = next_wrapper_num
    
    ... ... @@ -1984,11 +1982,6 @@ getConstraintVar = do { env <- getLclEnv; return (tcl_lie env) }
    1984 1982
     setConstraintVar :: TcRef WantedConstraints -> TcM a -> TcM a
    
    1985 1983
     setConstraintVar lie_var = updLclEnv (\ env -> env { tcl_lie = lie_var })
    
    1986 1984
     
    
    1987
    -emitStaticConstraints :: WantedConstraints -> TcM ()
    
    1988
    -emitStaticConstraints static_lie
    
    1989
    -  = do { gbl_env <- getGblEnv
    
    1990
    -       ; updTcRef (tcg_static_wc gbl_env) (`andWC` static_lie) }
    
    1991
    -
    
    1992 1985
     emitConstraints :: WantedConstraints -> TcM ()
    
    1993 1986
     emitConstraints ct
    
    1994 1987
       | isEmptyWC ct