on master help sign in
Fix an issue with detecting spans of patterns with guards
25c609cUtku Demir
data/examples/declaration/value/function/case-multi-line-guards-out.hs+5
@@ -7,3 +7,8 @@ withGuards x =
7 + bar
7 + bar
8 x | x > 5 -> 10
8 x | x > 5 -> 10
9 _ -> 20
9 _ -> 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 =
7 x | x > 5 -> 10
7 x | x > 5 -> 10
8 _ -> 20
8 _ -> 20
9
9
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
902liftAppend (x : xs) (y : ys) = x <> y : liftAppend xs ys
902liftAppend (x : xs) (y : ys) = x <> y : liftAppend xs ys
903
903
904getGRHSSpan :: GRHS GhcPs (Located body) -> SrcSpan
904getGRHSSpan :: 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
906getGRHSSpan (XGRHS NoExt) = notImplemented "XGRHS"
907getGRHSSpan (XGRHS NoExt) = notImplemented "XGRHS"
907
908
908-- | Place a thing that may have a hanging form. This function handles how
909-- | Place a thing that may have a hanging form. This function handles how