git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1105 from mjgpy3/1088_import_module_name
f9d6d0cPhil Freeman
src/Language/PureScript/Errors.hs+4−1
@@ -390,7 +390,7 @@ prettyPrintSingleError full e = prettyPrintErrorMessage <$> onTypesInErrorMessag
390 goSimple (UnknownValue name) = line $ "Unknown value " ++ show name
390 goSimple (UnknownValue name) = line $ "Unknown value " ++ show name
391 goSimple (UnknownTypeConstructor name) = line $ "Unknown type constructor " ++ show name
391 goSimple (UnknownTypeConstructor name) = line $ "Unknown type constructor " ++ show name
392 goSimple (UnknownDataConstructor dc tc) = line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
392 goSimple (UnknownDataConstructor dc tc) = line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
393− goSimple (ConflictingImport nm mn) = line $ "Declaration " ++ nm ++ " conflicts with import " ++ show mn
393+ goSimple (ConflictingImport nm mn) = line $ "Cannot declare `" ++ nm ++ "` since another declaration of that name was imported from `" ++ show mn ++ "`"
394 goSimple (ConflictingImports nm m1 m2) = line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
394 goSimple (ConflictingImports nm m1 m2) = line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
395 goSimple (ConflictingTypeDecls nm) = line $ "Conflicting type declarations for " ++ show nm
395 goSimple (ConflictingTypeDecls nm) = line $ "Conflicting type declarations for " ++ show nm
396 goSimple (ConflictingCtorDecls nm) = line $ "Conflicting data constructor declarations for " ++ show nm
396 goSimple (ConflictingCtorDecls nm) = line $ "Conflicting data constructor declarations for " ++ show nm
@@ -544,6 +544,9 @@ prettyPrintSingleError full e = prettyPrintErrorMessage <$> onTypesInErrorMessag
544 suggestions :: ErrorMessage -> [Box.Box]
544 suggestions :: ErrorMessage -> [Box.Box]
545 suggestions = suggestions' . unwrapErrorMessage
545 suggestions = suggestions' . unwrapErrorMessage
546 where
546 where
547+ suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide `" ++ nm ++ "` when importing `" ++ show im ++ "`:"
548+ , indent . line $ "import " ++ show im ++ " hiding (" ++ nm ++ ")"
549+ ]
547 suggestions' (TypesDoNotUnify t1 t2)
550 suggestions' (TypesDoNotUnify t1 t2)
548 | any isObject [t1, t2] = [line "Note that function composition in PureScript is defined using `(<<<)`"]
551 | any isObject [t1, t2] = [line "Note that function composition in PureScript is defined using `(<<<)`"]
549 | otherwise = []
552 | otherwise = []
src/Language/PureScript/Sugar/Names.hs+2−2
@@ -514,8 +514,8 @@ resolveImport currentModule importModule exps imps impQual =
514 Just (Qualified Nothing _) -> error "Invalid state in updateImports"
514 Just (Qualified Nothing _) -> error "Invalid state in updateImports"
515 Just (Qualified (Just mn) _) -> throwError . errorMessage $ err
515 Just (Qualified (Just mn) _) -> throwError . errorMessage $ err
516 where
516 where
517− err = if mn == currentModule || importModule == currentModule
517+ err = if currentModule `elem` [mn, importModule]
518− then ConflictingImport (show name) mn
518+ then ConflictingImport (show name) importModule
519 else ConflictingImports (show name) mn importModule
519 else ConflictingImports (show name) mn importModule
520
520
521 -- The available values, types, and classes in the module being imported
521 -- The available values, types, and classes in the module being imported