From: simonm Date: Tue, 25 Nov 1997 10:52:29 +0000 (+0000) Subject: [project @ 1997-11-25 10:52:29 by simonm] X-Git-Tag: Approx_2487_patches~1242 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=78f85b1ef880f3020a0a4c02d05d7009c9fc42ff;p=ghc-hetmet.git [project @ 1997-11-25 10:52:29 by simonm] fix for "TyCon used as Class" bug. --- diff --git a/ghc/compiler/typecheck/TcEnv.lhs b/ghc/compiler/typecheck/TcEnv.lhs index 32fdf22..e406b28 100644 --- a/ghc/compiler/typecheck/TcEnv.lhs +++ b/ghc/compiler/typecheck/TcEnv.lhs @@ -55,6 +55,7 @@ import UniqFM import Util ( zipEqual, zipWithEqual, zipWith3Equal, zipLazy, panic, pprPanic, pprTrace ) +import Maybes ( maybeToBool ) import Outputable \end{code} @@ -175,14 +176,17 @@ tcLookupTyConByKey uniq tcLookupClass name = tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) -> --- pprTrace "tcLookupClass:" (hsep [text "Uniq:", pprUnique10 (uniqueOf name), text "; avail:", hsep (map (pprUnique10 . fst) (ufmToList ce))]) $ --- pprTrace "tcLookupClass:" (hsep [text "Uniq:", pprUnique (uniqueOf name), text "; avail:", hsep (map (pprUnique . fst) (ufmToList ce))]) $ case lookupUFM ce name of - Just stuff -> returnTc stuff - Nothing -> -- Could be that he's using a type constructor as a class - case lookupUFM tce name of - Just _ -> failTc (tyConAsClassErr name) - Nothing -> pprPanic "tcLookupClass:" (ppr PprShowAll name) + Just stuff -- Common case: it's ok + -> returnTc stuff + + Nothing -- Could be that he's using a type constructor as a class + | maybeToBool (maybeWiredInTyConName name) + || maybeToBool (lookupUFM tce name) + -> failTc (tyConAsClassErr name) + + | otherwise -- Wierd! Renamer shouldn't let this happen + -> pprPanic "tcLookupClass:" (ppr PprShowAll name) tcLookupClassByKey uniq = tcGetEnv `thenNF_Tc` \ (TcEnv tve tce ce gve lve gtvs) ->