X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fiface%2FLoadIface.lhs;h=cfb8f1272b4a2f8b35a42b02c9463d64f91d4ac7;hb=7fcfb091b89d24e32faf95487208caca47fd0ab8;hp=8625a1aa84bed00a884b49315e95601bca2e9c22;hpb=e68a891932d615590d9b1ab5752ada8142db5053;p=ghc-hetmet.git diff --git a/compiler/iface/LoadIface.lhs b/compiler/iface/LoadIface.lhs index 8625a1a..cfb8f12 100644 --- a/compiler/iface/LoadIface.lhs +++ b/compiler/iface/LoadIface.lhs @@ -310,7 +310,7 @@ loadDecl ignore_prags mod (_version, decl) = do { -- Populate the name cache with final versions of all -- the names associated with the decl main_name <- mk_new_bndr mod (ifName decl) - ; traceIf (text "Loading decl for " <> ppr main_name) +-- ; traceIf (text "Loading decl for " <> ppr main_name) ; implicit_names <- mapM (mk_new_bndr mod) (ifaceDeclSubBndrs decl) -- Typecheck the thing, lazily @@ -323,7 +323,27 @@ loadDecl ignore_prags mod (_version, decl) ; thing <- forkM doc $ do { bumpDeclStats main_name ; tcIfaceDecl ignore_prags decl } - -- Populate the type environment with the implicitTyThings too + -- Populate the type environment with the implicitTyThings too. + -- + -- Note [Tricky iface loop] + -- ~~~~~~~~~~~~~~~~~~~~~~~~ + -- The delicate point here is that 'mini-env' should be + -- buildable from 'thing' without demanding any of the things 'forkM'd + -- by tcIfaceDecl. For example + -- class C a where { data T a; op :: T a -> Int } + -- We return the bindings + -- [("C", ), ("T", lookup env "T"), ("op", lookup env "op")] + -- The call (lookup env "T") must return the tycon T without first demanding + -- op; because getting the latter will look up T, hence loop. + -- + -- Of course, there is no reason in principle why (lookup env "T") should demand + -- anything do to with op, but take care: + -- (a) implicitTyThings, and + -- (b) getOccName of all the things returned by implicitThings, + -- must not depend on any of the nested type-checks + -- + -- All a bit too finely-balanced for my liking. + ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing] lookup n = case lookupOccEnv mini_env (getOccName n) of Just thing -> thing