summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-08-24 17:20:01 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2021-08-24 17:23:58 +0100
commit71e8094d3855d7c3a105ba5655f7995f94b84832 (patch)
tree7528cc4edadce0f757e5ca4a43beb7f93a0160f5
parentfdb2bfab19f538c43b8138751da73a9b024a62a8 (diff)
downloadhaskell-71e8094d3855d7c3a105ba5655f7995f94b84832.tar.gz
Fix colourised output in error messageswip/t20276
This fixes a small mistake in 4dc681c7c0345ee8ae268749d98b419dabf6a3bc which forced the dump rather than user style for error messages. In particular, this change replaced `defaultUserStyle` with `log_default_dump_context` rather than `log_default_user_context` which meant the PprStyle was PprDump rather than PprUser for error messages. https://gitlab.haskell.org/ghc/ghc/-/commit/4dc681c7c0345ee8ae268749d98b419dabf6a3bc?expanded=1&page=4#b62120081f64009b94c12d04ded5c68870d8c647_285_405 Fixes #20276
-rw-r--r--compiler/GHC/Utils/Logger.hs2
-rw-r--r--testsuite/tests/warnings/should_fail/Colour.hs1
-rw-r--r--testsuite/tests/warnings/should_fail/Colour.stderr5
-rw-r--r--testsuite/tests/warnings/should_fail/all.T1
4 files changed, 8 insertions, 1 deletions
diff --git a/compiler/GHC/Utils/Logger.hs b/compiler/GHC/Utils/Logger.hs
index bf480b8394..48601dd655 100644
--- a/compiler/GHC/Utils/Logger.hs
+++ b/compiler/GHC/Utils/Logger.hs
@@ -402,7 +402,7 @@ defaultLogActionHPutStrDoc :: LogFlags -> Bool -> Handle -> SDoc -> IO ()
defaultLogActionHPutStrDoc logflags asciiSpace h d
-- Don't add a newline at the end, so that successive
-- calls to this log-action can output all on the same line
- = printSDoc (log_default_dump_context logflags) (Pretty.PageMode asciiSpace) h d
+ = printSDoc (log_default_user_context logflags) (Pretty.PageMode asciiSpace) h d
--
-- Note [JSON Error Messages]
diff --git a/testsuite/tests/warnings/should_fail/Colour.hs b/testsuite/tests/warnings/should_fail/Colour.hs
new file mode 100644
index 0000000000..983f291160
--- /dev/null
+++ b/testsuite/tests/warnings/should_fail/Colour.hs
@@ -0,0 +1 @@
+main = () :: IO ()
diff --git a/testsuite/tests/warnings/should_fail/Colour.stderr b/testsuite/tests/warnings/should_fail/Colour.stderr
new file mode 100644
index 0000000000..8631313a7b
--- /dev/null
+++ b/testsuite/tests/warnings/should_fail/Colour.stderr
@@ -0,0 +1,5 @@
+
+Colour.hs:1:8: error:
+ • Couldn't match expected type ‘IO ()’ with actual type ‘()’
+ • In the expression: () :: IO ()
+ In an equation for ‘main’: main = () :: IO ()
diff --git a/testsuite/tests/warnings/should_fail/all.T b/testsuite/tests/warnings/should_fail/all.T
index 7d0dc4295f..075c790222 100644
--- a/testsuite/tests/warnings/should_fail/all.T
+++ b/testsuite/tests/warnings/should_fail/all.T
@@ -15,3 +15,4 @@ test('CaretDiagnostics1',
compile_fail,
['-fdiagnostics-show-caret -ferror-spans'])
test('CaretDiagnostics2', normal, compile_fail, ['-fdiagnostics-show-caret'])
+test('Colour', normal, compile_fail, ['-fdiagnostics-color=always'])