[project @ 1996-07-19 18:36:04 by partain]
[ghc-hetmet.git] / ghc / compiler / rename / RnBinds.lhs
index f1618ad..ced653a 100644 (file)
@@ -15,8 +15,8 @@ module RnBinds (
        rnTopBinds,
        rnMethodBinds,
        rnBinds,
-       FreeVars(..),
-       DefinedVars(..)
+       SYN_IE(FreeVars),
+       SYN_IE(DefinedVars)
    ) where
 
 IMP_Ubiq()
@@ -32,14 +32,14 @@ import RnExpr               ( rnMatch, rnGRHSsAndBinds, rnPat, checkPrecMatch )
 import CmdLineOpts     ( opt_SigsRequired )
 import Digraph         ( stronglyConnComp )
 import ErrUtils                ( addErrLoc, addShortErrLocLine )
-import Name            ( RdrName )
+import Name            ( getLocalName, RdrName )
 import Maybes          ( catMaybes )
-import PprStyle--ToDo:rm
+--import PprStyle--ToDo:rm
 import Pretty
 import UniqSet         ( emptyUniqSet, unitUniqSet, mkUniqSet,
                          unionUniqSets, unionManyUniqSets,
                          elementOfUniqSet, uniqSetToList, SYN_IE(UniqSet) )
-import Util            ( thenCmp, isIn, removeDups, panic, panic#, assertPanic, pprTrace{-ToDo:rm-} )
+import Util            ( thenCmp, isIn, removeDups, panic, panic#, assertPanic )
 \end{code}
 
 -- ToDo: Put the annotations into the monad, so that they arrive in the proper
@@ -524,7 +524,7 @@ rnBindSigs is_toplev binder_occnames sigs
         -- Discard unbound ones we've already complained about, so we
         -- complain about duplicate ones.
 
-       (goodies, dups) = removeDups compare (filter not_unbound sigs')
+       (goodies, dups) = removeDups compare (filter (\ x -> not_unbound x && not_main x) sigs')
     in
     mapRn (addErrRn . dupSigDeclErr) dups `thenRn_`
 
@@ -598,7 +598,7 @@ rnBindSigs is_toplev binder_occnames sigs
           lookupValue v        `thenRn` \ new_v ->
           returnRn (Just (MagicUnfoldingSig new_v str src_loc))
 
-    not_unbound :: RenamedSig -> Bool
+    not_unbound, not_main :: RenamedSig -> Bool
 
     not_unbound (Sig n _ _ _)            = not (isRnUnbound n)
     not_unbound (SpecSig n _ _ _)        = not (isRnUnbound n)
@@ -606,6 +606,10 @@ rnBindSigs is_toplev binder_occnames sigs
     not_unbound (DeforestSig n _)        = not (isRnUnbound n)
     not_unbound (MagicUnfoldingSig n _ _) = not (isRnUnbound n)
 
+    not_main (Sig n _ _ _)  = let str = getLocalName n in
+                             not (str == SLIT("main") || str == SLIT("mainPrimIO"))
+    not_main _             = True
+
     -------------------------------------
     sig_free :: [RdrNameSig] -> RdrName -> Maybe RdrName
        -- Return "Just x" if "x" has no type signature in