summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2017-02-22 19:54:40 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2017-02-23 13:46:07 -0800
commitde805583db457e2ee64468f3ed4cd9092d4ef8c8 (patch)
tree8ed65450a76b2bc9050cc394834f13db0f9c6a55
parent050f05df7b3f33bf2ec66b103aaaa19ff9d08116 (diff)
downloadhaskell-de805583db457e2ee64468f3ed4cd9092d4ef8c8.tar.gz
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@cs.stanford.edu> Test Plan: validate Reviewers: rwbarton, bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3172
-rw-r--r--compiler/main/DriverPhases.hs11
-rw-r--r--compiler/main/DriverPipeline.hs4
2 files changed, 12 insertions, 3 deletions
diff --git a/compiler/main/DriverPhases.hs b/compiler/main/DriverPhases.hs
index 650bb15269..57b2417100 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 adebdf4537..ca82e73f87 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.