diff options
| -rw-r--r-- | compiler/utils/Pretty.hs | 5 | ||||
| -rw-r--r-- | testsuite/tests/typecheck/should_fail/tcfail177.hs | 65 | ||||
| -rw-r--r-- | testsuite/tests/typecheck/should_fail/tcfail177.stderr | 180 | 
3 files changed, 66 insertions, 184 deletions
| diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs index 607d265e82..99566d36ea 100644 --- a/compiler/utils/Pretty.hs +++ b/compiler/utils/Pretty.hs @@ -822,11 +822,14 @@ fillNB g p k ys             = fill1 g p k ys  fillNBE :: Bool -> Int -> Doc -> [Doc] -> Doc  fillNBE g k y ys -  = nilBeside g (fill1 g ((oneLiner . reduceDoc) y) k' ys) +  = nilBeside g (fill1 g ((elideNest . oneLiner . reduceDoc) y) k' ys)      -- XXX: TODO: PRETTY: Used to use True here (but GHC used False...)      `mkUnion` nilAboveNest False k (fill g (y:ys))    where k' = if g then k - 1 else k +elideNest :: Doc -> Doc +elideNest (Nest _ d) = d +elideNest d          = d  -- ---------------------------------------------------------------------------  -- Selecting the best layout diff --git a/testsuite/tests/typecheck/should_fail/tcfail177.hs b/testsuite/tests/typecheck/should_fail/tcfail177.hs index d9e60e96fc..8d264db53d 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail177.hs +++ b/testsuite/tests/typecheck/should_fail/tcfail177.hs @@ -2,33 +2,58 @@ module ShouldFail where  -- See Trac #1176  -- This is really a pretty-printer test, not a typechecker test --- The more infix ops we have, the worse fsep works +-- +-- Before ghc-7.2 the error messages looked like this (notice the wrong +-- indentation): --- Currently the error message looks ok, however +{- +tcfail177.hs:9:12: +    Couldn't match expected type `Bool' with actual type `Int' +    In the return type of a call of `foo' +    In the expression: +      foo +        ["One........" ~?= "1", "Two" ~?= "2", "Thre........." ~?= "3", +     "Four" ~?= "4", ....] +    In an equation for `allTest1': +        allTest1 +          = foo +              ["One........" ~?= "1", "Two" ~?= "2", "Thre........." ~?= "3", +         ....] -allTests :: Bool -allTests = foo -           [a ~?= b -           ,"Three" ~?= "3" +tcfail177.hs:18:12: +    Couldn't match expected type `Bool' with actual type `Int' +    In the return type of a call of `foo' +    In the expression: +      foo +        ["One........" ~?= "1", "Two.................." ~?= "2", +       "Thre........." ~?= "3", "Four" ~?= "4", ....] +    In an equation for `allTest2': +        allTest2 +          = foo +              ["One........" ~?= "1", "Two.................." ~?= "2", +             "Thre........." ~?= "3", ....] +-} + +allTest1 :: Bool +allTest1 = foo +           ["One........" ~?= "1" +           ,"Two" ~?= "2" +           ,"Thre........." ~?= "3"             ,"Four" ~?= "4"             ,"Five" ~?= "5" -           ,"Five" ~?= "5" -           ,"Five" ~?= "5" -           ,"Five" ~?= "5" -           ,"Five" ~?= "5" -           ,"Five" ~?= "5" -           ,"Two", "Two", "Two"  -           ,"Two", "Two", "Two"  -           ,"Two", "Two", "Two"  -           ,"Two", "Two", "Two"  -           ,"Two", "Two", "Two"  -           ,"Two", "Two", "Two"]  +           ] -a="" -b="" +allTest2 :: Bool +allTest2 = foo +           ["One........" ~?= "1" +           ,"Two.................." ~?= "2" +           ,"Thre........." ~?= "3" +           ,"Four" ~?= "4" +           ,"Five" ~?= "5" +           ]  (~?=) :: a -> a -> Bool -(~?=) = error "urk"  +(~?=) = error "urk"  foo :: a -> Int  foo x = 0 diff --git a/testsuite/tests/typecheck/should_fail/tcfail177.stderr b/testsuite/tests/typecheck/should_fail/tcfail177.stderr index 54d7331172..206f9ced6c 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail177.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail177.stderr @@ -1,170 +1,24 @@ -tcfail177.hs:10:12: +tcfail177.hs:38:12: error:      Couldn't match expected type ‘Bool’ with actual type ‘Int’      In the expression:        foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] -    In an equation for ‘allTests’: -        allTests = foo [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", ....] +        ["One........" ~?= "1", "Two" ~?= "2", "Thre........." ~?= "3", +         "Four" ~?= "4", ....] +    In an equation for ‘allTest1’: +        allTest1 +          = foo +              ["One........" ~?= "1", "Two" ~?= "2", "Thre........." ~?= "3", +               ....] -tcfail177.hs:20:13: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:20:20: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:20:27: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:21:13: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:21:20: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:21:27: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:22:13: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:22:20: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:22:27: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:23:13: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:23:20: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:23:27: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:24:13: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:24:20: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:24:27: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:25:13: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:25:20: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ -    In the expression: -      foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] - -tcfail177.hs:25:27: -    Couldn't match expected type ‘Bool’ with actual type ‘[Char]’ -    In the expression: "Two" -    In the first argument of ‘foo’, namely -      ‘[a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....]’ +tcfail177.hs:47:12: error: +    Couldn't match expected type ‘Bool’ with actual type ‘Int’      In the expression:        foo -        [a ~?= b, "Three" ~?= "3", "Four" ~?= "4", "Five" ~?= "5", ....] +        ["One........" ~?= "1", "Two.................." ~?= "2", +         "Thre........." ~?= "3", "Four" ~?= "4", ....] +    In an equation for ‘allTest2’: +        allTest2 +          = foo +              ["One........" ~?= "1", "Two.................." ~?= "2", +               "Thre........." ~?= "3", ....] | 
