Commit 98a4fa5f authored by Ben Gamari's avatar Ben Gamari Committed by Herbert Valerio Riedel

DynFlags: Don't list TemplateHaskell as supported if it's not

`-XTemplateHaskell` requires GHCi; don't show it in
`--supported-extensions` if it's not supported.

Together with https://github.com/haskell/cabal/issues/2644
this allows to finally fix a long-standing annoyance in cabal
of not being able to detect availability of TH in build-plans.

Fixes #11102

See also https://github.com/haskell/cabal/pull/2930 which provides
emulation of this feature for older GHCs.

Reviewed By: bgamari

Differential Revision: https://phabricator.haskell.org/D1484
parent 233d1312
......@@ -3085,8 +3085,19 @@ supportedLanguageOverlays :: [String]
supportedLanguageOverlays = map flagSpecName safeHaskellFlags
supportedExtensions :: [String]
supportedExtensions
= concatMap (\name -> [name, "No" ++ name]) (map flagSpecName xFlags)
supportedExtensions = concatMap toFlagSpecNamePair xFlags
where
toFlagSpecNamePair flg
#ifndef GHCI
-- make sure that `ghc --supported-extensions` omits
-- "TemplateHaskell" when it's known to be unsupported. See also
-- GHC #11102 for rationale
| flagSpecFlag flg == Opt_TemplateHaskell = [noName]
#endif
| otherwise = [name, noName]
where
noName = "No" ++ name
name = flagSpecName flg
supportedLanguagesAndExtensions :: [String]
supportedLanguagesAndExtensions =
......
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