git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2007 from purescript/1872-reexport-unaliased

Fix re-exports to include intended exports only

commited5c26c833046011a173fdd735eb9a444126b025 authorGary Burgess <gary.burgess@gmail.com> dateSun 10 Apr 2016, 18:08 (11 years ago) parent3946fed6272bd9
1 file changed+6−10
src/Language/PureScript/Sugar/Names/Exports.hs+6−10
src/Language/PureScript/Sugar/Names/Exports.hs+6−10
@@ -119,9 +119,10 @@ resolveExports env mn imps exps refs =
119119 extract useQual name render = fmap (map (importName . head . snd)) . go . M.toList
120120 where
121121 go = filterM $ \(name', options) -> do
122− let isMatch = if useQual then eqQual name name' else any (eqQual name . importName) options
122+ let isMatch = if useQual then isQualifiedWith name name' else any (checkUnqual name') options
123123 when (isMatch && length options > 1) $ void $ checkImportConflicts mn render options
124124 return isMatch
125+ checkUnqual name' ir = isUnqualified name' && isQualifiedWith name (importName ir)
125126
126127 -- Check whether a module name refers to a "pseudo module" that came into
127128 -- existence in an import scope due to importing one or more modules as
@@ -134,21 +135,16 @@ resolveExports env mn imps exps refs =
134135 -- value being re-exported belongs to a qualified module, and we test the
135136 -- values if that fails to see whether the value has been imported at all.
136137 testQuals :: (forall a b. M.Map (Qualified a) b -> [Qualified a]) -> ModuleName -> Bool
137− testQuals f mn' = any (eqQual mn') (f (importedTypes imps))
138− || any (eqQual mn') (f (importedDataConstructors imps))
139− || any (eqQual mn') (f (importedTypeClasses imps))
140− || any (eqQual mn') (f (importedValues imps))
138+ testQuals f mn' = any (isQualifiedWith mn') (f (importedTypes imps))
139+ || any (isQualifiedWith mn') (f (importedDataConstructors imps))
140+ || any (isQualifiedWith mn') (f (importedTypeClasses imps))
141+ || any (isQualifiedWith mn') (f (importedValues imps))
141142
142143 -- Check whether a module name refers to a module that has been imported
143144 -- without qualification into an import scope.
144145 isImportedModule :: ModuleName -> Bool
145146 isImportedModule = flip elem (importedModules imps)
146147
147− -- Check whether a module name matches that of a qualified value.
148− eqQual :: ModuleName -> Qualified a -> Bool
149− eqQual mn'' (Qualified (Just mn''') _) = mn'' == mn'''
150− eqQual _ _ = False
151−
152148 -- Constructs a list of types with their data constructors and the original
153149 -- module they were defined in from a list of type and data constructor names.
154150 resolveTypeExports