@@ -253,15 +253,19 @@ renameInModule imports exports (Module mn decls exps) =
253 -> Qualified a
253 -> Qualified a
254 -> Maybe SourcePos
254 -> Maybe SourcePos
255 -> Either ErrorStack (Qualified a)
255 -> Either ErrorStack (Qualified a)
256− update t getI checkE qname@(Qualified mn' name) pos = case (M.lookup qname (getI imports), mn') of
256+ update t getI checkE qname@(Qualified mn' name) pos = positioned $ case (M.lookup qname imports', mn') of
257 (Just qname', _) -> return qname'
257 (Just qname', _) -> return qname'
258 (Nothing, Just mn'') -> do
258 (Nothing, Just mn'') -> do
259+ when (isExplicitQualModule mn'') $ throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show qname ++ "'") Nothing
259 modExports <- getExports mn''
260 modExports <- getExports mn''
260 if checkE modExports name
261 if checkE modExports name
261 then return qname
262 then return qname
262− else positioned $ throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show qname ++ "'") Nothing
263+ else throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show qname ++ "'") Nothing
263− _ -> positioned $ throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show name ++ "'") Nothing
264+ _ -> throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show name ++ "'") Nothing
266+ isExplicitQualModule :: ModuleName -> Bool
267+ isExplicitQualModule = flip elem $ mapMaybe (\(Qualified q _) -> q) (M.keys imports')
268+ imports' = getI imports
265 positioned err = case pos of
269 positioned err = case pos of
266 Nothing -> err
270 Nothing -> err
267 Just pos' -> rethrowWithPosition pos' err
271 Just pos' -> rethrowWithPosition pos' err
@@ -452,9 +456,9 @@ resolveImport currentModule importModule exps imps impQual =
453 -- Check if DeclarationRef points to an existent symbol
457 -- Check if DeclarationRef points to an existent symbol
454 checkedRefs :: [DeclarationRef] -> Either ErrorStack [DeclarationRef]
458 checkedRefs :: [DeclarationRef] -> Either ErrorStack [DeclarationRef]
455− checkedRefs refs = mapM check refs
459+ checkedRefs = mapM check
457− check (PositionedDeclarationRef pos r) = do
461+ check (PositionedDeclarationRef pos r) =
458 rethrowWithPosition pos $ check r
462 rethrowWithPosition pos $ check r
459 check ref@(ValueRef name) =
463 check ref@(ValueRef name) =
460 checkImportExists "value" values name >> return ref
464 checkImportExists "value" values name >> return ref
@@ -498,5 +502,3 @@ resolveImport currentModule importModule exps imps impQual =
498 if item `elem` exports
502 if item `elem` exports
499 then return item
503 then return item
500 else throwError $ mkErrorStack ("Cannot import unknown " ++ t ++ " '" ++ show item ++ "' from '" ++ show importModule ++ "'") Nothing
504 else throwError $ mkErrorStack ("Cannot import unknown " ++ t ++ " '" ++ show item ++ "' from '" ++ show importModule ++ "'") Nothing