git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Correct ConflictingImport error, add suggestion. Resolves #1088.
commit4e92b9bc5ef494a482f0a9166974c2d0d88a61fa authorMichael Gilliland <mjg.py3@gmail.com> dateWed 6 May 2015, 19:37 (11 years ago) parentd54416a
2 files changed+6−3
src/Language/PureScript/Errors.hs+4−1 src/Language/PureScript/Sugar/Names.hs+2−2
src/Language/PureScript/Errors.hs+4−1
@@ -387,7 +387,7 @@ prettyPrintSingleError full e = prettyPrintErrorMessage <$> onTypesInErrorMessag
387387 goSimple (UnknownValue name) = line $ "Unknown value " ++ show name
388388 goSimple (UnknownTypeConstructor name) = line $ "Unknown type constructor " ++ show name
389389 goSimple (UnknownDataConstructor dc tc) = line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
390− goSimple (ConflictingImport nm mn) = line $ "Declaration " ++ nm ++ " conflicts with import " ++ show mn
390+ goSimple (ConflictingImport nm mn) = line $ "Cannot declare `" ++ nm ++ "` since another declaration of that name was imported from `" ++ show mn ++ "`"
391391 goSimple (ConflictingImports nm m1 m2) = line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
392392 goSimple (ConflictingTypeDecls nm) = line $ "Conflicting type declarations for " ++ show nm
393393 goSimple (ConflictingCtorDecls nm) = line $ "Conflicting data constructor declarations for " ++ show nm
@@ -540,6 +540,9 @@ prettyPrintSingleError full e = prettyPrintErrorMessage <$> onTypesInErrorMessag
540540 suggestions :: ErrorMessage -> [Box.Box]
541541 suggestions = suggestions' . unwrapErrorMessage
542542 where
543+ suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide `" ++ nm ++ "` when importing `" ++ show im ++ "`:"
544+ , indent . line $ "import " ++ show im ++ " hiding (" ++ nm ++ ")"
545+ ]
543546 suggestions' (TypesDoNotUnify t1 t2)
544547 | any isObject [t1, t2] = [line "Note that function composition in PureScript is defined using `(<<<)`"]
545548 | otherwise = []
src/Language/PureScript/Sugar/Names.hs+2−2
@@ -514,8 +514,8 @@ resolveImport currentModule importModule exps imps impQual =
514514 Just (Qualified Nothing _) -> error "Invalid state in updateImports"
515515 Just (Qualified (Just mn) _) -> throwError . errorMessage $ err
516516 where
517− err = if mn == currentModule || importModule == currentModule
518− then ConflictingImport (show name) mn
517+ err = if currentModule `elem` [mn, importModule]
518+ then ConflictingImport (show name) importModule
519519 else ConflictingImports (show name) mn importModule
520520
521521 -- The available values, types, and classes in the module being imported