git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Error when re-exporting a pseudo module with conflicts
6492c77Gary Burgess
examples/failing/ConflictingQualifiedImports.pursnew file+17
@@ -0,0 +1,17 @@
1+-- @shouldFailWith ScopeConflict
2+module A where
3+
4+ thing :: Int
5+ thing = 1
6+
7+module B where
8+
9+ thing :: Int
10+ thing = 2
11+
12+module Main where
13+
14+ import A as X
15+ import B as X
16+
17+ foo = X.thing
examples/failing/ConflictingQualifiedImports2.pursnew file+15
@@ -0,0 +1,15 @@
1+-- @shouldFailWith ScopeConflict
2+module A where
3+
4+ thing :: Int
5+ thing = 1
6+
7+module B where
8+
9+ thing :: Int
10+ thing = 2
11+
12+module Main (module X) where
13+
14+ import A as X
15+ import B as X
src/Language/PureScript/Sugar/Names/Exports.hs+4−5
@@ -115,12 +115,11 @@ resolveExports env mn imps exps refs =
115 -> (a -> String)
115 -> (a -> String)
116 -> M.Map (Qualified a) [(Qualified a, ModuleName)]
116 -> M.Map (Qualified a) [(Qualified a, ModuleName)]
117 -> m [Qualified a]
117 -> m [Qualified a]
118− extract useQual name render = fmap (map (fst . head . snd)) . go useQual . M.toList
118+ extract useQual name render = fmap (map (fst . head . snd)) . go . M.toList
119 where
119 where
120− go True = filterM (return . eqQual name . fst)
121− go False = filterM $ \(_, options) -> do
120+ go = filterM $ \(name', options) -> do
122− let isMatch = any (eqQual name . fst) options
121+ let isMatch = if useQual then eqQual name name' else any (eqQual name . fst) options
123− when (length options > 1) $ checkImportConflicts render options
122+ when (isMatch && length options > 1) $ checkImportConflicts render options
124 return isMatch
123 return isMatch
125
124
126 -- Check whether a module name refers to a "pseudo module" that came into
125 -- Check whether a module name refers to a "pseudo module" that came into