[project @ 2001-05-14 16:40:54 by sewardj]
authorsewardj <unknown>
Mon, 14 May 2001 16:40:54 +0000 (16:40 +0000)
committersewardj <unknown>
Mon, 14 May 2001 16:40:54 +0000 (16:40 +0000)
Record-selector unfolding fix #2

ghc/compiler/coreSyn/CoreTidy.lhs

index dc2c600..b0f8dac 100644 (file)
@@ -21,8 +21,8 @@ import VarSet
 import Var             ( Id, Var )
 import Id              ( idType, idInfo, idName, isExportedId, 
                          idSpecialisation, idUnique, isDataConWrapId,
-                         mkVanillaGlobal, isLocalId, 
-                         hasNoBinding, mkUserLocal
+                         mkVanillaGlobal, isLocalId, isRecordSelector,
+                         setIdUnfolding, hasNoBinding, mkUserLocal
                        ) 
 import IdInfo          {- loads of stuff -}
 import Name            ( getOccName, nameOccName, globaliseName, setNameOcc, 
@@ -414,6 +414,12 @@ tidyTopBinder mod ext_ids cg_info_env tidy_env rhs
 -- What about the Id in the TyCon?  It probably shouldn't be in the TyCon at
 -- all, but in any case it will have the error message inline so it won't matter.
 
+
+  | isRecordSelector id        -- We can't use the "otherwise" case, because that
+                       -- forgets the IdDetails, which forgets that this is
+                       -- a record selector, which confuses an importing module
+  = (env, id `setIdUnfolding` unfold_info)
+
   | otherwise
        -- This function is the heart of Step 2
        -- The second env is the one to use for the IdInfo