[commit: ghc] master: Give better error message with you run ghc foo.bkp (de80558)
git at git.haskell.org
git at git.haskell.org
Thu Feb 23 21:46:37 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/de805583db457e2ee64468f3ed4cd9092d4ef8c8/ghc
>---------------------------------------------------------------
commit de805583db457e2ee64468f3ed4cd9092d4ef8c8
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Wed Feb 22 19:54:40 2017 -0800
Give better error message with you run ghc foo.bkp
Summary:
Detect Backpackish suffixes, and bail out if we try
to run them in the pipeline.
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
Test Plan: validate
Reviewers: rwbarton, bgamari, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3172
>---------------------------------------------------------------
de805583db457e2ee64468f3ed4cd9092d4ef8c8
compiler/main/DriverPhases.hs | 11 ++++++++---
compiler/main/DriverPipeline.hs | 4 ++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/compiler/main/DriverPhases.hs b/compiler/main/DriverPhases.hs
index 650bb15..57b2417 100644
--- a/compiler/main/DriverPhases.hs
+++ b/compiler/main/DriverPhases.hs
@@ -18,6 +18,7 @@ module DriverPhases (
isHaskellishSuffix,
isHaskellSrcSuffix,
+ isBackpackishSuffix,
isObjectSuffix,
isCishSuffix,
isDynLibSuffix,
@@ -291,7 +292,7 @@ phaseInputExt Cmm = "cmmcpp"
phaseInputExt MergeStub = "o"
phaseInputExt StopLn = "o"
-haskellish_src_suffixes, haskellish_suffixes, cish_suffixes,
+haskellish_src_suffixes, backpackish_suffixes, haskellish_suffixes, cish_suffixes,
haskellish_user_src_suffixes, haskellish_sig_suffixes
:: [String]
-- When a file with an extension in the haskellish_src_suffixes group is
@@ -306,6 +307,7 @@ cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S", "ll", "
haskellish_user_src_suffixes =
haskellish_sig_suffixes ++ [ "hs", "lhs", "hs-boot", "lhs-boot" ]
haskellish_sig_suffixes = [ "hsig", "lhsig" ]
+backpackish_suffixes = [ "bkp" ]
objish_suffixes :: Platform -> [String]
-- Use the appropriate suffix for the system on which
@@ -320,10 +322,11 @@ dynlib_suffixes platform = case platformOS platform of
OSDarwin -> ["dylib", "so"]
_ -> ["so"]
-isHaskellishSuffix, isHaskellSrcSuffix, isCishSuffix,
+isHaskellishSuffix, isBackpackishSuffix, isHaskellSrcSuffix, isCishSuffix,
isHaskellUserSrcSuffix, isHaskellSigSuffix
:: String -> Bool
isHaskellishSuffix s = s `elem` haskellish_suffixes
+isBackpackishSuffix s = s `elem` backpackish_suffixes
isHaskellSigSuffix s = s `elem` haskellish_sig_suffixes
isHaskellSrcSuffix s = s `elem` haskellish_src_suffixes
isCishSuffix s = s `elem` cish_suffixes
@@ -334,7 +337,9 @@ isObjectSuffix platform s = s `elem` objish_suffixes platform
isDynLibSuffix platform s = s `elem` dynlib_suffixes platform
isSourceSuffix :: String -> Bool
-isSourceSuffix suff = isHaskellishSuffix suff || isCishSuffix suff
+isSourceSuffix suff = isHaskellishSuffix suff
+ || isCishSuffix suff
+ || isBackpackishSuffix suff
-- | When we are given files (modified by -x arguments) we need
-- to determine if they are Haskellish or not to figure out
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index adebdf4..ca82e73 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -601,6 +601,10 @@ runPipeline stop_phase hsc_env0 (input_fn, mb_phase)
src_suffix = suffix',
output_spec = output }
+ when (isBackpackishSuffix suffix') $
+ throwGhcExceptionIO (UsageError
+ ("use --backpack to process " ++ input_fn))
+
-- We want to catch cases of "you can't get there from here" before
-- we start the pipeline, because otherwise it will just run off the
-- end.
More information about the ghc-commits
mailing list