Skip to content

Commit 5b81693

Browse files
committed
BUG: Parsect PackageIdentifier is broken
If we try to parse <flavour>-<version>-<pkg>-<version> for e.g. <pkg>-<version> this will break in -- | Parse the @setup-config@ file header, returning the package identifiers -- for Cabal and the compiler. parseHeader :: ByteString -- ^ The file contents. -> IO (PackageIdentifier, PackageIdentifier) The issue is that we I guess parse e.g. Cabal-x.y.z as compiler flavour + version, and then have nothing for the PackageIdentifier to parse. This code needs to be fixed properly to try and parse compier-version-pkg-version or only pkg-version (and set compiler to Nothing).
1 parent 0532529 commit 5b81693

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Cabal-syntax/src/Distribution/Types/PackageId.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ instance Pretty PackageIdentifier where
6464
-- Nothing
6565
instance Parsec PackageIdentifier where
6666
parsec = do
67-
comp <- parsec <* P.char '-'
67+
-- comp <- parsec <* P.char '-'
6868
xs' <- P.sepByNonEmpty component (P.char '-')
6969
(v, xs) <- case simpleParsec (NE.last xs') of
7070
Nothing -> return (nullVersion, toList xs') -- all components are version
7171
Just v -> return (v, NE.init xs')
7272
if not (null xs) && all (\c -> all (/= '.') c && not (all isDigit c)) xs
73-
then return $ PackageIdentifier (mkPackageName (intercalate "-" xs)) v comp
73+
then return $ PackageIdentifier (mkPackageName (intercalate "-" xs)) v Nothing
7474
else fail "all digits or a dot in a portion of package name"
7575
where
7676
component = P.munch1 (\c -> isAlphaNum c || c == '.')

0 commit comments

Comments
 (0)