Commit d5f1d21c authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺 Committed by GitHub
Browse files

Merge pull request #4778 from hvr/pr/case-sens-cli

Don't automatically case-correct mispelled package-names
parents 1e1ed457 7e895377
...@@ -614,10 +614,13 @@ reportPackageTargetProblems verbosity problems = do ...@@ -614,10 +614,13 @@ reportPackageTargetProblems verbosity problems = do
case [ (pkg, matches) | PackageNameAmbiguous pkg matches _ <- problems ] of case [ (pkg, matches) | PackageNameAmbiguous pkg matches _ <- problems ] of
[] -> return () [] -> return ()
ambiguities -> die' verbosity $ unlines ambiguities -> die' verbosity $ unlines
[ "The package name '" ++ display name [ "There is no package named '" ++ display name ++ "'. "
++ "' is ambiguous. It could be: " ++ (if length matches > 1
++ intercalate ", " (map display matches) then "However, the following package names exist: "
| (name, matches) <- ambiguities ] else "However, the following package name exists: ")
++ intercalate ", " [ "'" ++ display m ++ "'" | m <- matches]
++ "."
| (name, matches) <- ambiguities ]
case [ pkg | PackageNameUnknown pkg UserTargetWorld <- problems ] of case [ pkg | PackageNameUnknown pkg UserTargetWorld <- problems ] of
[] -> return () [] -> return ()
...@@ -636,11 +639,15 @@ reportPackageTargetProblems verbosity problems = do ...@@ -636,11 +639,15 @@ reportPackageTargetProblems verbosity problems = do
data MaybeAmbiguous a = None | Unambiguous a | Ambiguous [a] data MaybeAmbiguous a = None | Unambiguous a | Ambiguous [a]
-- | Given a package name and a list of matching names, figure out which one it -- | Given a package name and a list of matching names, figure out
-- might be referring to. If there is an exact case-sensitive match then that's -- which one it might be referring to. If there is an exact
-- ok. If it matches just one package case-insensitively then that's also ok. -- case-sensitive match then that's ok (i.e. returned via
-- The only problem is if it matches multiple packages case-insensitively, in -- 'Unambiguous'). If it matches just one package case-insensitively
-- that case it is ambiguous. -- or if it matches multiple packages case-insensitively, in that case
-- the result is 'Ambiguous'.
--
-- Note: Before cabal 2.2, when only a single package matched
-- case-insensitively it would be considered 'Unambigious'.
-- --
disambiguatePackageName :: PackageNameEnv disambiguatePackageName :: PackageNameEnv
-> PackageName -> PackageName
...@@ -648,7 +655,6 @@ disambiguatePackageName :: PackageNameEnv ...@@ -648,7 +655,6 @@ disambiguatePackageName :: PackageNameEnv
disambiguatePackageName (PackageNameEnv pkgNameLookup) name = disambiguatePackageName (PackageNameEnv pkgNameLookup) name =
case nub (pkgNameLookup name) of case nub (pkgNameLookup name) of
[] -> None [] -> None
[name'] -> Unambiguous name'
names -> case find (name==) names of names -> case find (name==) names of
Just name' -> Unambiguous name' Just name' -> Unambiguous name'
Nothing -> Ambiguous names Nothing -> Ambiguous names
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
2.2.0.0 (current development version) 2.2.0.0 (current development version)
* 'cabal configure' now supports '--enable-static' which can be * 'cabal configure' now supports '--enable-static' which can be
used to build static libaries with GHC via GHC's `-staticlib` flag. used to build static libaries with GHC via GHC's `-staticlib` flag.
* Don't automatically/silently case-correct mispelled package-names
on CLI (#4778)
* 'cabal update' now supports '--index-state' which can be used to * 'cabal update' now supports '--index-state' which can be used to
roll back the index to an earlier state. roll back the index to an earlier state.
* 'cabal new-configure' now backs up the old 'cabal.project.local' * 'cabal new-configure' now backs up the old 'cabal.project.local'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment