[commit: ghc] master: Improve error message for flags with missing required arguments (#12625) (ff06176)
git at git.haskell.org
git at git.haskell.org
Mon Aug 6 22:30:04 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ff06176b87078ce56cc7b6b3405a029ef3d0046f/ghc
>---------------------------------------------------------------
commit ff06176b87078ce56cc7b6b3405a029ef3d0046f
Author: roland <rsx at bluewin.ch>
Date: Mon Aug 6 12:50:38 2018 -0400
Improve error message for flags with missing required arguments (#12625)
Test Plan: make TEST=T12625
Reviewers: jstolarek, austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #12625
Differential Revision: https://phabricator.haskell.org/D5030
>---------------------------------------------------------------
ff06176b87078ce56cc7b6b3405a029ef3d0046f
compiler/main/CmdLineParser.hs | 6 ++++--
testsuite/tests/driver/T12625.hs | 2 ++
testsuite/tests/driver/{T3364.stderr => T12625.stderr} | 2 +-
testsuite/tests/driver/all.T | 2 ++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/compiler/main/CmdLineParser.hs b/compiler/main/CmdLineParser.hs
index 49fbd8f..c876f58 100644
--- a/compiler/main/CmdLineParser.hs
+++ b/compiler/main/CmdLineParser.hs
@@ -242,8 +242,9 @@ processOneArg opt_kind rest arg args
[] -> missingArgErr dash_arg
(L _ arg1:args1) -> Right (f arg1, args1)
+ -- See Trac #12625
Prefix f | notNull rest_no_eq -> Right (f rest_no_eq, args)
- | otherwise -> unknownFlagErr dash_arg
+ | otherwise -> missingArgErr dash_arg
PrefixPred _ f | notNull rest_no_eq -> Right (f rest_no_eq, args)
| otherwise -> unknownFlagErr dash_arg
@@ -281,7 +282,8 @@ arg_ok :: OptKind t -> [Char] -> String -> Bool
arg_ok (NoArg _) rest _ = null rest
arg_ok (HasArg _) _ _ = True
arg_ok (SepArg _) rest _ = null rest
-arg_ok (Prefix _) rest _ = notNull rest
+arg_ok (Prefix _) _ _ = True -- Missing argument checked for in processOneArg t
+ -- to improve error message (Trac #12625)
arg_ok (PrefixPred p _) rest _ = notNull rest && p (dropEq rest)
arg_ok (OptIntSuffix _) _ _ = True
arg_ok (IntSuffix _) _ _ = True
diff --git a/testsuite/tests/driver/T12625.hs b/testsuite/tests/driver/T12625.hs
new file mode 100644
index 0000000..b34b914
--- /dev/null
+++ b/testsuite/tests/driver/T12625.hs
@@ -0,0 +1,2 @@
+main :: IO()
+main = putStrLn "T12625"
diff --git a/testsuite/tests/driver/T3364.stderr b/testsuite/tests/driver/T12625.stderr
similarity index 50%
copy from testsuite/tests/driver/T3364.stderr
copy to testsuite/tests/driver/T12625.stderr
index 852893f..a171dbd 100644
--- a/testsuite/tests/driver/T3364.stderr
+++ b/testsuite/tests/driver/T12625.stderr
@@ -1,2 +1,2 @@
-ghc: on the commandline: missing argument for flag: -H
+ghc: on the commandline: missing argument for flag: -I
Usage: For basic information, try the `--help' option.
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index 6397598..07dc3bf 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -264,6 +264,8 @@ test('T12192', normal, run_command, ['mkdir foo && (cd foo && {compiler} -v0 ../
test('T10923', [], run_command, ['$MAKE -s --no-print-directory T10923'])
+test('T12625', normal, compile_fail, ['-I'])
+
test('T12752pass', normal, compile, ['-DSHOULD_PASS=1 -Wcpp-undef'])
test('T12955', normal, run_command, ['$MAKE -s --no-print-directory T12955'])
More information about the ghc-commits
mailing list