[commit: ghc] master: Pretty: bugfix fillNB (#10735) (67576dd)

git at git.haskell.org git at git.haskell.org
Wed Aug 12 09:23:12 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/67576ddc67f39bef43c473f30af0887d22011710/ghc

>---------------------------------------------------------------

commit 67576ddc67f39bef43c473f30af0887d22011710
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Tue Aug 4 22:32:06 2015 +0200

    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


>---------------------------------------------------------------

67576ddc67f39bef43c473f30af0887d22011710
 compiler/utils/Pretty.hs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs
index 0bde5fa..607d265 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
 



More information about the ghc-commits mailing list