diff options
author | Daishi Nakajima <nakaji.dayo@gmail.com> | 2017-01-18 16:23:55 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-01-18 17:39:48 -0500 |
commit | 181688abae5c0b32237a5bd783dfc9667641cce2 (patch) | |
tree | f54bf73606eb4315ac4bf1d970af64d0c8c42208 /ghc | |
parent | 852c6a09f8ac21c3e843e64dfa7c6382073eb5ce (diff) | |
download | haskell-181688abae5c0b32237a5bd783dfc9667641cce2.tar.gz |
Improve suggestion for misspelled flag including '=' (fixes #11789)
Test Plan:
Added 2 test cases, verified that ghc can suggest in the following
cases:
- for misspelled flag containing '=', ghc suggests flags that doesn't
contain '='
- for misspelled flag containing '=', ghc suggests flags that
contains '='
Reviewers: austin, dfeuer, bgamari
Reviewed By: dfeuer, bgamari
Subscribers: dfeuer, mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D2978
GHC Trac Issues: #11789
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index 83d5238176..a650d35a62 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -915,9 +915,18 @@ unknownFlagsErr fs = throwGhcException $ UsageError $ concatMap oneError fs where oneError f = "unrecognised flag: " ++ f ++ "\n" ++ - (case fuzzyMatch f (nub allNonDeprecatedFlags) of + (case match f (nubSort allNonDeprecatedFlags) of [] -> "" suggs -> "did you mean one of:\n" ++ unlines (map (" " ++) suggs)) + -- fixes #11789 + -- If the flag contains '=', + -- this uses both the whole and the left side of '=' for comparing. + match f allFlags + | elem '=' f = + let (flagsWithEq, flagsWithoutEq) = partition (elem '=') allFlags + fName = takeWhile (/= '=') f + in (fuzzyMatch f flagsWithEq) ++ (fuzzyMatch fName flagsWithoutEq) + | otherwise = fuzzyMatch f allFlags {- Note [-Bsymbolic and hooks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |