Commit ff06176b authored by Roland Senn's avatar Roland Senn Committed by Ben Gamari

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
parent 4fc6524a
......@@ -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
......
main :: IO()
main = putStrLn "T12625"
ghc: on the commandline: missing argument for flag: -I
Usage: For basic information, try the `--help' option.
......@@ -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'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment