summaryrefslogtreecommitdiff
path: root/testsuite/tests/warnings
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/warnings
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/warnings')
-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
3 files changed, 54 insertions, 0 deletions
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([