Fix let-in-expr non-idempotent comment placement

ghc92
Lennart Spitzner 2023-08-28 21:31:25 +02:00
parent 15fc8ec332
commit 7d84705e7a
3 changed files with 25 additions and 8 deletions

View File

@ -1113,3 +1113,16 @@ func = do
func arg = abc ++ def ++ case arg of func arg = abc ++ def ++ case arg of
False -> ghi False -> ghi
True -> jkl True -> jkl
#test non-idempotent comment position with let-in-where
otherFunc very long patterrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrn
= let
localfunc a b c = a <> b <> c
someThing = fromList [abc, def, ghi]
in -- abc
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccc
where
ccccccc = "abc"
ddddd = True

View File

@ -553,10 +553,11 @@ layoutExpr lexpr@(L _ expr) = do
] ]
, docAlt , docAlt
[ docSeq [ docSeq
[ appSep $ wrapIn $ docLit $ Text.pack $ ifIndentFreeElse [ appSep $ wrapIn $ docLit $ Text.pack "in"
"in " , ifIndentFreeElse ( docSetBaseAndIndent
"in" . docEnsureIndent (BrIndentSpecial 1)
, ifIndentFreeElse docSetBaseAndIndent . docSetBaseAndIndent
)
docForceSingleline docForceSingleline
expDoc1 expDoc1
] ]
@ -586,6 +587,7 @@ layoutExpr lexpr@(L _ expr) = do
) )
, docSeq , docSeq
[ wrapIn $ docLit $ Text.pack "in" [ wrapIn $ docLit $ Text.pack "in"
, docSeparator
, docAddBaseY BrIndentRegular $ docForceParSpacing expDoc1 , docAddBaseY BrIndentRegular $ docForceParSpacing expDoc1
] ]
] ]
@ -599,7 +601,9 @@ layoutExpr lexpr@(L _ expr) = do
] ]
, docSeq , docSeq
[ appSep $ wrapIn $ docLit $ Text.pack "in" [ appSep $ wrapIn $ docLit $ Text.pack "in"
, docSetBaseY expDoc1 , docSetBaseY
$ docEnsureIndent (BrIndentSpecial 1)
$ docSetBaseY expDoc1
] ]
] ]
addAlternative $ docLines addAlternative $ docLines

View File

@ -143,7 +143,7 @@ layoutWriteComment absolute isBlock dp commentLines s = do
' ' ' '
mTell $ Text.Builder.fromText s mTell $ Text.Builder.fromText s
traceLocal traceLocal
( "layoutMoveToCommentPos" ( "layoutWriteComment"
, y , y
, x , x
, commentLines , commentLines