Skip to content

Commit

Permalink
Error when re-exporting a pseudo module with conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
garyb committed Dec 11, 2015
1 parent e20d299 commit 6492c77
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
17 changes: 17 additions & 0 deletions examples/failing/ConflictingQualifiedImports.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- @shouldFailWith ScopeConflict
module A where

thing :: Int
thing = 1

module B where

thing :: Int
thing = 2

module Main where

import A as X
import B as X

foo = X.thing
15 changes: 15 additions & 0 deletions examples/failing/ConflictingQualifiedImports2.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- @shouldFailWith ScopeConflict
module A where

thing :: Int
thing = 1

module B where

thing :: Int
thing = 2

module Main (module X) where

import A as X
import B as X
9 changes: 4 additions & 5 deletions src/Language/PureScript/Sugar/Names/Exports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ resolveExports env mn imps exps refs =
-> (a -> String)
-> M.Map (Qualified a) [(Qualified a, ModuleName)]
-> m [Qualified a]
extract useQual name render = fmap (map (fst . head . snd)) . go useQual . M.toList
extract useQual name render = fmap (map (fst . head . snd)) . go . M.toList
where
go True = filterM (return . eqQual name . fst)
go False = filterM $ \(_, options) -> do
let isMatch = any (eqQual name . fst) options
when (length options > 1) $ checkImportConflicts render options
go = filterM $ \(name', options) -> do
let isMatch = if useQual then eqQual name name' else any (eqQual name . fst) options
when (isMatch && length options > 1) $ checkImportConflicts render options
return isMatch

-- Check whether a module name refers to a "pseudo module" that came into
Expand Down

0 comments on commit 6492c77

Please sign in to comment.