Skip to content

Commit 0a451a6

Browse files
committed
Fix: just a version is not a valid PackageId
1 parent 9f76d8f commit 0a451a6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Cabal/Distribution/Types/PackageId.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ instance Pretty PackageIdentifier where
5353
-- >>> simpleParsec "foo-bar.4-2" :: Maybe PackageIdentifier
5454
-- Nothing
5555
--
56+
-- >>> simpleParsec "1.2.3" :: Maybe PackageIdentifier
57+
-- Nothing
58+
--
5659
instance Parsec PackageIdentifier where
5760
parsec = do
5861
xs' <- P.sepBy1 component (P.char '-')
5962
(v, xs) <- case simpleParsec (last xs') of
6063
Nothing -> return (nullVersion, xs') -- all components are version
6164
Just v -> return (v, init xs')
62-
if all (\c -> all (/= '.') c && not (all isDigit c)) xs
65+
if not (null xs) && all (\c -> all (/= '.') c && not (all isDigit c)) xs
6366
then return $ PackageIdentifier (mkPackageName (intercalate "-" xs)) v
6467
else fail "all digits or a dot in a portion of package name"
6568
where

0 commit comments

Comments
 (0)