[commit: ghc] master: DynFlags: Don't list TemplateHaskell as supported if it's not (98a4fa5)

git at git.haskell.org git at git.haskell.org
Wed Nov 18 07:02:17 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/98a4fa5fb740ce43a1787eb5730e35b463a2de79/ghc

>---------------------------------------------------------------

commit 98a4fa5fb740ce43a1787eb5730e35b463a2de79
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Wed Nov 18 07:56:30 2015 +0100

    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


>---------------------------------------------------------------

98a4fa5fb740ce43a1787eb5730e35b463a2de79
 compiler/main/DynFlags.hs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 45fb72e..3a93e02 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -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 =



More information about the ghc-commits mailing list