diff --git a/Cabal/Distribution/Types/PkgconfigName.hs b/Cabal/Distribution/Types/PkgconfigName.hs index a0e321fee23..61176687e81 100644 --- a/Cabal/Distribution/Types/PkgconfigName.hs +++ b/Cabal/Distribution/Types/PkgconfigName.hs @@ -56,7 +56,13 @@ instance Pretty PkgconfigName where pretty = Disp.text . unPkgconfigName instance Parsec PkgconfigName where - parsec = mkPkgconfigName <$> P.munch1 (\c -> isAlphaNum c || c `elem` "+-._") + parsec = mkPkgconfigName <$> P.munch1 isNameChar where + -- https://gitlab.haskell.org/ghc/ghc/issues/17752 + isNameChar '-' = True + isNameChar '_' = True + isNameChar '.' = True + isNameChar '+' = True + isNameChar c = isAlphaNum c instance NFData PkgconfigName where rnf (PkgconfigName pkg) = rnf pkg diff --git a/Cabal/Distribution/Types/PkgconfigVersionRange.hs b/Cabal/Distribution/Types/PkgconfigVersionRange.hs index f718af92efd..faa704f5fb6 100644 --- a/Cabal/Distribution/Types/PkgconfigVersionRange.hs +++ b/Cabal/Distribution/Types/PkgconfigVersionRange.hs @@ -86,7 +86,7 @@ pkgconfigParser = P.spaces >> expr where factor = parens expr <|> prim prim = do - op <- P.munch1 (`elem` "<>=^-") P. "operator" + op <- P.munch1 isOpChar P. "operator" case op of "-" -> anyPkgconfigVersion <$ (P.string "any" *> P.spaces) @@ -98,6 +98,14 @@ pkgconfigParser = P.spaces >> expr where _ -> P.unexpected $ "Unknown version operator " ++ show op + -- https://gitlab.haskell.org/ghc/ghc/issues/17752 + isOpChar '<' = True + isOpChar '=' = True + isOpChar '>' = True + isOpChar '^' = True + isOpChar '-' = True + isOpChar _ = False + afterOp f = do P.spaces v <- parsec diff --git a/Cabal/Distribution/Types/UnitId.hs b/Cabal/Distribution/Types/UnitId.hs index 4bdb09c9f3b..047a43f27c3 100644 --- a/Cabal/Distribution/Types/UnitId.hs +++ b/Cabal/Distribution/Types/UnitId.hs @@ -78,7 +78,13 @@ instance Pretty UnitId where -- GHC accepts for @-package-id@. -- instance Parsec UnitId where - parsec = mkUnitId <$> P.munch1 (\c -> isAlphaNum c || c `elem` "-_.+") + parsec = mkUnitId <$> P.munch1 isUnitChar where + -- https://gitlab.haskell.org/ghc/ghc/issues/17752 + isUnitChar '-' = True + isUnitChar '_' = True + isUnitChar '.' = True + isUnitChar '+' = True + isUnitChar c = isAlphaNum c -- | If you need backwards compatibility, consider using 'display' -- instead, which is supported by all versions of Cabal. diff --git a/Cabal/Distribution/Types/VersionRange/Internal.hs b/Cabal/Distribution/Types/VersionRange/Internal.hs index 73605d7e65d..9b84bea9cb3 100644 --- a/Cabal/Distribution/Types/VersionRange/Internal.hs +++ b/Cabal/Distribution/Types/VersionRange/Internal.hs @@ -293,7 +293,7 @@ versionRangeParser digitParser = expr factor = parens expr <|> prim prim = do - op <- P.munch1 (`elem` "<>=^-") P. "operator" + op <- P.munch1 isOpChar P. "operator" case op of "-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion' @@ -325,6 +325,14 @@ versionRangeParser digitParser = expr ">" -> pure $ laterVersion v _ -> fail $ "Unknown version operator " ++ show op + -- https://gitlab.haskell.org/ghc/ghc/issues/17752 + isOpChar '<' = True + isOpChar '=' = True + isOpChar '>' = True + isOpChar '^' = True + isOpChar '-' = True + isOpChar _ = False + -- Note: There are other features: -- && and || since 1.8 -- x.y.* (wildcard) since 1.6