Skip to content

Commit b48a620

Browse files
tbidnemergify[bot]
andauthored
Improve bad cabal-version error message (#9754)
See: #4899 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 6f76be3 commit b48a620

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ parseGenericPackageDescription bs = do
8888
Just csv -> return (Just csv)
8989
Nothing ->
9090
parseFatalFailure zeroPos $
91-
"Unsupported cabal-version " ++ prettyShow v ++ ". See https://github.com/haskell/cabal/issues/4899."
91+
"Unsupported cabal format version in cabal-version field: "
92+
++ prettyShow v
93+
++ ".\n"
94+
++ cabalFormatVersionsDesc
9295
_ -> pure Nothing
9396

9497
case readFields' bs'' of
@@ -175,8 +178,8 @@ parseGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do
175178
-- if it were at the beginning, scanner would found it
176179
when (v >= CabalSpecV2_2) $
177180
parseFailure pos $
178-
"cabal-version should be at the beginning of the file starting with spec version 2.2. "
179-
++ "See https://github.com/haskell/cabal/issues/4899"
181+
"cabal-version should be at the beginning of the file starting with spec version 2.2.\n"
182+
++ cabalFormatVersionsDesc
180183

181184
return v
182185

@@ -234,6 +237,10 @@ parseGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do
234237
++ "' must use section syntax. See the Cabal user guide for details."
235238
maybeWarnCabalVersion _ _ = return ()
236239

240+
-- See #4899
241+
cabalFormatVersionsDesc :: String
242+
cabalFormatVersionsDesc = "Current cabal-version values are listed at https://cabal.readthedocs.io/en/stable/file-format-changelog.html."
243+
237244
goSections :: CabalSpecVersion -> [Field Position] -> SectionParser ()
238245
goSections specVer = traverse_ process
239246
where
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VERSION: Just (mkVersion [99999,9])
2-
forward-compat.cabal:0:0: Unsupported cabal-version 99999.9. See https://github.com/haskell/cabal/issues/4899.
2+
forward-compat.cabal:0:0: Unsupported cabal format version in cabal-version field: 99999.9.
3+
Current cabal-version values are listed at https://cabal.readthedocs.io/en/stable/file-format-changelog.html.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VERSION: Just (mkVersion [2,2])
2-
forward-compat2.cabal:5:1: cabal-version should be at the beginning of the file starting with spec version 2.2. See https://github.com/haskell/cabal/issues/4899
2+
forward-compat2.cabal:5:1: cabal-version should be at the beginning of the file starting with spec version 2.2.
3+
Current cabal-version values are listed at https://cabal.readthedocs.io/en/stable/file-format-changelog.html.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VERSION: Just (mkVersion [99999,99])
2-
forward-compat3.cabal:0:0: Unsupported cabal-version 99999.99. See https://github.com/haskell/cabal/issues/4899.
2+
forward-compat3.cabal:0:0: Unsupported cabal format version in cabal-version field: 99999.99.
3+
Current cabal-version values are listed at https://cabal.readthedocs.io/en/stable/file-format-changelog.html.

0 commit comments

Comments
 (0)