@@ -16,6 +16,7 @@ import Control.Monad.Writer (MonadWriter(..), censor)
1616import Control.Monad.State.Lazy
1717
1818import qualified Data.Map as M
19+import qualified Data.Set as S
1920
2021import Language.PureScript.Crash
2122import Language.PureScript.AST
@@ -257,17 +258,21 @@ renameInModule env imports (Module ss coms mn decls exps) =
257258 -- by qualified importing). If that's not the case, then we just need to
258259 -- check it refers to a symbol in another module.
259260 (Nothing, Just mn'') -> do
260− modExports <- getExports env mn''
261− maybe (throwError . errorMessage $ unknown qname) return (getE modExports name)
261+ case M.lookup mn'' env of
262+ Nothing
263+ | mn'' `S.member` importedVirtualModules imports -> throwUnknown
264+ | otherwise -> throwError . errorMessage $ UnknownModule mn''
265+ Just env' -> maybe throwUnknown return (getE (envModuleExports env') name)
262266
263267 -- If neither of the above cases are true then it's an undefined or
264268 -- unimported symbol.
265− _ -> throwError . errorMessage $ unknown qname
269+ _ -> throwUnknown
266270
267271 where
268272 positioned err = case pos of
269273 Nothing -> err
270274 Just pos' -> rethrowWithPosition pos' err
275+ throwUnknown = throwError . errorMessage $ unknown qname
271276
272277-- |
273278-- Replaces `ProperRef` export values with a `TypeRef` or `TypeClassRef`