From: simonpj Date: Thu, 10 Feb 2000 15:39:39 +0000 (+0000) Subject: [project @ 2000-02-10 15:39:39 by simonpj] X-Git-Tag: Approximately_9120_patches~5145 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=016a498f92a76d77bc14d629fed0105f58558240;p=ghc-hetmet.git [project @ 2000-02-10 15:39:39 by simonpj] A few comments about RnIfaces.lookupFixity --- diff --git a/ghc/compiler/rename/RnIfaces.lhs b/ghc/compiler/rename/RnIfaces.lhs index a46eb5b..fbf8df1 100644 --- a/ghc/compiler/rename/RnIfaces.lhs +++ b/ghc/compiler/rename/RnIfaces.lhs @@ -624,6 +624,13 @@ lookupFixity name Nothing -> returnRn defaultFixity | otherwise -- Imported + -- For imported names, we have to get their fixities by doing a loadHomeInterface, + -- and consulting the Ifaces that comes back from that, because the interface + -- file for the Name might not have been loaded yet. Why not? Suppose you import module A, + -- which exports a function 'f', which is defined in module B. Then B isn't loaded + -- right away (after all, it's possible that nothing from B will be used). + -- When we come across a use of 'f', we need to know its fixity, and it's then, + -- and only then, that we load B.hi. That is what's happening here. = loadHomeInterface doc name `thenRn` \ ifaces -> case lookupNameEnv (iFixes ifaces) name of Just (FixitySig _ fix _) -> returnRn fix diff --git a/ghc/compiler/rename/RnMonad.lhs b/ghc/compiler/rename/RnMonad.lhs index bcc220b..0b83f41 100644 --- a/ghc/compiler/rename/RnMonad.lhs +++ b/ghc/compiler/rename/RnMonad.lhs @@ -132,8 +132,9 @@ data SDown = SDown { -- we can look up record field names rn_fixenv :: FixityEnv -- Local fixities - -- The global ones are held in the - -- rn_ifaces field + -- The global fixities are held in the + -- rn_ifaces field. Why? See the comments + -- with RnIfaces.lookupFixity } data RnMode = SourceMode -- Renaming source code @@ -308,6 +309,7 @@ data Ifaces = Ifaces { iDecls :: DeclsMap, -- A single, global map of Names to decls iFixes :: FixityEnv, -- A single, global map of Names to fixities + -- See comments with RnIfaces.lookupFixity iSlurp :: NameSet, -- All the names (whether "big" or "small", whether wired-in or not,