[Git][ghc/ghc][master] Put the newline after errors instead of before them

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Apr 20 15:11:48 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
275e41a9 by Jade at 2024-04-20T11:10:40-04:00
Put the newline after errors instead of before them

This mainly has consequences for GHCi but also slightly alters how the
output of GHC on the commandline looks.

Fixes: #22499

- - - - -


13 changed files:

- compiler/GHC/Utils/Logger.hs
- testsuite/tests/ghci/prog018/prog018.stdout
- testsuite/tests/ghci/scripts/T9140.stdout
- testsuite/tests/layout/layout001.stdout
- testsuite/tests/layout/layout003.stdout
- testsuite/tests/layout/layout004.stdout
- testsuite/tests/layout/layout006.stdout
- testsuite/tests/overloadedrecflds/ghci/GHCiDRF.stdout
- testsuite/tests/overloadedrecflds/ghci/T19314.stdout
- testsuite/tests/overloadedrecflds/ghci/duplicaterecfldsghci01.stdout
- testsuite/tests/rename/should_compile/T13839.stdout
- testsuite/tests/th/T7276a.stdout
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr


Changes:

=====================================
compiler/GHC/Utils/Logger.hs
=====================================
@@ -417,14 +417,13 @@ defaultLogAction logflags msg_class srcSpan msg
       message = mkLocMessageWarningGroups (log_show_warn_groups logflags) msg_class srcSpan msg
 
       printDiagnostics = do
-        hPutChar stderr '\n'
         caretDiagnostic <-
             if log_show_caret logflags
             then getCaretDiagnostic msg_class srcSpan
             else pure empty
         printErrs $ getPprStyle $ \style ->
           withPprStyle (setStyleColoured True style)
-            (message $+$ caretDiagnostic)
+            (message $+$ caretDiagnostic $+$ blankLine)
         -- careful (#2302): printErrs prints in UTF-8,
         -- whereas converting to string first and using
         -- hPutStr would just emit the low 8 bits of


=====================================
testsuite/tests/ghci/prog018/prog018.stdout
=====================================
@@ -1,7 +1,6 @@
 [1 of 3] Compiling A                ( A.hs, interpreted )
 [2 of 3] Compiling B                ( B.hs, interpreted )
 [3 of 3] Compiling C                ( C.hs, interpreted )
-
 A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)]
     Pattern match(es) are non-exhaustive
     In an equation for ‘incompletePattern’:
@@ -17,9 +16,10 @@ B.hs:7:1: warning: [GHC-66111] [-Wunused-imports (in -Wextra)]
 
 C.hs:6:7: error: [GHC-88464]
     Variable not in scope: variableNotInScope :: ()
+
 Failed, two modules loaded.
 [3 of 3] Compiling C                ( C.hs, interpreted )
-
 C.hs:6:7: error: [GHC-88464]
     Variable not in scope: variableNotInScope :: ()
+
 Failed, two modules reloaded.


=====================================
testsuite/tests/ghci/scripts/T9140.stdout
=====================================
@@ -1,4 +1,3 @@
-
 <interactive>:2:5: error: [GHC-20036]
     You can't mix polymorphic and unlifted bindings: a = (# 1 #)
     Suggested fix: Add a type signature.
@@ -10,3 +9,4 @@
 <interactive>:1:1: error: [GHC-17999]
     GHCi can't bind a variable of unlifted type:
       a :: (# Integer, Integer #)
+


=====================================
testsuite/tests/layout/layout001.stdout
=====================================
@@ -1,9 +1,9 @@
 Running with -XNoAlternativeLayoutRule
 Running with -XAlternativeLayoutRule
-
 layout001.hs:6:3: error: [GHC-58481] parse error on input ‘where’
-Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 
+Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 layout001.hs:6:3: warning: [GHC-93617] [-Walternative-layout-rule-transitional (in -Wdefault)]
     transitional layout will not be accepted in the future:
     `where' clause at the same depth as implicit layout block
+


=====================================
testsuite/tests/layout/layout003.stdout
=====================================
@@ -1,9 +1,9 @@
 Running with -XNoAlternativeLayoutRule
 Running with -XAlternativeLayoutRule
-
 layout003.hs:11:4: error: [GHC-58481] parse error on input ‘|’
-Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 
+Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 layout003.hs:11:4: warning: [GHC-93617] [-Walternative-layout-rule-transitional (in -Wdefault)]
     transitional layout will not be accepted in the future:
     `|' at the same depth as implicit layout block
+


=====================================
testsuite/tests/layout/layout004.stdout
=====================================
@@ -1,7 +1,7 @@
 Running with -XNoAlternativeLayoutRule
 Running with -XAlternativeLayoutRule
-
 layout004.hs:7:14: error: [GHC-58481] parse error on input ‘,’
-Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 
+Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 layout004.hs:7:14: error: [GHC-58481] parse error on input ‘,’
+


=====================================
testsuite/tests/layout/layout006.stdout
=====================================
@@ -1,13 +1,12 @@
 Running with -XNoAlternativeLayoutRule
-
 layout006.hs:12:4: warning: [GHC-53633] [-Woverlapping-patterns (in -Wdefault)]
     Pattern match is redundant
     In an equation for ‘f’: f | True = ...
-Running with -XAlternativeLayoutRule
 
+Running with -XAlternativeLayoutRule
 layout006.hs:12:2: error: [GHC-58481] parse error on input ‘|’
-Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 
+Running with -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional
 layout006.hs:12:2: warning: [GHC-93617] [-Walternative-layout-rule-transitional (in -Wdefault)]
     transitional layout will not be accepted in the future:
     `|' at the same depth as implicit layout block
@@ -15,3 +14,4 @@ layout006.hs:12:2: warning: [GHC-93617] [-Walternative-layout-rule-transitional
 layout006.hs:12:4: warning: [GHC-53633] [-Woverlapping-patterns (in -Wdefault)]
     Pattern match is redundant
     In an equation for ‘f’: f | True = ...
+


=====================================
testsuite/tests/overloadedrecflds/ghci/GHCiDRF.stdout
=====================================
@@ -1,10 +1,10 @@
 GHCiDRF.foo :: T -> Int
-
 <interactive>:1:1: error: [GHC-87543]
     Ambiguous occurrence ‘GHCiDRF.bar’.
     It could refer to
        either the field ‘bar’ of record ‘T’, defined at GHCiDRF.hs:3:28,
            or the field ‘bar’ of record ‘U’, defined at GHCiDRF.hs:4:16.
+
 type T :: *
 data T = MkT {foo :: Int, ...}
   	-- Defined at GHCiDRF.hs:3:16
@@ -16,7 +16,6 @@ type U :: *
 data U = MkU {bar :: Bool}
   	-- Defined at GHCiDRF.hs:4:16
 GHCiDRF.foo :: GHCiDRF.T -> Int
-
 <interactive>:1:1: error: [GHC-87543]
     Ambiguous occurrence ‘GHCiDRF.bar’.
     It could refer to
@@ -26,6 +25,7 @@ GHCiDRF.foo :: GHCiDRF.T -> Int
            or the field ‘bar’ belonging to data constructor ‘MkU’,
               imported qualified from ‘GHCiDRF’
               (and originally defined at GHCiDRF.hs:4:16-18).
+
 type GHCiDRF.T :: *
 data GHCiDRF.T = GHCiDRF.MkT {GHCiDRF.foo :: Int, ...}
   	-- Defined at GHCiDRF.hs:3:16
@@ -36,7 +36,6 @@ data GHCiDRF.T = GHCiDRF.MkT {..., GHCiDRF.bar :: Int}
 type GHCiDRF.U :: *
 data GHCiDRF.U = GHCiDRF.MkU {GHCiDRF.bar :: Bool}
   	-- Defined at GHCiDRF.hs:4:16
-
 <interactive>:11:1: error: [GHC-87543]
     Ambiguous occurrence ‘GHCiDRF.bar’.
     It could refer to
@@ -46,3 +45,4 @@ data GHCiDRF.U = GHCiDRF.MkU {GHCiDRF.bar :: Bool}
            or the field ‘bar’ belonging to data constructor ‘MkU’,
               imported qualified from ‘GHCiDRF’
               (and originally defined at GHCiDRF.hs:4:16-18).
+


=====================================
testsuite/tests/overloadedrecflds/ghci/T19314.stdout
=====================================
@@ -1,6 +1,5 @@
 w :: [a] -> a
 x :: [a] -> a
-
 <interactive>:1:1: error: [GHC-88464]
     Variable not in scope: y
     Suggested fix:
@@ -12,3 +11,4 @@ x :: [a] -> a
     Suggested fix:
       Notice that ‘z’ is a field selector
       that has been suppressed by NoFieldSelectors.
+


=====================================
testsuite/tests/overloadedrecflds/ghci/duplicaterecfldsghci01.stdout
=====================================
@@ -7,7 +7,6 @@ type T :: * -> *
 data T a = MkT {foo :: Bool, ...}
   	-- Defined at <interactive>:4:18
 True
-
 <interactive>:1:1: error: [GHC-87543]
     Ambiguous occurrence ‘foo’.
     It could refer to
@@ -15,6 +14,7 @@ True
               defined at <interactive>:3:16,
            or the field ‘foo’ of record ‘T’,
               defined at <interactive>:4:18.
+
 type U :: *
 data U = MkU {foo :: Int}
   	-- Defined at <interactive>:12:16


=====================================
testsuite/tests/rename/should_compile/T13839.stdout
=====================================
@@ -1,5 +1,5 @@
-
 T13839a.hs:10:1: warning: [GHC-40910] [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
     Defined but not used: ‘nonUsed’
+
 nonUsed :: ()
 nonUsed :: ()


=====================================
testsuite/tests/th/T7276a.stdout
=====================================
@@ -1,4 +1,3 @@
-
 <interactive>:3:9: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
     • Couldn't match type ‘[Dec]’ with ‘Exp’
       Expected: Q Exp
@@ -17,3 +16,4 @@
 (deferred type error)
       Code: x
     • In the untyped splice: $x
+


=====================================
testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
=====================================
@@ -1,4 +1,3 @@
-
 CaretDiagnostics1.hs:7:8-15: error: [GHC-83865]
     • Couldn't match expected type ‘IO a0’ with actual type ‘Int’
     • In the second argument of ‘(+)’, namely ‘(3 :: Int)’
@@ -68,3 +67,4 @@ CaretDiagnostics1.hs:23:25-26: error: [GHC-83865]
    |
 23 | tabby2 =                ()
    |                         ^^
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/275e41a902f4aec8552707ec9924f2d0a20346d0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/275e41a902f4aec8552707ec9924f2d0a20346d0
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240420/7de16b75/attachment-0001.html>


More information about the ghc-commits mailing list