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

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
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 which provides
emulation of this feature for older GHCs.

Reviewed By: bgamari

Differential Revision:
parent 233d1312
...@@ -3085,8 +3085,19 @@ supportedLanguageOverlays :: [String] ...@@ -3085,8 +3085,19 @@ supportedLanguageOverlays :: [String]
supportedLanguageOverlays = map flagSpecName safeHaskellFlags supportedLanguageOverlays = map flagSpecName safeHaskellFlags
supportedExtensions :: [String] supportedExtensions :: [String]
supportedExtensions supportedExtensions = concatMap toFlagSpecNamePair xFlags
= concatMap (\name -> [name, "No" ++ name]) (map flagSpecName 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]
| otherwise = [name, noName]
noName = "No" ++ name
name = flagSpecName flg
supportedLanguagesAndExtensions :: [String] supportedLanguagesAndExtensions :: [String]
supportedLanguagesAndExtensions = 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