@@ -16,6 +16,7 @@ import Control.Monad.Writer (MonadWriter(..), censor)
16import Control.Monad.State.Lazy
16import Control.Monad.State.Lazy
18import qualified Data.Map as M
18import qualified Data.Map as M
19+import qualified Data.Set as S
20import Language.PureScript.Crash
21import Language.PureScript.Crash
21import Language.PureScript.AST
22import Language.PureScript.AST
@@ -257,17 +258,21 @@ renameInModule env imports (Module ss coms mn decls exps) =
257 -- by qualified importing). If that's not the case, then we just need to
258 -- by qualified importing). If that's not the case, then we just need to
258 -- check it refers to a symbol in another module.
259 -- check it refers to a symbol in another module.
259 (Nothing, Just mn'') -> do
260 (Nothing, Just mn'') -> do
260− modExports <- getExports env mn''
261+ case M.lookup mn'' env of
263+ | mn'' `S.member` importedVirtualModules imports -> throwUnknown
261− maybe (throwError . errorMessage $ unknown qname) return (getE modExports name)
264+ | otherwise -> throwError . errorMessage $ UnknownModule mn''
265+ Just env' -> maybe throwUnknown return (getE (envModuleExports env') name)
263 -- If neither of the above cases are true then it's an undefined or
267 -- If neither of the above cases are true then it's an undefined or
264 -- unimported symbol.
268 -- unimported symbol.
265− _ -> throwError . errorMessage $ unknown qname
269+ _ -> throwUnknown
268 positioned err = case pos of
272 positioned err = case pos of
269 Nothing -> err
273 Nothing -> err
270 Just pos' -> rethrowWithPosition pos' err
274 Just pos' -> rethrowWithPosition pos' err
275+ throwUnknown = throwError . errorMessage $ unknown qname
273-- Replaces `ProperRef` export values with a `TypeRef` or `TypeClassRef`
278-- Replaces `ProperRef` export values with a `TypeRef` or `TypeClassRef`