import Panic
-- Standard Haskell libraries
-import Control.Exception ( throwDyn )
import System.IO
import System.Environment
import System.Exit
_other -> 1
}
+ -- turn on -fimplicit-import-qualified for GHCi now, so that it
+ -- can be overriden from the command-line
+ dflags1a | DoInteractive <- cli_mode = imp_qual_enabled
+ | DoEval _ <- cli_mode = imp_qual_enabled
+ | otherwise = dflags1
+ where imp_qual_enabled = dflags1 `dopt_set` Opt_ImplicitImportQualified
+
-- The rest of the arguments are "dynamic"
-- Leftover ones are presumably files
- (dflags2, fileish_args, dynamicFlagWarnings) <- GHC.parseDynamicFlags dflags1 argv3
+ (dflags2, fileish_args, dynamicFlagWarnings) <- GHC.parseDynamicFlags dflags1a argv3
let flagWarnings = staticFlagWarnings
++ modeFlagWarnings
#ifndef GHCI
interactiveUI :: a -> b -> c -> IO ()
interactiveUI _ _ _ =
- throwDyn (CmdLineError "not built for interactive use")
+ ghcError (CmdLineError "not built for interactive use")
#endif
-- -----------------------------------------------------------------------------
-- -prof and --interactive are not a good combination
when (notNull (filter (not . isRTSWay) (wayNames dflags))
&& isInterpretiveMode cli_mode) $
- do throwDyn (UsageError
+ do ghcError (UsageError
"--interactive can't be used with -prof or -unreg.")
-- -ohi sanity check
if (isJust (outputHi dflags) &&
(isCompManagerMode cli_mode || srcs `lengthExceeds` 1))
- then throwDyn (UsageError "-ohi can only be used when compiling a single source file")
+ then ghcError (UsageError "-ohi can only be used when compiling a single source file")
else do
-- -o sanity checking
if (srcs `lengthExceeds` 1 && isJust (outputFile dflags)
&& not (isLinkMode cli_mode))
- then throwDyn (UsageError "can't apply -o to multiple source files")
+ then ghcError (UsageError "can't apply -o to multiple source files")
else do
-- Check that there are some input files
-- (except in the interactive case)
if null srcs && null objs && needsInputsMode cli_mode
- then throwDyn (UsageError "no input files")
+ then ghcError (UsageError "no input files")
else do
-- Verify that output files point somewhere sensible.
when (not flg) (nonExistentDir "-ohi" hi)
where
nonExistentDir flg dir =
- throwDyn (CmdLineError ("error: directory portion of " ++
+ ghcError (CmdLineError ("error: directory portion of " ++
show dir ++ " does not exist (used with " ++
show flg ++ " option.)"))
let ((leftover, errs, warns), (mode, _, flags')) =
runCmdLine (processArgs mode_flags args) (StopBefore StopLn, "", [])
when (not (null errs)) $ do
- throwDyn (UsageError (unlines errs))
+ ghcError (UsageError (unlines errs))
return (mode, flags' ++ leftover, warns)
type ModeM = CmdLineP (CmdLineMode, String, [String])
updateMode f flag = do
(old_mode, old_flag, flags') <- getCmdLineState
if notNull old_flag && flag /= old_flag
- then throwDyn (UsageError
+ then ghcError (UsageError
("cannot use `" ++ old_flag ++ "' with `" ++ flag ++ "'"))
else putCmdLineState (f old_mode, flag, flags')
-- Run --make mode
doMake :: Session -> [(String,Maybe Phase)] -> IO ()
-doMake _ [] = throwDyn (UsageError "no input files")
+doMake _ [] = ghcError (UsageError "no input files")
doMake sess srcs = do
let (hs_srcs, non_hs_srcs) = partition haskellish srcs
-- Util
unknownFlagsErr :: [String] -> a
-unknownFlagsErr fs = throwDyn (UsageError ("unrecognised flags: " ++ unwords fs))
+unknownFlagsErr fs = ghcError (UsageError ("unrecognised flags: " ++ unwords fs))