diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-04 22:32:06 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2015-08-12 11:19:14 +0200 |
commit | 67576ddc67f39bef43c473f30af0887d22011710 (patch) | |
tree | 1abbca23157983de9d7cbcabb699bd830b315243 | |
parent | 8cce7e4bc8f17f1c9ef4d4028b5145829fc3334b (diff) | |
download | haskell-67576ddc67f39bef43c473f30af0887d22011710.tar.gz |
Pretty: bugfix fillNB (#10735)
This is a backport of a bug fix by Benedikt Huber (#2393), from commit
1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.
From https://mail.haskell.org/pipermail/libraries/2008-June/009991.html:
Law <l1> states that
> sep (ps++[empty]++qs) = sep (ps ++ qs)
> ...ditto hsep, hcat, vcat, fill...
In the current implementation, this fails for the paragraph fill
variants.
> render' $ fsep [ text "c", text "c",empty, text "c", text "b"]
> where render' = renderStyle (Style PageMode 7 1.4)
>> c c c
>> b
-rw-r--r-- | compiler/utils/Pretty.hs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs index 0bde5fa1c0..607d265e82 100644 --- a/compiler/utils/Pretty.hs +++ b/compiler/utils/Pretty.hs @@ -815,6 +815,7 @@ fillNB _ _ k _ | k `seq` False = undefined fillNB g (Nest _ p) k ys = fillNB g p k ys -- Never triggered, because of invariant (2) fillNB _ Empty _ [] = Empty +fillNB g Empty k (Empty:ys) = fillNB g Empty k ys fillNB g Empty k (y:ys) = fillNBE g k y ys fillNB g p k ys = fill1 g p k ys |