summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-23 14:46:21 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-01-25 05:24:57 -0500
commitb3e5c678851ed73897b0eb337e656ff377d242c9 (patch)
tree40eaa03e6eb8ba3c7f815cbbaf43c76aae59b0f6
parent0a5e4f5f7d6cef16b6b11ac8d3a269b92016ed5d (diff)
downloadhaskell-b3e5c678851ed73897b0eb337e656ff377d242c9.tar.gz
hadrian: Throw error on duplicate-named flavours
Throw an error if the user requests a flavour for which there is more than one match. Fixes #17156.
-rwxr-xr-xhadrian/src/Settings.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/hadrian/src/Settings.hs b/hadrian/src/Settings.hs
index 2263f68107..068e7ba914 100755
--- a/hadrian/src/Settings.hs
+++ b/hadrian/src/Settings.hs
@@ -58,12 +58,14 @@ flavour :: Action Flavour
flavour = do
flavourName <- fromMaybe userDefaultFlavour <$> cmdFlavour
kvs <- userSetting ([] :: [KeyVal])
- let unknownFlavour = error $ "Unknown build flavour: " ++ flavourName
- flavours = hadrianFlavours ++ userFlavours
+ let flavours = hadrianFlavours ++ userFlavours
(_settingErrs, tweak) = applySettings kvs
- return $ maybe unknownFlavour tweak $
- find ((== flavourName) . name) flavours
+ return $
+ case filter (\fl -> name fl == flavourName) flavours of
+ [] -> error $ "Unknown build flavour: " ++ flavourName
+ [f] -> tweak f
+ _ -> error $ "Multiple build flavours named " ++ flavourName
getIntegerPackage :: Expr Package
getIntegerPackage = expr (integerLibrary =<< flavour)