FIX part of #1959: declaration versions were not being incremented correctly
authorSimon Marlow <simonmar@microsoft.com>
Thu, 6 Dec 2007 08:45:56 +0000 (08:45 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 6 Dec 2007 08:45:56 +0000 (08:45 +0000)
We were building a mapping from ModuleName to [Occ] from the usage
list, using the usg_mod field as the key.  Unfortunately, due to a
very poor naming decision, usg_mod is actually the module version, not
the ModuleName.  usg_name is the ModuleName.  Since Version is also an
instance of Uniquable, there was no type error: all that happened was
lookups in the map never succeeded.  I shall rename the fields of
Usage in a separate patch.

This doesn't completely fix #1959, but it gets part of the way there.

I have to take partial blame as the person who wrote this fragment of
code in late 2006 (patch "Interface file optimisation and removal of
nameParent").

compiler/iface/MkIface.lhs

index c0b9717..3c33647 100644 (file)
@@ -706,7 +706,7 @@ computeChangedOccs ver_fn this_module old_usages eq_info
     name_changed nm
         | Just ents <- lookupUFM usg_modmap (moduleName mod) 
         = case lookupUFM ents parent_occ of
     name_changed nm
         | Just ents <- lookupUFM usg_modmap (moduleName mod) 
         = case lookupUFM ents parent_occ of
-                Nothing -> pprPanic "computeChangedOccs" (ppr nm)
+                Nothing -> pprTrace "WARNING: computeChangedOccs" (ppr nm) $ False
                 Just v  -> v < new_version
         | otherwise = False -- must be in another package
       where
                 Just v  -> v < new_version
         | otherwise = False -- must be in another package
       where
@@ -714,7 +714,7 @@ computeChangedOccs ver_fn this_module old_usages eq_info
          (parent_occ, new_version) = ver_fn nm
 
     -- Turn the usages from the old ModIface into a mapping
          (parent_occ, new_version) = ver_fn nm
 
     -- Turn the usages from the old ModIface into a mapping
-    usg_modmap = listToUFM [ (usg_mod usg, listToUFM (usg_entities usg))
+    usg_modmap = listToUFM [ (usg_name usg, listToUFM (usg_entities usg))
                            | usg <- old_usages ]
 
     get_local_eq_info :: GenIfaceEq NameSet -> GenIfaceEq OccSet
                            | usg <- old_usages ]
 
     get_local_eq_info :: GenIfaceEq NameSet -> GenIfaceEq OccSet