fix runtime crash on incomplete pattern match in lambda
This was very susprising to me that it was not caught by -Wall, so I enabled -Wincomplete-uni-patterns to catch such things. It found a second one just lines above, but no others anywhere.
This commit is contained in:
parent
c22c07bbed
commit
bcc0ec5b99
2 changed files with 11 additions and 6 deletions
|
@ -84,12 +84,17 @@ parseRemoteLocation s repo = ret $ calcloc s
|
||||||
where
|
where
|
||||||
replacement = decodeBS' $ S.drop (S.length prefix) $
|
replacement = decodeBS' $ S.drop (S.length prefix) $
|
||||||
S.take (S.length bestkey - S.length suffix) bestkey
|
S.take (S.length bestkey - S.length suffix) bestkey
|
||||||
(ConfigKey bestkey, ConfigValue bestvalue) = maximumBy longestvalue insteadofs
|
(bestkey, bestvalue) =
|
||||||
|
case maximumBy longestvalue insteadofs of
|
||||||
|
(ConfigKey k, ConfigValue v) -> (k, v)
|
||||||
|
(ConfigKey k, NoConfigValue) -> (k, mempty)
|
||||||
longestvalue (_, a) (_, b) = compare b a
|
longestvalue (_, a) (_, b) = compare b a
|
||||||
insteadofs = filterconfig $ \(ConfigKey k, ConfigValue v) ->
|
insteadofs = filterconfig $ \case
|
||||||
prefix `S.isPrefixOf` k &&
|
(ConfigKey k, ConfigValue v) ->
|
||||||
suffix `S.isSuffixOf` k &&
|
prefix `S.isPrefixOf` k &&
|
||||||
v `S.isPrefixOf` encodeBS l
|
suffix `S.isSuffixOf` k &&
|
||||||
|
v `S.isPrefixOf` encodeBS l
|
||||||
|
(_, NoConfigValue) -> False
|
||||||
filterconfig f = filter f $
|
filterconfig f = filter f $
|
||||||
concatMap splitconfigs $ M.toList $ fullconfig repo
|
concatMap splitconfigs $ M.toList $ fullconfig repo
|
||||||
splitconfigs (k, vs) = map (\v -> (k, v)) vs
|
splitconfigs (k, vs) = map (\v -> (k, v)) vs
|
||||||
|
|
|
@ -371,7 +371,7 @@ Executable git-annex
|
||||||
tasty-quickcheck,
|
tasty-quickcheck,
|
||||||
tasty-rerun
|
tasty-rerun
|
||||||
CC-Options: -Wall
|
CC-Options: -Wall
|
||||||
GHC-Options: -Wall -fno-warn-tabs
|
GHC-Options: -Wall -fno-warn-tabs -Wincomplete-uni-patterns
|
||||||
Extensions: PackageImports, LambdaCase
|
Extensions: PackageImports, LambdaCase
|
||||||
-- Some things don't work with the non-threaded RTS.
|
-- Some things don't work with the non-threaded RTS.
|
||||||
GHC-Options: -threaded
|
GHC-Options: -threaded
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue