diff options
author | Zejun Wu <watashi@fb.com> | 2018-12-28 00:10:22 -0800 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-01-31 12:46:51 -0500 |
commit | 0593e9389c4e5fd4386ebd74a746ef9659401ac6 (patch) | |
tree | 04d4b9fe43d13034daacf59f511e8c239b235cbc /testsuite/tests/ghci/prog018 | |
parent | 98ff3010a642366ab8e0c563fc20debc8858dc83 (diff) | |
download | haskell-0593e9389c4e5fd4386ebd74a746ef9659401ac6.tar.gz |
Add -fdefer-diagnostics to defer and group diagnostic messages in make-mode
When loading many modules in parallel there can a lot of warnings and
errors get mixed up with regular output. When the compilation fails,
the relevant error message can be thousands of lines backward and is
hard to find. When the compilation successes, warning message is likely
to be ignored as it is not seen. We can address this by deferring the
warning and error message after the compilation. We also put errors
after warnings so it is more visible.
This idea was originally proposed by Bartosz Nitka in
https://phabricator.haskell.org/D4219.
Diffstat (limited to 'testsuite/tests/ghci/prog018')
-rw-r--r-- | testsuite/tests/ghci/prog018/A.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog018/B.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog018/C.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog018/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog018/prog018.T | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog018/prog018.script | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog018/prog018.stdout | 23 |
7 files changed, 54 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/prog018/A.hs b/testsuite/tests/ghci/prog018/A.hs new file mode 100644 index 0000000000..aebfa35614 --- /dev/null +++ b/testsuite/tests/ghci/prog018/A.hs @@ -0,0 +1,8 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -Wunused-matches #-} +module A where + +incompletePattern :: Int -> Int +incompletePattern 0 = 0 + +unusedMatches :: Int -> Int +unusedMatches x = 0 diff --git a/testsuite/tests/ghci/prog018/B.hs b/testsuite/tests/ghci/prog018/B.hs new file mode 100644 index 0000000000..ebfdd6d733 --- /dev/null +++ b/testsuite/tests/ghci/prog018/B.hs @@ -0,0 +1,7 @@ +{-# OPTIONS_GHC -Wunused-imports #-} +module B + ( module A + ) where + +import A +import Data.List diff --git a/testsuite/tests/ghci/prog018/C.hs b/testsuite/tests/ghci/prog018/C.hs new file mode 100644 index 0000000000..c722f9554c --- /dev/null +++ b/testsuite/tests/ghci/prog018/C.hs @@ -0,0 +1,6 @@ +module C where + +import B + +foo :: () +foo = variableNotInScope diff --git a/testsuite/tests/ghci/prog018/Makefile b/testsuite/tests/ghci/prog018/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/ghci/prog018/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/ghci/prog018/prog018.T b/testsuite/tests/ghci/prog018/prog018.T new file mode 100644 index 0000000000..0d9e7813a6 --- /dev/null +++ b/testsuite/tests/ghci/prog018/prog018.T @@ -0,0 +1,3 @@ +# testcase for warning and error messages from :load +test('prog018', [combined_output, extra_files(['A.hs', 'B.hs', 'C.hs'])], + ghci_script, ['prog018.script']) diff --git a/testsuite/tests/ghci/prog018/prog018.script b/testsuite/tests/ghci/prog018/prog018.script new file mode 100644 index 0000000000..108a84de04 --- /dev/null +++ b/testsuite/tests/ghci/prog018/prog018.script @@ -0,0 +1,4 @@ +:set -fdefer-diagnostics +:set -v1 +:load C.hs +:reload diff --git a/testsuite/tests/ghci/prog018/prog018.stdout b/testsuite/tests/ghci/prog018/prog018.stdout new file mode 100644 index 0000000000..daa722e436 --- /dev/null +++ b/testsuite/tests/ghci/prog018/prog018.stdout @@ -0,0 +1,23 @@ +[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: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In an equation for ‘incompletePattern’: + Patterns not matched: p where p is not one of {0} + +A.hs:8:15: warning: [-Wunused-matches (in -Wextra)] + Defined but not used: ‘x’ + +B.hs:7:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Data.List’ is redundant + except perhaps to import instances from ‘Data.List’ + To import instances alone, use: import Data.List() + +C.hs:6:7: error: Variable not in scope: variableNotInScope :: () +Failed, two modules loaded. +[3 of 3] Compiling C ( C.hs, interpreted ) + +C.hs:6:7: error: Variable not in scope: variableNotInScope :: () +Failed, two modules loaded. |