Workaround for #1959: assume untracked names have changed
authorSimon Marlow <simonmar@microsoft.com>
Thu, 6 Dec 2007 09:23:49 +0000 (09:23 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 6 Dec 2007 09:23:49 +0000 (09:23 +0000)
This fixes the 1959 test, but will do more recompilation than is
strictly necessary (but only when -O is on).  Still, more
recompilation is better than segfaults, link errors or other random
breakage.

compiler/iface/MkIface.lhs

index 3c33647..c00c371 100644 (file)
@@ -704,15 +704,21 @@ computeChangedOccs ver_fn this_module old_usages eq_info
     -- return True if an external name has changed
     name_changed :: Name -> Bool
     name_changed nm
-        | Just ents <- lookupUFM usg_modmap (moduleName mod) 
-        = case lookupUFM ents parent_occ of
-                Nothing -> pprTrace "WARNING: computeChangedOccs" (ppr nm) $ False
-                Just v  -> v < new_version
+        | Just ents <- lookupUFM usg_modmap (moduleName mod),
+          Just v    <- lookupUFM ents parent_occ
+        = v < new_version
+        | modulePackageId mod == this_pkg
+        = WARN(True, ptext SLIT("computeChangedOccs") <+> ppr nm) True
+        -- should really be a panic, see #1959.  The problem is that the usages doesn't
+        -- contain all the names that might be referred to by unfoldings.  So as a
+        -- conservative workaround we just assume these names have changed.
         | otherwise = False -- must be in another package
       where
          mod = nameModule nm
          (parent_occ, new_version) = ver_fn nm
 
+    this_pkg = modulePackageId this_module
+
     -- Turn the usages from the old ModIface into a mapping
     usg_modmap = listToUFM [ (usg_name usg, listToUFM (usg_entities usg))
                            | usg <- old_usages ]