Fix an issue with detecting spans of patterns with guards
commit25c609ca23f12279617449d1976e67b20399266c
authorUtku Demir <me@utdemir.com>
dateMon 26 Aug 2019, 15:05 (7 years ago)
parentde279d8
data/examples/declaration/value/function/case-multi-line-guards-out.hs+5
@@ -7,3 +7,8 @@ withGuards x =
77 + bar
88 x | x > 5 -> 10
99 _ -> 20
10+
11+case x of
12+ '-' | not isUrl ->
13+ case xs of
14+ _ -> emitc '-'
data/examples/declaration/value/function/case-multi-line-guards.hs+3
@@ -7,3 +7,6 @@ withGuards x =
77 x | x > 5 -> 10
88 _ -> 20
99
10+case x of
11+ '-' | not isUrl -> case xs of
12+ _ -> emitc '-'
src/Ormolu/Printer/Meat/Declaration/Value.hs+2−1
@@ -902,7 +902,8 @@ liftAppend (x : xs) [] = x : xs
902902liftAppend (x : xs) (y : ys) = x <> y : liftAppend xs ys
903903
904904getGRHSSpan :: GRHS GhcPs (Located body) -> SrcSpan
905−getGRHSSpan (GRHS NoExt _ body) = getLoc body
905+getGRHSSpan (GRHS NoExt guards body) =
906+ combineSrcSpans' $ getLoc body :| map getLoc guards
906907getGRHSSpan (XGRHS NoExt) = notImplemented "XGRHS"
907908
908909-- | Place a thing that may have a hanging form. This function handles how