Unverified Commit 6207f27c authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub
Browse files

Merge pull request #7235 from phadej/issue-7234

Issue 7234: other-extension cannot be omitted.
parents e5a3fbd6 f9e0fab9
......@@ -146,6 +146,19 @@ class
-> g s a
-> g s a
-- | Annotate field with since spec-version.
-- This is used to recognise, but warn about the field.
-- It is used to process @other-extensions@ field.
--
-- Default implementation is to not warn.
--
-- @since 3.4.0.0
availableSinceWarn
:: CabalSpecVersion -- ^ spec version
-> g s a
-> g s a
availableSinceWarn _ = id
-- | Field which can be defined at most once.
uniqueField
:: (FieldGrammar c g, c (Identity a))
......
......@@ -287,6 +287,20 @@ instance FieldGrammar Parsec ParsecFieldGrammar where
pure def
availableSinceWarn vs (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'
where
parser' v values
| v >= vs = parser v values
| otherwise = do
let unknownFields = Map.intersection values $ Map.fromSet (const ()) names
for_ (Map.toList unknownFields) $ \(name, fields) ->
for_ fields $ \(MkNamelessField pos _) ->
parseWarning pos PWTUnknownField $
"The field " <> show name <> " is available only since the Cabal specification version " ++ showCabalSpecVersion vs ++ "."
parser v values
-- todo we know about this field
deprecatedSince vs msg (ParsecFG names prefixes parser) = ParsecFG names prefixes parser'
where
......
......@@ -554,7 +554,7 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "default-extensions" (alaList' FSep MQuoted) L.defaultExtensions
^^^ availableSince CabalSpecV1_10 []
<*> monoidalFieldAla "other-extensions" formatOtherExtensions L.otherExtensions
^^^ availableSince CabalSpecV1_10 []
^^^ availableSinceWarn CabalSpecV1_10
<*> monoidalFieldAla "extensions" (alaList' FSep MQuoted) L.oldExtensions
^^^ deprecatedSince CabalSpecV1_12
"Please use 'default-extensions' or 'other-extensions' fields."
......
......@@ -90,8 +90,8 @@ convId ipi = (pn, I ver $ Inst $ IPI.installedUnitId ipi)
convIP :: SI.InstalledPackageIndex -> IPI.InstalledPackageInfo -> (PN, I, PInfo)
convIP idx ipi =
case traverse (convIPId (DependencyReason pn M.empty S.empty) comp idx) (IPI.depends ipi) of
Nothing -> (pn, i, PInfo [] M.empty M.empty (Just Broken))
Just fds -> ( pn, i, PInfo fds components M.empty Nothing)
Left u -> (pn, i, PInfo [] M.empty M.empty (Just (Broken u)))
Right fds -> (pn, i, PInfo fds components M.empty Nothing)
where
-- TODO: Handle sub-libraries and visibility.
components =
......@@ -141,13 +141,13 @@ convIP idx ipi =
-- May return Nothing if the package can't be found in the index. That
-- indicates that the original package having this dependency is broken
-- and should be ignored.
convIPId :: DependencyReason PN -> Component -> SI.InstalledPackageIndex -> UnitId -> Maybe (FlaggedDep PN)
convIPId :: DependencyReason PN -> Component -> SI.InstalledPackageIndex -> UnitId -> Either UnitId (FlaggedDep PN)
convIPId dr comp idx ipid =
case SI.lookupUnitId idx ipid of
Nothing -> Nothing
Nothing -> Left ipid
Just ipi -> let (pn, i) = convId ipi
name = ExposedLib LMainLibName -- TODO: Handle sub-libraries.
in Just (D.Simple (LDep dr (Dep (PkgComponent pn name) (Fixed i))) comp)
in Right (D.Simple (LDep dr (Dep (PkgComponent pn name) (Fixed i))) comp)
-- NB: something we pick up from the
-- InstalledPackageIndex is NEVER an executable
......
......@@ -230,7 +230,7 @@ showFR _ CannotInstall = " (only already installed instances
showFR _ CannotReinstall = " (avoiding to reinstall a package with same version but new dependencies)"
showFR _ NotExplicit = " (not a user-provided goal nor mentioned as a constraint, but reject-unconstrained-dependencies was set)"
showFR _ Shadowed = " (shadowed by another installed package with same version)"
showFR _ Broken = " (package is broken)"
showFR _ (Broken u) = " (package is broken, missing depenedency " ++ prettyShow u ++ ")"
showFR _ UnknownPackage = " (unknown package)"
showFR _ (GlobalConstraintVersion vr src) = " (" ++ constraintSource src ++ " requires " ++ prettyShow vr ++ ")"
showFR _ (GlobalConstraintInstalled src) = " (" ++ constraintSource src ++ " requires installed instance)"
......
......@@ -32,6 +32,7 @@ import Distribution.Solver.Types.ConstraintSource
import Distribution.Solver.Types.Flag
import Distribution.Solver.Types.PackagePath
import Distribution.Types.PkgconfigVersionRange
import Distribution.Types.UnitId (UnitId)
import Language.Haskell.Extension (Extension, Language)
type Weight = Double
......@@ -111,7 +112,7 @@ data FailReason = UnsupportedExtension Extension
| CannotReinstall
| NotExplicit
| Shadowed
| Broken
| Broken UnitId
| UnknownPackage
| GlobalConstraintVersion VR ConstraintSource
| GlobalConstraintInstalled ConstraintSource
......
......@@ -2480,7 +2480,7 @@ availableSourceTargets elab =
(Nothing, True) -> TargetBuildable (elabUnitId elab, cname)
TargetNotRequestedByDefault
(Just True, False) ->
error "componentAvailableTargetStatus: impossible"
error $ "componentAvailableTargetStatus: impossible; cname=" ++ prettyShow cname
where
cname = componentName component
buildable = PD.buildable (componentBuildInfo component)
......
# cabal v2-build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: issue7234 (user goal)
[__0] rejecting: issue7234-0 (conflict: requires HopefullyThisExtensionWontOccur)
[__0] fail (backjumping, conflict set: issue7234)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: issue7234 (2)
import Test.Cabal.Prelude
main = cabalTest $
-- this should fail,
-- none of GHC have extension declared in other-extensions
fails $ cabal "v2-build" ["all"]
cabal-version: >=1.8
name: issue7234
version: 0
synopsis: Old cabal-version package
description: But we have other-extensions to guide solver
author: Oleg Grenrus
category: Tests
maintainer: oleg.grenrus@iki.fi
build-type: Simple
library
build-depends: base <5
other-extensions: HopefullyThisExtensionWontOccur
exposed-modules: M
# cabal v2-build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- issue7234-0 (lib) (first run)
Warning: issue7234.cabal:14:3: The field "other-extensions" is available only since the Cabal specification version 1.10.
Configuring library for issue7234-0..
Preprocessing library for issue7234-0..
Building library for issue7234-0..
import Test.Cabal.Prelude
main = cabalTest $
-- this should not fail, just warn.
cabal "v2-build" ["all"]
cabal-version: >=1.8
name: issue7234
version: 0
synopsis: Old cabal-version package
description: But we have other-extensions to guide solver
author: Oleg Grenrus
category: Tests
maintainer: oleg.grenrus@iki.fi
build-type: Simple
library
build-depends: base <5
-- this extension is in virtually all GHCs, but there should be a warning
other-extensions: GADTs
exposed-modules: M
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