git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Allow duplicate imports
2c8ea37Gary Burgess
src/Language/PureScript/Errors.hs+1−1
@@ -454,7 +454,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
454 goSimple (ConflictingImport nm mn) =
454 goSimple (ConflictingImport nm mn) =
455 line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ show mn
455 line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ show mn
456 goSimple (ConflictingImports nm m1 m2) =
456 goSimple (ConflictingImports nm m1 m2) =
457− line $ "Conflicting imports for " ++ show nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
457+ line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
458 goSimple (ConflictingTypeDecls nm) =
458 goSimple (ConflictingTypeDecls nm) =
459 line $ "Conflicting type declarations for " ++ show nm
459 line $ "Conflicting type declarations for " ++ show nm
460 goSimple (ConflictingCtorDecls nm) =
460 goSimple (ConflictingCtorDecls nm) =
src/Language/PureScript/Sugar/Names.hs+8−5
@@ -589,11 +589,14 @@ resolveImport currentModule importModule exps imps impQual =
589 updateImports m name = case M.lookup (Qualified impQual name) m of
589 updateImports m name = case M.lookup (Qualified impQual name) m of
590 Nothing -> return $ M.insert (Qualified impQual name) (Qualified (Just importModule) name) m
590 Nothing -> return $ M.insert (Qualified impQual name) (Qualified (Just importModule) name) m
591 Just (Qualified Nothing _) -> error "Invalid state in updateImports"
591 Just (Qualified Nothing _) -> error "Invalid state in updateImports"
592+ Just (Qualified (Just mn) _)
593+ | mn == importModule -> return m
592− Just (Qualified (Just mn) _) -> throwError . errorMessage $ err
594+ | otherwise -> throwError . errorMessage $ err
593− where
595+ where
594− err = if currentModule `elem` [mn, importModule]
596+ err = if currentModule `elem` [mn, importModule]
595− then ConflictingImport (show name) importModule
597+ then ConflictingImport (show name) importModule
596− else ConflictingImports (show name) mn importModule
598+ else ConflictingImports (show name) mn importModule
599+
597
600
598 -- The available values, types, and classes in the module being imported
601 -- The available values, types, and classes in the module being imported
599 values = exportedValues exps
602 values = exportedValues exps