summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorDavid Luposchainsky <dluposchainsky@gmail.com>2015-12-17 12:17:32 +0100
committerBen Gamari <ben@smart-cactus.org>2015-12-17 12:54:32 +0100
commit4f870f8481b2611619adf66d61eff06f02e3741f (patch)
tree9af21d344bb783b7eb69cb9e1ef4d0e400fd267f /testsuite/tests
parente58a9361ac7e3699e298aa5c99398a21ac732500 (diff)
downloadhaskell-4f870f8481b2611619adf66d61eff06f02e3741f.tar.gz
Conditionally show plural "s" in warnings
Redundant constraints and defaulting warnings had "constraint(s)" in their messages; the "s" is now conditional based on the number of things warned about. Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1647
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/ghc-api/apirecomp001/apirecomp001.stderr40
-rw-r--r--testsuite/tests/parser/should_compile/T2245.stderr38
-rw-r--r--testsuite/tests/typecheck/should_compile/T10971a.stderr34
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail204.stderr20
-rw-r--r--testsuite/tests/warnings/should_compile/PluralS.hs27
-rw-r--r--testsuite/tests/warnings/should_compile/PluralS.stderr26
-rw-r--r--testsuite/tests/warnings/should_compile/all.T1
7 files changed, 120 insertions, 66 deletions
diff --git a/testsuite/tests/ghc-api/apirecomp001/apirecomp001.stderr b/testsuite/tests/ghc-api/apirecomp001/apirecomp001.stderr
index 69b9996223..d778df2783 100644
--- a/testsuite/tests/ghc-api/apirecomp001/apirecomp001.stderr
+++ b/testsuite/tests/ghc-api/apirecomp001/apirecomp001.stderr
@@ -1,32 +1,32 @@
-B.hs:4:1: Warning:
+B.hs:4:1: warning:
Top-level binding with no type signature:
answer_to_live_the_universe_and_everything :: Int
-B.hs:5:12: Warning:
- Defaulting the following constraint(s) to type ‘Integer’
- (Enum a0)
- arising from the arithmetic sequence ‘1 .. 23 * 2’ at B.hs:5:12-20
- (Num a0) arising from the literal ‘1’ at B.hs:5:13
- In the first argument of ‘length’, namely ‘[1 .. 23 * 2]’
- In the first argument of ‘(-)’, namely ‘length [1 .. 23 * 2]’
- In the expression: length [1 .. 23 * 2] - 4
+B.hs:5:12: warning:
+ • Defaulting the following constraints to type ‘Integer’
+ (Enum a0)
+ arising from the arithmetic sequence ‘1 .. 23 * 2’ at B.hs:5:12-20
+ (Num a0) arising from the literal ‘1’ at B.hs:5:13
+ • In the first argument of ‘length’, namely ‘[1 .. 23 * 2]’
+ In the first argument of ‘(-)’, namely ‘length [1 .. 23 * 2]’
+ In the expression: length [1 .. 23 * 2] - 4
-A.hs:7:1: Warning:
+A.hs:7:1: warning:
Top-level binding with no type signature: main :: IO ()
-B.hs:4:1: Warning:
+B.hs:4:1: warning:
Top-level binding with no type signature:
answer_to_live_the_universe_and_everything :: Int
-B.hs:5:12: Warning:
- Defaulting the following constraint(s) to type ‘Integer’
- (Enum a0)
- arising from the arithmetic sequence ‘1 .. 23 * 2’ at B.hs:5:12-20
- (Num a0) arising from the literal ‘1’ at B.hs:5:13
- In the first argument of ‘length’, namely ‘[1 .. 23 * 2]’
- In the first argument of ‘(-)’, namely ‘length [1 .. 23 * 2]’
- In the expression: length [1 .. 23 * 2] - 4
+B.hs:5:12: warning:
+ • Defaulting the following constraints to type ‘Integer’
+ (Enum a0)
+ arising from the arithmetic sequence ‘1 .. 23 * 2’ at B.hs:5:12-20
+ (Num a0) arising from the literal ‘1’ at B.hs:5:13
+ • In the first argument of ‘length’, namely ‘[1 .. 23 * 2]’
+ In the first argument of ‘(-)’, namely ‘length [1 .. 23 * 2]’
+ In the expression: length [1 .. 23 * 2] - 4
-A.hs:7:1: Warning:
+A.hs:7:1: warning:
Top-level binding with no type signature: main :: IO ()
diff --git a/testsuite/tests/parser/should_compile/T2245.stderr b/testsuite/tests/parser/should_compile/T2245.stderr
index 53b738832f..1f5f87f7c7 100644
--- a/testsuite/tests/parser/should_compile/T2245.stderr
+++ b/testsuite/tests/parser/should_compile/T2245.stderr
@@ -1,22 +1,22 @@
-T2245.hs:4:10: Warning:
- No explicit implementation for
- ‘+’, ‘*’, ‘abs’, ‘signum’, ‘fromInteger’, and (either ‘negate’
- or
- ‘-’)
- In the instance declaration for ‘Num T’
+T2245.hs:4:10: warning:
+ • No explicit implementation for
+ ‘+’, ‘*’, ‘abs’, ‘signum’, ‘fromInteger’, and (either ‘negate’
+ or
+ ‘-’)
+ • In the instance declaration for ‘Num T’
-T2245.hs:5:10: Warning:
- No explicit implementation for
- ‘fromRational’ and (either ‘recip’ or ‘/’)
- In the instance declaration for ‘Fractional T’
+T2245.hs:5:10: warning:
+ • No explicit implementation for
+ ‘fromRational’ and (either ‘recip’ or ‘/’)
+ • In the instance declaration for ‘Fractional T’
-T2245.hs:7:29: Warning:
- Defaulting the following constraint(s) to type ‘T’
- (Fractional b0)
- arising from the literal ‘1e400’ at T2245.hs:7:29-33
- (Ord b0) arising from a use of ‘<’ at T2245.hs:7:27
- (Read b0) arising from a use of ‘read’ at T2245.hs:7:38-41
- In the second argument of ‘(<)’, namely ‘1e400’
- In the first argument of ‘(.)’, namely ‘(< 1e400)’
- In the second argument of ‘(.)’, namely ‘(< 1e400) . read’
+T2245.hs:7:29: warning:
+ • Defaulting the following constraints to type ‘T’
+ (Fractional b0)
+ arising from the literal ‘1e400’ at T2245.hs:7:29-33
+ (Ord b0) arising from a use of ‘<’ at T2245.hs:7:27
+ (Read b0) arising from a use of ‘read’ at T2245.hs:7:38-41
+ • In the second argument of ‘(<)’, namely ‘1e400’
+ In the first argument of ‘(.)’, namely ‘(< 1e400)’
+ In the second argument of ‘(.)’, namely ‘(< 1e400) . read’
diff --git a/testsuite/tests/typecheck/should_compile/T10971a.stderr b/testsuite/tests/typecheck/should_compile/T10971a.stderr
index 4cb2b72a40..7ca7680c52 100644
--- a/testsuite/tests/typecheck/should_compile/T10971a.stderr
+++ b/testsuite/tests/typecheck/should_compile/T10971a.stderr
@@ -3,11 +3,11 @@ T10971a.hs:7:1: warning:
Top-level binding with no type signature: f :: forall a. [a] -> Int
T10971a.hs:7:11: warning:
- Defaulting the following constraint(s) to type ‘[]’
- Foldable t0 arising from a use of ‘length’
- In the expression: length x
- In the expression: \ x -> length x
- In an equation for ‘f’: f = \ x -> length x
+ • Defaulting the following constraint to type ‘[]’
+ Foldable t0 arising from a use of ‘length’
+ • In the expression: length x
+ In the expression: \ x -> length x
+ In an equation for ‘f’: f = \ x -> length x
T10971a.hs:8:1: warning:
Top-level binding with no type signature:
@@ -18,11 +18,11 @@ T10971a.hs:8:6: warning:
defined at T10971a.hs:7:1
T10971a.hs:8:13: warning:
- Defaulting the following constraint(s) to type ‘[]’
- Traversable t0 arising from a use of ‘fmapDefault’
- In the expression: fmapDefault f x
- In the expression: \ f x -> fmapDefault f x
- In an equation for ‘g’: g = \ f x -> fmapDefault f x
+ • Defaulting the following constraint to type ‘[]’
+ Traversable t0 arising from a use of ‘fmapDefault’
+ • In the expression: fmapDefault f x
+ In the expression: \ f x -> fmapDefault f x
+ In an equation for ‘g’: g = \ f x -> fmapDefault f x
T10971a.hs:9:1: warning:
Top-level binding with no type signature:
@@ -33,10 +33,10 @@ T10971a.hs:9:6: warning:
defined at T10971a.hs:7:1
T10971a.hs:9:31: warning:
- Defaulting the following constraint(s) to type ‘[]’
- (Foldable t0) arising from a use of ‘length’ at T10971a.hs:9:31-36
- (Traversable t0)
- arising from a use of ‘fmapDefault’ at T10971a.hs:9:14-24
- In the expression: length x
- In the expression: (fmapDefault f x, length x)
- In the expression: \ f x -> (fmapDefault f x, length x)
+ • Defaulting the following constraints to type ‘[]’
+ (Foldable t0) arising from a use of ‘length’ at T10971a.hs:9:31-36
+ (Traversable t0)
+ arising from a use of ‘fmapDefault’ at T10971a.hs:9:14-24
+ • In the expression: length x
+ In the expression: (fmapDefault f x, length x)
+ In the expression: \ f x -> (fmapDefault f x, length x)
diff --git a/testsuite/tests/typecheck/should_fail/tcfail204.stderr b/testsuite/tests/typecheck/should_fail/tcfail204.stderr
index e8ecfc0024..b6ef584387 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail204.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail204.stderr
@@ -1,13 +1,13 @@
-tcfail204.hs:10:15: Warning:
- Defaulting the following constraint(s) to type ‘Double’
- (Fractional a0)
- arising from the literal ‘6.3’ at tcfail204.hs:10:15-17
- (RealFrac a0)
- arising from a use of ‘ceiling’ at tcfail204.hs:10:7-13
- In the first argument of ‘ceiling’, namely ‘6.3’
- In the expression: ceiling 6.3
- In an equation for ‘foo’: foo = ceiling 6.3
+tcfail204.hs:10:15: warning:
+ • Defaulting the following constraints to type ‘Double’
+ (Fractional a0)
+ arising from the literal ‘6.3’ at tcfail204.hs:10:15-17
+ (RealFrac a0)
+ arising from a use of ‘ceiling’ at tcfail204.hs:10:7-13
+ • In the first argument of ‘ceiling’, namely ‘6.3’
+ In the expression: ceiling 6.3
+ In an equation for ‘foo’: foo = ceiling 6.3
-<no location info>:
+<no location info>: error:
Failing due to -Werror.
diff --git a/testsuite/tests/warnings/should_compile/PluralS.hs b/testsuite/tests/warnings/should_compile/PluralS.hs
new file mode 100644
index 0000000000..89b5dbffcd
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/PluralS.hs
@@ -0,0 +1,27 @@
+-- Test purpose:
+--
+-- Ensure the plural "s" in warnings is only shown if there are more than
+-- one entries
+
+{-# OPTIONS_GHC -Wredundant-constraints #-}
+{-# OPTIONS_GHC -Wtype-defaults #-}
+
+module PluralS () where
+
+
+
+-- Defaulting type classes
+
+defaultingNum = 123 `seq` ()
+
+defaultingNumAndShow = show 123
+
+
+
+-- Redundant constraints
+
+redundantNum :: (Num a, Num a) => a
+redundantNum = 123
+
+redundantMultiple :: (Num a, Show a, Num a, Eq a, Eq a) => a
+redundantMultiple = 123
diff --git a/testsuite/tests/warnings/should_compile/PluralS.stderr b/testsuite/tests/warnings/should_compile/PluralS.stderr
new file mode 100644
index 0000000000..c013e7b73d
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/PluralS.stderr
@@ -0,0 +1,26 @@
+
+PluralS.hs:15:17: warning:
+ • Defaulting the following constraint to type ‘Integer’
+ Num t0 arising from the literal ‘123’
+ • In the first argument of ‘seq’, namely ‘123’
+ In the expression: 123 `seq` ()
+ In an equation for ‘defaultingNum’: defaultingNum = 123 `seq` ()
+
+PluralS.hs:17:29: warning:
+ • Defaulting the following constraints to type ‘Integer’
+ (Num a0) arising from the literal ‘123’ at PluralS.hs:17:29-31
+ (Show a0) arising from a use of ‘show’ at PluralS.hs:17:24-27
+ • In the first argument of ‘show’, namely ‘123’
+ In the expression: show 123
+ In an equation for ‘defaultingNumAndShow’:
+ defaultingNumAndShow = show 123
+
+PluralS.hs:23:1: warning:
+ • Redundant constraint: Num a
+ • In the type signature for:
+ redundantNum :: (Num a, Num a) => a
+
+PluralS.hs:26:1: warning:
+ • Redundant constraints: (Show a, Num a, Eq a, Eq a)
+ • In the type signature for:
+ redundantMultiple :: (Num a, Show a, Num a, Eq a, Eq a) => a
diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T
index f60468e6ca..a2b1860ba4 100644
--- a/testsuite/tests/warnings/should_compile/all.T
+++ b/testsuite/tests/warnings/should_compile/all.T
@@ -7,6 +7,7 @@ test('T9230', normal, compile_without_flag('-fno-warn-tabs'), [''])
test('T10908', normal, compile, [''])
test('T11077', normal, compile, ['-fwarn-missing-exported-sigs'])
test('T11128', normal, compile, [''])
+test('PluralS', normal, compile, [''])
test('DeprU',
extra_clean([