diff options
author | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2006-10-21 03:58:29 +0000 |
---|---|---|
committer | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2006-10-21 03:58:29 +0000 |
commit | 9530e7922d07ac2272e26078c6c626a333d1a761 (patch) | |
tree | 4cb850a431811ae0e96e48768ccf13bc561b7de3 | |
parent | a00334cc6a209c009c7b6e5dc3926f3871c9b097 (diff) | |
download | haskell-2006-10-22.tar.gz |
Fix parent position in RnNames.nubAvails2006-10-22
- `RnNames.nubAvails', which amalgamates AvailInfo items that belong to the
same parent, needs to be careful that the parent name occurs first if it is
in the list of subnames at all. (Otherwise, we can get funny export items
in ifaces.)
- I discovered this while debugging family import/exports, but I am pretty
sure the bug would also have shown up without using families under the
right circumstances.
-rw-r--r-- | compiler/rename/RnNames.lhs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs index 8661c0e2ce..90cf81fc5f 100644 --- a/compiler/rename/RnNames.lhs +++ b/compiler/rename/RnNames.lhs @@ -58,7 +58,7 @@ import BasicTypes ( DeprecTxt ) import DriverPhases ( isHsBoot ) import Util import ListSetOps -import Data.List ( partition, concatMap, (\\) ) +import Data.List ( partition, concatMap, (\\), delete ) import IO ( openFile, IOMode(..) ) import Monad ( when ) \end{code} @@ -780,9 +780,18 @@ mkAvailEnv :: [AvailInfo] -> AvailEnv -- We want to combine these; addAvail does that mkAvailEnv avails = foldl addAvail emptyAvailEnv avails +-- After combining the avails, we need to ensure that the parent name is the +-- first entry in the list of subnames, if it is included at all. (Subsequent +-- functions rely on that.) +normaliseAvail :: AvailInfo -> AvailInfo +normaliseAvail avail@(Avail _) = avail +normaliseAvail (AvailTC name subs) = AvailTC name subs' + where + subs' = if name `elem` subs then name : (delete name subs) else subs + -- | combines 'AvailInfo's from the same family nubAvails :: [AvailInfo] -> [AvailInfo] -nubAvails avails = nameEnvElts (mkAvailEnv avails) +nubAvails avails = map normaliseAvail . nameEnvElts . mkAvailEnv $ avails \end{code} @@ -874,6 +883,7 @@ exports_from_avail Nothing rdr_env imports this_mod exports_from_avail (Just rdr_items) rdr_env imports this_mod = do (ie_names, _, exports) <- foldlM do_litem emptyExportAccum rdr_items + return (Just ie_names, exports) where do_litem :: ExportAccum -> LIE RdrName -> RnM ExportAccum |