summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel de Bruijne <m.debruijne@matrict.nl>2021-01-05 09:44:11 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-22 18:26:52 -0500
commite1f133bf5ee30f25a94b4f3bf4d26d1a9381f0d9 (patch)
tree6ff9aa4b04431c57ce6c207a2017cd1e051615f6
parentf90487cacb16e8398c4c4a84de5a1e33ac4e7867 (diff)
downloadhaskell-e1f133bf5ee30f25a94b4f3bf4d26d1a9381f0d9.tar.gz
Prefer -Wmissing-signatures over -Wmissing-exported-signatures (#14794)
-rw-r--r--compiler/GHC/Rename/Names.hs12
-rw-r--r--docs/users_guide/using-warnings.rst7
-rw-r--r--testsuite/tests/warnings/should_compile/T14794a.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794a.stderr12
-rw-r--r--testsuite/tests/warnings/should_compile/T14794b.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794b.stderr12
-rw-r--r--testsuite/tests/warnings/should_compile/T14794c.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794c.stderr12
-rw-r--r--testsuite/tests/warnings/should_compile/T14794d.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794d.stderr6
-rw-r--r--testsuite/tests/warnings/should_compile/T14794e.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794e.stderr12
-rw-r--r--testsuite/tests/warnings/should_compile/T14794f.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794f.stderr3
-rw-r--r--testsuite/tests/warnings/should_compile/T14794g.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794g.stderr6
-rw-r--r--testsuite/tests/warnings/should_compile/T2526.hs7
-rw-r--r--testsuite/tests/warnings/should_compile/T2526.stderr3
-rw-r--r--testsuite/tests/warnings/should_compile/all.T10
19 files changed, 298 insertions, 21 deletions
diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs
index 99d2089799..6dff5b195e 100644
--- a/compiler/GHC/Rename/Names.hs
+++ b/compiler/GHC/Rename/Names.hs
@@ -1480,16 +1480,16 @@ warnMissingSignatures gbl_env
; warn_pat_syns <- woptM Opt_WarnMissingPatternSynonymSignatures
; let add_sig_warns
- | warn_only_exported = add_warns Opt_WarnMissingExportedSignatures
| warn_missing_sigs = add_warns Opt_WarnMissingSignatures
+ | warn_only_exported = add_warns Opt_WarnMissingExportedSignatures
| warn_pat_syns = add_warns Opt_WarnMissingPatternSynonymSignatures
| otherwise = return ()
add_warns flag
- = when warn_pat_syns
- (mapM_ add_pat_syn_warn pat_syns) >>
- when (warn_missing_sigs || warn_only_exported)
- (mapM_ add_bind_warn binds)
+ = when (warn_missing_sigs || warn_only_exported)
+ (mapM_ add_bind_warn binds) >>
+ when (warn_missing_sigs || warn_pat_syns)
+ (mapM_ add_pat_syn_warn pat_syns)
where
add_pat_syn_warn p
= add_warn name $
@@ -1514,7 +1514,7 @@ warnMissingSignatures gbl_env
(addWarnAt (Reason flag) (getSrcSpan name) msg)
export_check name
- = not warn_only_exported || name `elemNameSet` exports
+ = warn_missing_sigs || not warn_only_exported || name `elemNameSet` exports
; add_sig_warns }
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst
index 252b6a5383..5c2c9b66e1 100644
--- a/docs/users_guide/using-warnings.rst
+++ b/docs/users_guide/using-warnings.rst
@@ -1104,7 +1104,7 @@ of ``-W(no-)*``.
.. ghc-flag:: -Wmissing-exported-signatures
:shortdesc: warn about top-level functions without signatures, only if they
- are exported. takes precedence over -Wmissing-signatures
+ are exported
:type: dynamic
:reverse: -Wno-missing-exported-signatures
:category:
@@ -1115,8 +1115,9 @@ of ``-W(no-)*``.
If you would like GHC to check that every exported top-level
function/value has a type signature, but not check unexported
values, use the :ghc-flag:`-Wmissing-exported-signatures`
- option. This option takes precedence over
- :ghc-flag:`-Wmissing-signatures`. As part of the warning GHC also
+ option. If this option is used in conjunction with
+ :ghc-flag:`-Wmissing-signatures` then every top-level function/value
+ must have a type signature. As part of the warning GHC also
reports the inferred type. The option is off by default.
.. ghc-flag:: -Wmissing-local-sigs
diff --git a/testsuite/tests/warnings/should_compile/T14794a.hs b/testsuite/tests/warnings/should_compile/T14794a.hs
new file mode 100644
index 0000000000..224eaf64f7
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794a.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures #-}
+
+module T14794a (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-signatures -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+
+test3 = True
+
+pattern Test4 <- True
+
+test7 = True
+
+pattern Test8 <- True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-signatures -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794a.stderr b/testsuite/tests/warnings/should_compile/T14794a.stderr
new file mode 100644
index 0000000000..166d59ab37
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794a.stderr
@@ -0,0 +1,12 @@
+
+T14794a.hs:9:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test3 :: Bool
+
+T14794a.hs:11:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test4 :: Bool
+
+T14794a.hs:13:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test7 :: Bool
+
+T14794a.hs:15:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test8 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794b.hs b/testsuite/tests/warnings/should_compile/T14794b.hs
new file mode 100644
index 0000000000..7c542b4dc1
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794b.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-exported-signatures #-}
+
+module T14794b (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-signatures -Wmissing-exported-signatures
+
+test3 = True
+
+pattern Test4 <- True
+
+test7 = True
+
+pattern Test8 <- True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-signatures -Wmissing-exported-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794b.stderr b/testsuite/tests/warnings/should_compile/T14794b.stderr
new file mode 100644
index 0000000000..6109a4c985
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794b.stderr
@@ -0,0 +1,12 @@
+
+T14794b.hs:9:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test3 :: Bool
+
+T14794b.hs:11:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test4 :: Bool
+
+T14794b.hs:13:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test7 :: Bool
+
+T14794b.hs:15:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test8 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794c.hs b/testsuite/tests/warnings/should_compile/T14794c.hs
new file mode 100644
index 0000000000..742ca3c91c
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794c.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-pattern-synonym-signatures #-}
+
+module T14794c (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-signatures -Wmissing-pattern-synonym-signatures
+
+test3 = True
+
+pattern Test4 <- True
+
+test7 = True
+
+pattern Test8 <- True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-signatures -Wmissing-pattern-synonym-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794c.stderr b/testsuite/tests/warnings/should_compile/T14794c.stderr
new file mode 100644
index 0000000000..95cbb4d16f
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794c.stderr
@@ -0,0 +1,12 @@
+
+T14794c.hs:9:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test3 :: Bool
+
+T14794c.hs:11:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test4 :: Bool
+
+T14794c.hs:13:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test7 :: Bool
+
+T14794c.hs:15:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test8 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794d.hs b/testsuite/tests/warnings/should_compile/T14794d.hs
new file mode 100644
index 0000000000..8928df75d3
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794d.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures #-}
+
+module T14794d (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+
+test3 = True
+
+pattern Test4 <- True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
+
+test7 = True
+
+pattern Test8 <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794d.stderr b/testsuite/tests/warnings/should_compile/T14794d.stderr
new file mode 100644
index 0000000000..3388d17316
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794d.stderr
@@ -0,0 +1,6 @@
+
+T14794d.hs:9:1: warning: [-Wmissing-exported-signatures]
+ Top-level binding with no type signature: test3 :: Bool
+
+T14794d.hs:11:1: warning: [-Wmissing-exported-signatures]
+ Pattern synonym with no type signature: pattern Test4 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794e.hs b/testsuite/tests/warnings/should_compile/T14794e.hs
new file mode 100644
index 0000000000..051cf347d6
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794e.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-signatures #-}
+
+module T14794e (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-signatures
+
+test3 = True
+
+pattern Test4 <- True
+
+test7 = True
+
+pattern Test8 <- True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794e.stderr b/testsuite/tests/warnings/should_compile/T14794e.stderr
new file mode 100644
index 0000000000..f0e4ddbc4c
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794e.stderr
@@ -0,0 +1,12 @@
+
+T14794e.hs:9:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test3 :: Bool
+
+T14794e.hs:11:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test4 :: Bool
+
+T14794e.hs:13:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: test7 :: Bool
+
+T14794e.hs:15:1: warning: [-Wmissing-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test8 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794f.hs b/testsuite/tests/warnings/should_compile/T14794f.hs
new file mode 100644
index 0000000000..c2cf58f174
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794f.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-exported-signatures #-}
+
+module T14794f (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-exported-signatures
+
+test3 = True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-exported-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+pattern Test4 <- True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
+
+test7 = True
+
+pattern Test8 <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794f.stderr b/testsuite/tests/warnings/should_compile/T14794f.stderr
new file mode 100644
index 0000000000..b751aad98e
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794f.stderr
@@ -0,0 +1,3 @@
+
+T14794f.hs:9:1: warning: [-Wmissing-exported-signatures]
+ Top-level binding with no type signature: test3 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794g.hs b/testsuite/tests/warnings/should_compile/T14794g.hs
new file mode 100644
index 0000000000..eec2210203
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794g.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# OPTIONS_GHC -Wmissing-pattern-synonym-signatures #-}
+
+module T14794g (test1, pattern Test2, test3, pattern Test4) where
+
+-- This should generate warnings with;
+-- -Wmissing-pattern-synonym-signatures
+
+pattern Test4 <- True
+
+pattern Test8 <- True
+
+
+-- This should not generate warnings with;
+-- -Wmissing-pattern-synonym-signatures
+
+test1 :: Bool
+test1 = True
+
+pattern Test2 :: Bool
+pattern Test2 <- True
+
+test3 = True
+
+test5 :: Bool
+test5 = True
+
+pattern Test6 :: Bool
+pattern Test6 <- True
+
+test7 = True
diff --git a/testsuite/tests/warnings/should_compile/T14794g.stderr b/testsuite/tests/warnings/should_compile/T14794g.stderr
new file mode 100644
index 0000000000..abd3bf205d
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T14794g.stderr
@@ -0,0 +1,6 @@
+
+T14794g.hs:9:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test4 :: Bool
+
+T14794g.hs:11:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)]
+ Pattern synonym with no type signature: pattern Test8 :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T2526.hs b/testsuite/tests/warnings/should_compile/T2526.hs
deleted file mode 100644
index c77168c73b..0000000000
--- a/testsuite/tests/warnings/should_compile/T2526.hs
+++ /dev/null
@@ -1,7 +0,0 @@
-module T2526 (foo) where
-
--- This should generate a warning
-foo = 1
-
--- This should not
-bar = 2
diff --git a/testsuite/tests/warnings/should_compile/T2526.stderr b/testsuite/tests/warnings/should_compile/T2526.stderr
deleted file mode 100644
index b433f0e71d..0000000000
--- a/testsuite/tests/warnings/should_compile/T2526.stderr
+++ /dev/null
@@ -1,3 +0,0 @@
-
-T2526.hs:4:1: warning: [-Wmissing-exported-signatures]
- Top-level binding with no type signature: foo :: Integer
diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T
index de46efcf1f..7e8668c8d8 100644
--- a/testsuite/tests/warnings/should_compile/all.T
+++ b/testsuite/tests/warnings/should_compile/all.T
@@ -1,5 +1,11 @@
-# -fwarn-missing-exported-signatures should take precedence over -fwarn-missing-signatures
-test('T2526', normal, compile, ['-fwarn-missing-signatures -fwarn-missing-exported-signatures'])
+test('T14794a', normal, compile, [''])
+test('T14794b', normal, compile, [''])
+test('T14794c', normal, compile, [''])
+test('T14794d', normal, compile, [''])
+test('T14794e', normal, compile, [''])
+test('T14794f', normal, compile, [''])
+test('T14794g', normal, compile, [''])
+
test('T9178', [], multimod_compile, ['T9178', '-Wall'])
# T9230.hs contains a tab character. Test that -Wtabs is enabled by default.