git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #558 from purescript/422

Fix #422 wrong "unknown module" error

commitb55d164482551dfaae31628cc9ee5cd88eac6c04 authorPhil Freeman <paf31@cantab.net> dateMon 11 Aug 2014, 08:33 (12 years ago) parent29fe90161e1cee
1 file changed+9−7
src/Language/PureScript/Sugar/Names.hs+9−7
src/Language/PureScript/Sugar/Names.hs+9−7
@@ -253,15 +253,19 @@ renameInModule imports exports (Module mn decls exps) =
253253 -> Qualified a
254254 -> Maybe SourcePos
255255 -> 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
257257 (Just qname', _) -> return qname'
258258 (Nothing, Just mn'') -> do
259+ when (isExplicitQualModule mn'') $ throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show qname ++ "'") Nothing
259260 modExports <- getExports mn''
260261 if checkE modExports name
261262 then return qname
262− else positioned $ throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show qname ++ "'") Nothing
263− _ -> positioned $ throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show name ++ "'") Nothing
263+ else throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show qname ++ "'") Nothing
264+ _ -> throwError $ mkErrorStack ("Unknown " ++ t ++ " '" ++ show name ++ "'") Nothing
264265 where
266+ isExplicitQualModule :: ModuleName -> Bool
267+ isExplicitQualModule = flip elem $ mapMaybe (\(Qualified q _) -> q) (M.keys imports')
268+ imports' = getI imports
265269 positioned err = case pos of
266270 Nothing -> err
267271 Just pos' -> rethrowWithPosition pos' err
@@ -452,9 +456,9 @@ resolveImport currentModule importModule exps imps impQual =
452456
453457 -- Check if DeclarationRef points to an existent symbol
454458 checkedRefs :: [DeclarationRef] -> Either ErrorStack [DeclarationRef]
455− checkedRefs refs = mapM check refs
459+ checkedRefs = mapM check
456460 where
457− check (PositionedDeclarationRef pos r) = do
461+ check (PositionedDeclarationRef pos r) =
458462 rethrowWithPosition pos $ check r
459463 check ref@(ValueRef name) =
460464 checkImportExists "value" values name >> return ref
@@ -498,5 +502,3 @@ resolveImport currentModule importModule exps imps impQual =
498502 if item `elem` exports
499503 then return item
500504 else throwError $ mkErrorStack ("Cannot import unknown " ++ t ++ " '" ++ show item ++ "' from '" ++ show importModule ++ "'") Nothing
501−
502−