Commit f78b31a3 authored by pcapriotti's avatar pcapriotti
Browse files

Fix ambiguous flag resolution (#7138)

Pick longest flag when more than one matches in findArg.

This fixes an issue where -ignore-dot-ghci wasn't honored, because the
flag was parsed as "-i gnore-dot-ghci".
parent 7473c3d2
......@@ -27,6 +27,7 @@ import Panic
import Bag
import SrcLoc
import Data.Function
import Data.List
......@@ -194,7 +195,8 @@ processOneArg opt_kind rest arg args
findArg :: [Flag m] -> String -> Maybe (String, OptKind m)
findArg spec arg =
case [ (removeSpaces rest, optKind)
case sortBy (compare `on` (length . fst)) -- prefer longest matching flag
[ (removeSpaces rest, optKind)
| flag <- spec,
let optKind = flagOptKind flag,
Just rest <- [stripPrefix (flagName flag) arg],
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