diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2017-07-11 15:41:20 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-07-11 16:32:43 -0400 |
commit | 4befb415d7ee63d2b0ecdc2384310dc4b3ccc90a (patch) | |
tree | f0baf272b60c130ca4fe4eaf9e7c39c3fa123abb /testsuite | |
parent | 3a163aabe7948d382393e9e81f1239f3e06b222b (diff) | |
download | haskell-4befb415d7ee63d2b0ecdc2384310dc4b3ccc90a.tar.gz |
Mention which -Werror promoted a warning to an error
Previously -Werror or -Werror=flag printed warnings as usual and then
printed
these two lines:
<no location info>: error:
Failing due to -Werror.
This is not ideal: first, it's not clear which flag made one of the
warnings an
error. Second, warning messages are not modified in any way, so there's
no way
to know which warnings caused this error.
With this patch we (1) promote warning messages to error messages if a
relevant
-Werror is enabled (2) mention which -Werror is used during this
promotion.
Previously:
[1 of 1] Compiling Main ( test.hs, test.o )
test.hs:9:10: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: (C2 _)
|
9 | sInt s = case s of
| ^^^^^^^^^...
test.hs:12:14: warning: [-Wmissing-fields]
• Fields of ‘Rec’ not initialised: f2
• In the first argument of ‘print’, namely ‘Rec {f1 =
1}’
In the expression: print Rec {f1 = 1}
In an equation for ‘main’: main = print Rec {f1 = 1}
|
12 | main = print Rec{ f1 = 1 }
| ^^^^^^^^^^^^^
<no location info>: error:
Failing due to -Werror.
Now:
[1 of 1] Compiling Main ( test.hs, test.o )
test.hs:9:10: error: [-Wincomplete-patterns,
-Werror=incomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: (C2 _)
|
9 | sInt s = case s of
| ^^^^^^^^^...
test.hs:12:14: error: [-Wmissing-fields, -Werror=missing-fields]
• Fields of ‘Rec’ not initialised: f2
• In the first argument of ‘print’, namely ‘Rec {f1 =
1}’
In the expression: print Rec {f1 = 1}
In an equation for ‘main’: main = print Rec {f1 = 1}
|
12 | main = print Rec{ f1 = 1 }
| ^^^^^^^^^^^^^
Test Plan: - Update old tests, add new tests if there aren't any
relevant tests
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3709
Diffstat (limited to 'testsuite')
20 files changed, 68 insertions, 81 deletions
diff --git a/testsuite/tests/driver/T11429c.stderr b/testsuite/tests/driver/T11429c.stderr index 19e269b2d0..6fee70dc04 100644 --- a/testsuite/tests/driver/T11429c.stderr +++ b/testsuite/tests/driver/T11429c.stderr @@ -1,5 +1,3 @@ -<no location info>: error: -Failing due to -Werror. - -on the commandline: warning: unrecognised warning flag: -Wfoobar +on the commandline: error: [-Werror] + unrecognised warning flag: -Wfoobar diff --git a/testsuite/tests/driver/werror.stderr b/testsuite/tests/driver/werror.stderr index ccbeb393cd..2d9fd5324c 100644 --- a/testsuite/tests/driver/werror.stderr +++ b/testsuite/tests/driver/werror.stderr @@ -1,31 +1,28 @@ -werror.hs:6:1: warning: [-Wmissing-signatures (in -Wall)] +werror.hs:6:1: error: [-Wmissing-signatures (in -Wall), -Werror=missing-signatures] Top-level binding with no type signature: main :: IO () -werror.hs:7:13: warning: [-Wname-shadowing (in -Wall)] +werror.hs:7:13: error: [-Wname-shadowing (in -Wall), -Werror=name-shadowing] This binding for ‘main’ shadows the existing binding defined at werror.hs:6:1 -werror.hs:7:13: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)] +werror.hs:7:13: error: [-Wunused-local-binds (in -Wextra, -Wunused-binds), -Werror=unused-local-binds] Defined but not used: ‘main’ -werror.hs:8:1: warning: [-Wtabs (in -Wdefault)] +werror.hs:8:1: error: [-Wtabs (in -Wdefault), -Werror=tabs] Tab character found here. Please use spaces instead. -werror.hs:10:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] +werror.hs:10:1: error: [-Wunused-top-binds (in -Wextra, -Wunused-binds), -Werror=unused-top-binds] Defined but not used: ‘f’ -werror.hs:10:1: warning: [-Wmissing-signatures (in -Wall)] +werror.hs:10:1: error: [-Wmissing-signatures (in -Wall), -Werror=missing-signatures] Top-level binding with no type signature: f :: [a1] -> [a2] -werror.hs:10:1: warning: [-Wincomplete-patterns (in -Wextra)] +werror.hs:10:1: error: [-Wincomplete-patterns (in -Wextra), -Werror=incomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘f’: Patterns not matched: (_:_) -werror.hs:11:1: warning: [-Woverlapping-patterns (in -Wdefault)] +werror.hs:11:1: error: [-Woverlapping-patterns (in -Wdefault), -Werror=overlapping-patterns] Pattern match is redundant In an equation for ‘f’: f [] = ... - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr index e3fbbcfd9e..9dc7af2782 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr @@ -1,6 +1,3 @@ -overloadedrecfldsfail05.hs:7:16: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] +overloadedrecfldsfail05.hs:7:16: error: [-Wunused-top-binds (in -Wextra, -Wunused-binds), -Werror=unused-top-binds] Defined but not used: ‘foo’ - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr index dc8a9d6bbc..3aae5c5061 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr @@ -10,22 +10,19 @@ OverloadedRecFldsFail06_A.hs:9:59: warning: [-Wunused-top-binds (in -Wextra, -Wu Defined but not used: ‘used_locally’ [2 of 2] Compiling Main ( overloadedrecfldsfail06.hs, overloadedrecfldsfail06.o ) -overloadedrecfldsfail06.hs:7:1: warning: [-Wunused-imports (in -Wextra)] +overloadedrecfldsfail06.hs:7:1: error: [-Wunused-imports (in -Wextra), -Werror=unused-imports] The import of ‘Unused(unused), V(x), U(y), MkV, Unused’ from module ‘OverloadedRecFldsFail06_A’ is redundant -overloadedrecfldsfail06.hs:8:1: warning: [-Wunused-imports (in -Wextra)] +overloadedrecfldsfail06.hs:8:1: error: [-Wunused-imports (in -Wextra), -Werror=unused-imports] The qualified import of ‘OverloadedRecFldsFail06_A’ is redundant except perhaps to import instances from ‘OverloadedRecFldsFail06_A’ To import instances alone, use: import OverloadedRecFldsFail06_A() -overloadedrecfldsfail06.hs:9:1: warning: [-Wunused-imports (in -Wextra)] +overloadedrecfldsfail06.hs:9:1: error: [-Wunused-imports (in -Wextra), -Werror=unused-imports] The qualified import of ‘V(y)’ from module ‘OverloadedRecFldsFail06_A’ is redundant -overloadedrecfldsfail06.hs:10:1: warning: [-Wunused-imports (in -Wextra)] +overloadedrecfldsfail06.hs:10:1: error: [-Wunused-imports (in -Wextra), -Werror=unused-imports] The qualified import of ‘U(x), U’ from module ‘OverloadedRecFldsFail06_A’ is redundant - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr index dac6d29ef2..0aa41a2962 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail11.stderr @@ -1,9 +1,6 @@ [1 of 2] Compiling OverloadedRecFldsFail11_A ( OverloadedRecFldsFail11_A.hs, OverloadedRecFldsFail11_A.o ) [2 of 2] Compiling Main ( overloadedrecfldsfail11.hs, overloadedrecfldsfail11.o ) -overloadedrecfldsfail11.hs:5:15: warning: [-Wdeprecations (in -Wdefault)] +overloadedrecfldsfail11.hs:5:15: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations] In the use of ‘foo’ (imported from OverloadedRecFldsFail11_A): "Warning on a record field" - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr index 7cd9151c56..e17c9f8573 100644 --- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr +++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail12.stderr @@ -1,17 +1,14 @@ [1 of 2] Compiling OverloadedRecFldsFail12_A ( OverloadedRecFldsFail12_A.hs, OverloadedRecFldsFail12_A.o ) [2 of 2] Compiling Main ( overloadedrecfldsfail12.hs, overloadedrecfldsfail12.o ) -overloadedrecfldsfail12.hs:10:11: warning: [-Wdeprecations (in -Wdefault)] +overloadedrecfldsfail12.hs:10:11: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations] In the use of ‘foo’ (imported from OverloadedRecFldsFail12_A): "Deprecated foo" -overloadedrecfldsfail12.hs:10:20: warning: [-Wdeprecations (in -Wdefault)] +overloadedrecfldsfail12.hs:10:20: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations] In the use of ‘bar’ (imported from OverloadedRecFldsFail12_A): "Deprecated bar" -overloadedrecfldsfail12.hs:13:5: warning: [-Wdeprecations (in -Wdefault)] +overloadedrecfldsfail12.hs:13:5: error: [-Wdeprecations (in -Wdefault), -Werror=deprecations] In the use of ‘foo’ (imported from OverloadedRecFldsFail12_A): "Deprecated foo" - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/patsyn/should_fail/UnliftedPSBind.stderr b/testsuite/tests/patsyn/should_fail/UnliftedPSBind.stderr index 6b6b97710e..7bb123095f 100644 --- a/testsuite/tests/patsyn/should_fail/UnliftedPSBind.stderr +++ b/testsuite/tests/patsyn/should_fail/UnliftedPSBind.stderr @@ -1,8 +1,5 @@ -UnliftedPSBind.hs:12:9: warning: [-Wunbanged-strict-patterns (in -Wextra)] +UnliftedPSBind.hs:12:9: error: [-Wunbanged-strict-patterns (in -Wextra), -Werror=unbanged-strict-patterns] Pattern bindings containing unlifted types should use an outermost bang pattern: P x = P 4# - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr b/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr index 8f20f91be9..e0f4606909 100644 --- a/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr +++ b/testsuite/tests/patsyn/should_fail/unboxed-bind.stderr @@ -1,8 +1,5 @@ -unboxed-bind.hs:11:11: warning: [-Wunbanged-strict-patterns (in -Wextra)] +unboxed-bind.hs:11:11: error: [-Wunbanged-strict-patterns (in -Wextra), -Werror=unbanged-strict-patterns] Pattern bindings containing unlifted types should use an outermost bang pattern: P arg = x - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/rename/should_fail/T5892a.stderr b/testsuite/tests/rename/should_fail/T5892a.stderr index b3f1145481..0779538b1e 100644 --- a/testsuite/tests/rename/should_fail/T5892a.stderr +++ b/testsuite/tests/rename/should_fail/T5892a.stderr @@ -1,10 +1,7 @@ -T5892a.hs:12:8: warning: [-Wmissing-fields (in -Wdefault)] +T5892a.hs:12:8: error: [-Wmissing-fields (in -Wdefault), -Werror=missing-fields] • Fields of ‘Node’ not initialised: subForest • In the expression: Node {..} In the expression: let rootLabel = [] in Node {..} In an equation for ‘foo’: foo (Node {..}) = let rootLabel = ... in Node {..} - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags18.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags18.stderr index 7ef83389a8..2766f41512 100644 --- a/testsuite/tests/safeHaskell/flags/SafeFlags18.stderr +++ b/testsuite/tests/safeHaskell/flags/SafeFlags18.stderr @@ -1,6 +1,3 @@ -SafeFlags18.hs:1:16: - Warning: -fpackage-trust ignored; must be specified with a Safe Haskell flag - -<no location info>: -Failing due to -Werror. +SafeFlags18.hs:1:16: error: [-Werror] + -fpackage-trust ignored; must be specified with a Safe Haskell flag diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags23.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags23.stderr index f4e46c2aa8..ea03484823 100644 --- a/testsuite/tests/safeHaskell/flags/SafeFlags23.stderr +++ b/testsuite/tests/safeHaskell/flags/SafeFlags23.stderr @@ -1,10 +1,7 @@ -SafeFlags23.hs:1:16: warning: [-Wunsafe] +SafeFlags23.hs:1:16: error: [-Wunsafe, -Werror=unsafe] ‘SafeFlags22’ has been inferred as unsafe! Reason: SafeFlags23.hs:7:1: error: System.IO.Unsafe: Can't be safely imported! The module itself isn't safe. - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/safeHaskell/flags/SafeFlags26.stderr b/testsuite/tests/safeHaskell/flags/SafeFlags26.stderr index bc27ac2a4f..45047aa019 100644 --- a/testsuite/tests/safeHaskell/flags/SafeFlags26.stderr +++ b/testsuite/tests/safeHaskell/flags/SafeFlags26.stderr @@ -1,6 +1,3 @@ -SafeFlags26.hs:1:16: warning: [-Wsafe] +SafeFlags26.hs:1:16: error: [-Wsafe, -Werror=safe] ‘SafeFlags26’ has been inferred as safe! - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/safeHaskell/overlapping/SH_Overlap7.stderr b/testsuite/tests/safeHaskell/overlapping/SH_Overlap7.stderr index 8010407cc7..45701f2529 100644 --- a/testsuite/tests/safeHaskell/overlapping/SH_Overlap7.stderr +++ b/testsuite/tests/safeHaskell/overlapping/SH_Overlap7.stderr @@ -2,7 +2,7 @@ [2 of 3] Compiling SH_Overlap7_A ( SH_Overlap7_A.hs, SH_Overlap7_A.o ) [3 of 3] Compiling SH_Overlap7 ( SH_Overlap7.hs, SH_Overlap7.o ) -SH_Overlap7.hs:1:16: warning: [-Wunsafe] +SH_Overlap7.hs:1:16: error: [-Wunsafe, -Werror=unsafe] ‘SH_Overlap7’ has been inferred as unsafe! Reason: SH_Overlap7.hs:14:8: warning: @@ -17,6 +17,3 @@ SH_Overlap7.hs:1:16: warning: [-Wunsafe] instance C [a] -- Defined at SH_Overlap7.hs:10:10 • In the expression: f ([1, 2, 3, 4] :: [Int]) In an equation for ‘test’: test = f ([1, 2, 3, 4] :: [Int]) - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered12.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered12.stderr index 74cf60dc54..f05bf7fa8c 100644 --- a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered12.stderr +++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered12.stderr @@ -1,9 +1,6 @@ -UnsafeInfered12.hs:2:16: warning: [-Wunsafe] +UnsafeInfered12.hs:2:16: error: [-Wunsafe, -Werror=unsafe] ‘UnsafeInfered12’ has been inferred as unsafe! Reason: UnsafeInfered12.hs:1:14: -XTemplateHaskell is not allowed in Safe Haskell - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/typecheck/should_fail/T3966.stderr b/testsuite/tests/typecheck/should_fail/T3966.stderr index f79574696b..cab45c21e6 100644 --- a/testsuite/tests/typecheck/should_fail/T3966.stderr +++ b/testsuite/tests/typecheck/should_fail/T3966.stderr @@ -1,8 +1,5 @@ -T3966.hs:5:16: warning: +T3966.hs:5:16: error: [-Werror] • Ignoring unusable UNPACK pragma on the first argument of ‘Foo’ • In the definition of data constructor ‘Foo’ In the data type declaration for ‘Foo’ - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/typecheck/should_fail/tcfail204.stderr b/testsuite/tests/typecheck/should_fail/tcfail204.stderr index a3e8eec3d6..8083ffce60 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail204.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail204.stderr @@ -1,5 +1,5 @@ -tcfail204.hs:10:7: warning: [-Wtype-defaults (in -Wall)] +tcfail204.hs:10:7: error: [-Wtype-defaults (in -Wall), -Werror=type-defaults] • Defaulting the following constraints to type ‘Double’ (RealFrac a0) arising from a use of ‘ceiling’ at tcfail204.hs:10:7-17 @@ -7,6 +7,3 @@ tcfail204.hs:10:7: warning: [-Wtype-defaults (in -Wall)] arising from the literal ‘6.3’ at tcfail204.hs:10:15-17 • In the expression: ceiling 6.3 In an equation for ‘foo’: foo = ceiling 6.3 - -<no location info>: error: -Failing due to -Werror. diff --git a/testsuite/tests/warnings/should_fail/WerrorFail.stderr b/testsuite/tests/warnings/should_fail/WerrorFail.stderr index 90c6c2db3a..00272ef2fe 100644 --- a/testsuite/tests/warnings/should_fail/WerrorFail.stderr +++ b/testsuite/tests/warnings/should_fail/WerrorFail.stderr @@ -1,6 +1,4 @@ -WerrorFail.hs:6:1: warning: [-Wincomplete-patterns (in -Wextra)] + +WerrorFail.hs:6:1: error: [-Wincomplete-patterns (in -Wextra), -Werror=incomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘foo’: Patterns not matched: (Just _) - -<no location info>: -Failing due to -Werror. diff --git a/testsuite/tests/warnings/should_fail/WerrorFail2.hs b/testsuite/tests/warnings/should_fail/WerrorFail2.hs new file mode 100644 index 0000000000..c65f713738 --- /dev/null +++ b/testsuite/tests/warnings/should_fail/WerrorFail2.hs @@ -0,0 +1,19 @@ +{-# OPTIONS_GHC -Wall + -Werror=incomplete-patterns + -Werror=missing-fields #-} + +module Werror03 where + +data Rec = Rec + { f1 :: Int + , f2 :: Int + } deriving (Show) + +data S = C1 Int | C2 Int + +-- incomplete pattern +sInt s = case s of + C1 i -> i + +-- missing field +printRec = print Rec{ f1 = 1 } diff --git a/testsuite/tests/warnings/should_fail/WerrorFail2.stderr b/testsuite/tests/warnings/should_fail/WerrorFail2.stderr new file mode 100644 index 0000000000..f6105d1bfb --- /dev/null +++ b/testsuite/tests/warnings/should_fail/WerrorFail2.stderr @@ -0,0 +1,16 @@ + +WerrorFail2.hs:15:1: warning: [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: sInt :: S -> Int + +WerrorFail2.hs:15:10: error: [-Wincomplete-patterns (in -Wextra), -Werror=incomplete-patterns] + Pattern match(es) are non-exhaustive + In a case alternative: Patterns not matched: (C2 _) + +WerrorFail2.hs:19:1: warning: [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: printRec :: IO () + +WerrorFail2.hs:19:18: error: [-Wmissing-fields (in -Wdefault), -Werror=missing-fields] + • Fields of ‘Rec’ not initialised: f2 + • In the first argument of ‘print’, namely ‘Rec {f1 = 1}’ + In the expression: print Rec {f1 = 1} + In an equation for ‘printRec’: printRec = print Rec {f1 = 1} diff --git a/testsuite/tests/warnings/should_fail/all.T b/testsuite/tests/warnings/should_fail/all.T index 73117a957c..7d0dc4295f 100644 --- a/testsuite/tests/warnings/should_fail/all.T +++ b/testsuite/tests/warnings/should_fail/all.T @@ -9,6 +9,7 @@ def normalise_whitespace_carefully(s): for line in s.split('\n')) test('WerrorFail', normal, compile_fail, ['']) +test('WerrorFail2', normal, compile_fail, ['']) test('CaretDiagnostics1', [normalise_whitespace_fun(normalise_whitespace_carefully)], compile_fail, |