summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Winant <dewinant@gmail.com>2021-01-20 18:25:33 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-29 05:04:00 -0400
commit5ae070f168ba7f9679b045ea4b8f30917f47f800 (patch)
tree4b5a5a30d8bfca4bf42b169a2a23f7c68d6e6ffe
parentdf997fac54bbadd399593f49228b6292e71145f1 (diff)
downloadhaskell-5ae070f168ba7f9679b045ea4b8f30917f47f800.tar.gz
Add -Wmissing-exported-pattern-synonym-signatures
After !4741, it was no longer possible to silence a warning about a missing pattern synonym signature if the `-Wmissing-signatures` flag was on. Restore the previous semantics while still adhering to the principle "enabling an additional warning flag should never make prior warnings disappear". For more symmetry and granularity, introduce `-Wmissing-exported-pattern-synonym-signatures`. See Note [Missing signatures] for an overview of all flags involved.
-rw-r--r--compiler/GHC/Driver/Flags.hs180
-rw-r--r--compiler/GHC/Driver/Session.hs3
-rw-r--r--compiler/GHC/Rename/Names.hs108
-rw-r--r--docs/users_guide/using-warnings.rst18
-rw-r--r--testsuite/tests/warnings/should_compile/T14794a.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794a.stderr14
-rw-r--r--testsuite/tests/warnings/should_compile/T14794b.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794b.stderr13
-rw-r--r--testsuite/tests/warnings/should_compile/T14794c.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794c.stderr14
-rw-r--r--testsuite/tests/warnings/should_compile/T14794d.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794d.stderr10
-rw-r--r--testsuite/tests/warnings/should_compile/T14794e.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794e.stderr14
-rw-r--r--testsuite/tests/warnings/should_compile/T14794f.hs31
-rw-r--r--testsuite/tests/warnings/should_compile/T14794f.stderr9
-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/all.T1
19 files changed, 255 insertions, 352 deletions
diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs
index 97039cbcf8..19f730ed19 100644
--- a/compiler/GHC/Driver/Flags.hs
+++ b/compiler/GHC/Driver/Flags.hs
@@ -534,6 +534,7 @@ data WarningFlag =
| Opt_WarnAmbiguousFields -- Since 9.2
| Opt_WarnImplicitLift -- Since 9.2
| Opt_WarnMissingKindSignatures -- Since 9.2
+ | Opt_WarnMissingExportedPatternSynonymSignatures -- since 9.2
deriving (Eq, Show, Enum)
-- | Return the names of a WarningFlag
@@ -542,95 +543,96 @@ data WarningFlag =
-- the "preferred one" that will be displayed in warning messages.
warnFlagNames :: WarningFlag -> NonEmpty String
warnFlagNames wflag = case wflag of
- Opt_WarnAlternativeLayoutRuleTransitional -> "alternative-layout-rule-transitional" :| []
- Opt_WarnAmbiguousFields -> "ambiguous-fields" :| []
- Opt_WarnAutoOrphans -> "auto-orphans" :| []
- Opt_WarnCPPUndef -> "cpp-undef" :| []
- Opt_WarnUnbangedStrictPatterns -> "unbanged-strict-patterns" :| []
- Opt_WarnDeferredTypeErrors -> "deferred-type-errors" :| []
- Opt_WarnDeferredOutOfScopeVariables -> "deferred-out-of-scope-variables" :| []
- Opt_WarnWarningsDeprecations -> "deprecations" :| ["warnings-deprecations"]
- Opt_WarnDeprecatedFlags -> "deprecated-flags" :| []
- Opt_WarnDerivingDefaults -> "deriving-defaults" :| []
- Opt_WarnDerivingTypeable -> "deriving-typeable" :| []
- Opt_WarnDodgyExports -> "dodgy-exports" :| []
- Opt_WarnDodgyForeignImports -> "dodgy-foreign-imports" :| []
- Opt_WarnDodgyImports -> "dodgy-imports" :| []
- Opt_WarnEmptyEnumerations -> "empty-enumerations" :| []
- Opt_WarnDuplicateConstraints -> "duplicate-constraints" :| []
- Opt_WarnRedundantConstraints -> "redundant-constraints" :| []
- Opt_WarnDuplicateExports -> "duplicate-exports" :| []
- Opt_WarnHiShadows -> "hi-shadowing" :| []
- Opt_WarnInaccessibleCode -> "inaccessible-code" :| []
- Opt_WarnImplicitPrelude -> "implicit-prelude" :| []
- Opt_WarnImplicitKindVars -> "implicit-kind-vars" :| []
- Opt_WarnIncompletePatterns -> "incomplete-patterns" :| []
- Opt_WarnIncompletePatternsRecUpd -> "incomplete-record-updates" :| []
- Opt_WarnIncompleteUniPatterns -> "incomplete-uni-patterns" :| []
- Opt_WarnInlineRuleShadowing -> "inline-rule-shadowing" :| []
- Opt_WarnIdentities -> "identities" :| []
- Opt_WarnMissingFields -> "missing-fields" :| []
- Opt_WarnMissingImportList -> "missing-import-lists" :| []
- Opt_WarnMissingExportList -> "missing-export-lists" :| []
- Opt_WarnMissingLocalSignatures -> "missing-local-signatures" :| []
- Opt_WarnMissingMethods -> "missing-methods" :| []
- Opt_WarnMissingMonadFailInstances -> "missing-monadfail-instances" :| []
- Opt_WarnSemigroup -> "semigroup" :| []
- Opt_WarnMissingSignatures -> "missing-signatures" :| []
- Opt_WarnMissingKindSignatures -> "missing-kind-signatures" :| []
- Opt_WarnMissingExportedSignatures -> "missing-exported-signatures" :| []
- Opt_WarnMonomorphism -> "monomorphism-restriction" :| []
- Opt_WarnNameShadowing -> "name-shadowing" :| []
- Opt_WarnNonCanonicalMonadInstances -> "noncanonical-monad-instances" :| []
- Opt_WarnNonCanonicalMonadFailInstances -> "noncanonical-monadfail-instances" :| []
- Opt_WarnNonCanonicalMonoidInstances -> "noncanonical-monoid-instances" :| []
- Opt_WarnOrphans -> "orphans" :| []
- Opt_WarnOverflowedLiterals -> "overflowed-literals" :| []
- Opt_WarnOverlappingPatterns -> "overlapping-patterns" :| []
- Opt_WarnMissedSpecs -> "missed-specialisations" :| ["missed-specializations"]
- Opt_WarnAllMissedSpecs -> "all-missed-specialisations" :| ["all-missed-specializations"]
- Opt_WarnSafe -> "safe" :| []
- Opt_WarnTrustworthySafe -> "trustworthy-safe" :| []
- Opt_WarnInferredSafeImports -> "inferred-safe-imports" :| []
- Opt_WarnMissingSafeHaskellMode -> "missing-safe-haskell-mode" :| []
- Opt_WarnTabs -> "tabs" :| []
- Opt_WarnTypeDefaults -> "type-defaults" :| []
- Opt_WarnTypedHoles -> "typed-holes" :| []
- Opt_WarnPartialTypeSignatures -> "partial-type-signatures" :| []
- Opt_WarnUnrecognisedPragmas -> "unrecognised-pragmas" :| []
- Opt_WarnUnsafe -> "unsafe" :| []
- Opt_WarnUnsupportedCallingConventions -> "unsupported-calling-conventions" :| []
- Opt_WarnUnsupportedLlvmVersion -> "unsupported-llvm-version" :| []
- Opt_WarnMissedExtraSharedLib -> "missed-extra-shared-lib" :| []
- Opt_WarnUntickedPromotedConstructors -> "unticked-promoted-constructors" :| []
- Opt_WarnUnusedDoBind -> "unused-do-bind" :| []
- Opt_WarnUnusedForalls -> "unused-foralls" :| []
- Opt_WarnUnusedImports -> "unused-imports" :| []
- Opt_WarnUnusedLocalBinds -> "unused-local-binds" :| []
- Opt_WarnUnusedMatches -> "unused-matches" :| []
- Opt_WarnUnusedPatternBinds -> "unused-pattern-binds" :| []
- Opt_WarnUnusedTopBinds -> "unused-top-binds" :| []
- Opt_WarnUnusedTypePatterns -> "unused-type-patterns" :| []
- Opt_WarnUnusedRecordWildcards -> "unused-record-wildcards" :| []
- Opt_WarnRedundantBangPatterns -> "redundant-bang-patterns" :| []
- Opt_WarnRedundantRecordWildcards -> "redundant-record-wildcards" :| []
- Opt_WarnWrongDoBind -> "wrong-do-bind" :| []
- Opt_WarnMissingPatternSynonymSignatures -> "missing-pattern-synonym-signatures" :| []
- Opt_WarnMissingDerivingStrategies -> "missing-deriving-strategies" :| []
- Opt_WarnSimplifiableClassConstraints -> "simplifiable-class-constraints" :| []
- Opt_WarnMissingHomeModules -> "missing-home-modules" :| []
- Opt_WarnUnrecognisedWarningFlags -> "unrecognised-warning-flags" :| []
- Opt_WarnStarBinder -> "star-binder" :| []
- Opt_WarnStarIsType -> "star-is-type" :| []
- Opt_WarnSpaceAfterBang -> "missing-space-after-bang" :| []
- Opt_WarnPartialFields -> "partial-fields" :| []
- Opt_WarnPrepositiveQualifiedModule -> "prepositive-qualified-module" :| []
- Opt_WarnUnusedPackages -> "unused-packages" :| []
- Opt_WarnCompatUnqualifiedImports -> "compat-unqualified-imports" :| []
- Opt_WarnInvalidHaddock -> "invalid-haddock" :| []
- Opt_WarnOperatorWhitespaceExtConflict -> "operator-whitespace-ext-conflict" :| []
- Opt_WarnOperatorWhitespace -> "operator-whitespace" :| []
- Opt_WarnImplicitLift -> "implicit-lift" :| []
+ Opt_WarnAlternativeLayoutRuleTransitional -> "alternative-layout-rule-transitional" :| []
+ Opt_WarnAmbiguousFields -> "ambiguous-fields" :| []
+ Opt_WarnAutoOrphans -> "auto-orphans" :| []
+ Opt_WarnCPPUndef -> "cpp-undef" :| []
+ Opt_WarnUnbangedStrictPatterns -> "unbanged-strict-patterns" :| []
+ Opt_WarnDeferredTypeErrors -> "deferred-type-errors" :| []
+ Opt_WarnDeferredOutOfScopeVariables -> "deferred-out-of-scope-variables" :| []
+ Opt_WarnWarningsDeprecations -> "deprecations" :| ["warnings-deprecations"]
+ Opt_WarnDeprecatedFlags -> "deprecated-flags" :| []
+ Opt_WarnDerivingDefaults -> "deriving-defaults" :| []
+ Opt_WarnDerivingTypeable -> "deriving-typeable" :| []
+ Opt_WarnDodgyExports -> "dodgy-exports" :| []
+ Opt_WarnDodgyForeignImports -> "dodgy-foreign-imports" :| []
+ Opt_WarnDodgyImports -> "dodgy-imports" :| []
+ Opt_WarnEmptyEnumerations -> "empty-enumerations" :| []
+ Opt_WarnDuplicateConstraints -> "duplicate-constraints" :| []
+ Opt_WarnRedundantConstraints -> "redundant-constraints" :| []
+ Opt_WarnDuplicateExports -> "duplicate-exports" :| []
+ Opt_WarnHiShadows -> "hi-shadowing" :| []
+ Opt_WarnInaccessibleCode -> "inaccessible-code" :| []
+ Opt_WarnImplicitPrelude -> "implicit-prelude" :| []
+ Opt_WarnImplicitKindVars -> "implicit-kind-vars" :| []
+ Opt_WarnIncompletePatterns -> "incomplete-patterns" :| []
+ Opt_WarnIncompletePatternsRecUpd -> "incomplete-record-updates" :| []
+ Opt_WarnIncompleteUniPatterns -> "incomplete-uni-patterns" :| []
+ Opt_WarnInlineRuleShadowing -> "inline-rule-shadowing" :| []
+ Opt_WarnIdentities -> "identities" :| []
+ Opt_WarnMissingFields -> "missing-fields" :| []
+ Opt_WarnMissingImportList -> "missing-import-lists" :| []
+ Opt_WarnMissingExportList -> "missing-export-lists" :| []
+ Opt_WarnMissingLocalSignatures -> "missing-local-signatures" :| []
+ Opt_WarnMissingMethods -> "missing-methods" :| []
+ Opt_WarnMissingMonadFailInstances -> "missing-monadfail-instances" :| []
+ Opt_WarnSemigroup -> "semigroup" :| []
+ Opt_WarnMissingSignatures -> "missing-signatures" :| []
+ Opt_WarnMissingKindSignatures -> "missing-kind-signatures" :| []
+ Opt_WarnMissingExportedSignatures -> "missing-exported-signatures" :| []
+ Opt_WarnMonomorphism -> "monomorphism-restriction" :| []
+ Opt_WarnNameShadowing -> "name-shadowing" :| []
+ Opt_WarnNonCanonicalMonadInstances -> "noncanonical-monad-instances" :| []
+ Opt_WarnNonCanonicalMonadFailInstances -> "noncanonical-monadfail-instances" :| []
+ Opt_WarnNonCanonicalMonoidInstances -> "noncanonical-monoid-instances" :| []
+ Opt_WarnOrphans -> "orphans" :| []
+ Opt_WarnOverflowedLiterals -> "overflowed-literals" :| []
+ Opt_WarnOverlappingPatterns -> "overlapping-patterns" :| []
+ Opt_WarnMissedSpecs -> "missed-specialisations" :| ["missed-specializations"]
+ Opt_WarnAllMissedSpecs -> "all-missed-specialisations" :| ["all-missed-specializations"]
+ Opt_WarnSafe -> "safe" :| []
+ Opt_WarnTrustworthySafe -> "trustworthy-safe" :| []
+ Opt_WarnInferredSafeImports -> "inferred-safe-imports" :| []
+ Opt_WarnMissingSafeHaskellMode -> "missing-safe-haskell-mode" :| []
+ Opt_WarnTabs -> "tabs" :| []
+ Opt_WarnTypeDefaults -> "type-defaults" :| []
+ Opt_WarnTypedHoles -> "typed-holes" :| []
+ Opt_WarnPartialTypeSignatures -> "partial-type-signatures" :| []
+ Opt_WarnUnrecognisedPragmas -> "unrecognised-pragmas" :| []
+ Opt_WarnUnsafe -> "unsafe" :| []
+ Opt_WarnUnsupportedCallingConventions -> "unsupported-calling-conventions" :| []
+ Opt_WarnUnsupportedLlvmVersion -> "unsupported-llvm-version" :| []
+ Opt_WarnMissedExtraSharedLib -> "missed-extra-shared-lib" :| []
+ Opt_WarnUntickedPromotedConstructors -> "unticked-promoted-constructors" :| []
+ Opt_WarnUnusedDoBind -> "unused-do-bind" :| []
+ Opt_WarnUnusedForalls -> "unused-foralls" :| []
+ Opt_WarnUnusedImports -> "unused-imports" :| []
+ Opt_WarnUnusedLocalBinds -> "unused-local-binds" :| []
+ Opt_WarnUnusedMatches -> "unused-matches" :| []
+ Opt_WarnUnusedPatternBinds -> "unused-pattern-binds" :| []
+ Opt_WarnUnusedTopBinds -> "unused-top-binds" :| []
+ Opt_WarnUnusedTypePatterns -> "unused-type-patterns" :| []
+ Opt_WarnUnusedRecordWildcards -> "unused-record-wildcards" :| []
+ Opt_WarnRedundantBangPatterns -> "redundant-bang-patterns" :| []
+ Opt_WarnRedundantRecordWildcards -> "redundant-record-wildcards" :| []
+ Opt_WarnWrongDoBind -> "wrong-do-bind" :| []
+ Opt_WarnMissingPatternSynonymSignatures -> "missing-pattern-synonym-signatures" :| []
+ Opt_WarnMissingDerivingStrategies -> "missing-deriving-strategies" :| []
+ Opt_WarnSimplifiableClassConstraints -> "simplifiable-class-constraints" :| []
+ Opt_WarnMissingHomeModules -> "missing-home-modules" :| []
+ Opt_WarnUnrecognisedWarningFlags -> "unrecognised-warning-flags" :| []
+ Opt_WarnStarBinder -> "star-binder" :| []
+ Opt_WarnStarIsType -> "star-is-type" :| []
+ Opt_WarnSpaceAfterBang -> "missing-space-after-bang" :| []
+ Opt_WarnPartialFields -> "partial-fields" :| []
+ Opt_WarnPrepositiveQualifiedModule -> "prepositive-qualified-module" :| []
+ Opt_WarnUnusedPackages -> "unused-packages" :| []
+ Opt_WarnCompatUnqualifiedImports -> "compat-unqualified-imports" :| []
+ Opt_WarnInvalidHaddock -> "invalid-haddock" :| []
+ Opt_WarnOperatorWhitespaceExtConflict -> "operator-whitespace-ext-conflict" :| []
+ Opt_WarnOperatorWhitespace -> "operator-whitespace" :| []
+ Opt_WarnImplicitLift -> "implicit-lift" :| []
+ Opt_WarnMissingExportedPatternSynonymSignatures -> "missing-exported-pattern-synonym-signatures" :| []
-- -----------------------------------------------------------------------------
-- Standard sets of warning options
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 4e570f1b3e..f6095677e4 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -3243,7 +3243,8 @@ wWarningFlagsDeps = mconcat [
warnSpec Opt_WarnInvalidHaddock,
warnSpec Opt_WarnOperatorWhitespaceExtConflict,
warnSpec Opt_WarnOperatorWhitespace,
- warnSpec Opt_WarnImplicitLift
+ warnSpec Opt_WarnImplicitLift,
+ warnSpec Opt_WarnMissingExportedPatternSynonymSignatures
]
-- | These @-\<blah\>@ flags can all be reversed with @-no-\<blah\>@
diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs
index ee545b9132..fa19bdc600 100644
--- a/compiler/GHC/Rename/Names.hs
+++ b/compiler/GHC/Rename/Names.hs
@@ -1482,6 +1482,28 @@ reportUnusedNames gbl_env hsc_src
* *
********************************************************************* -}
+{-
+Note [Missing signatures]
+~~~~~~~~~~~~~~~~~~~~~~~~~
+There are four warning flags in play:
+
+ * -Wmissing-exported-signatures
+ Warn about any exported top-level function/value without a type signature.
+ Does not include pattern synonyms.
+
+ * -Wmissing-signatures
+ Warn about any top-level function/value without a type signature. Does not
+ include pattern synonyms. Takes priority over -Wmissing-exported-signatures.
+
+ * -Wmissing-exported-pattern-synonym-signatures
+ Warn about any exported pattern synonym without a type signature.
+
+ * -Wmissing-pattern-synonym-signatures
+ Warn about any pattern synonym without a type signature. Takes priority over
+ -Wmissing-exported-pattern-synonym-signatures.
+
+-}
+
-- | Warn the user about top level binders that lack type signatures.
-- Called /after/ type inference, so that we can report the
-- inferred type of the function
@@ -1495,46 +1517,56 @@ warnMissingSignatures gbl_env
-- Warn about missing signatures
-- Do this only when we have a type to offer
- ; warn_missing_sigs <- woptM Opt_WarnMissingSignatures
- ; warn_only_exported <- woptM Opt_WarnMissingExportedSignatures
- ; warn_pat_syns <- woptM Opt_WarnMissingPatternSynonymSignatures
+ ; warn_binds <- woptM Opt_WarnMissingSignatures
+ ; warn_exported_binds <- woptM Opt_WarnMissingExportedSignatures
+ ; warn_pat_syns <- woptM Opt_WarnMissingPatternSynonymSignatures
+ ; warn_exported_pat_syns <- woptM Opt_WarnMissingExportedPatternSynonymSignatures
+ -- See Note [Missing signatures]
; let add_sig_warns
- | 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_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 $
- hang (text "Pattern synonym with no type signature:")
- 2 (text "pattern" <+> pprPrefixName name <+> dcolon <+> pp_ty)
- where
- name = patSynName p
- pp_ty = pprPatSynType p
-
- add_bind_warn :: Id -> IOEnv (Env TcGblEnv TcLclEnv) ()
- add_bind_warn id
- = do { env <- tcInitTidyEnv -- Why not use emptyTidyEnv?
- ; let name = idName id
- (_, ty) = tidyOpenType env (idType id)
- ty_msg = pprSigmaType ty
- ; add_warn name $
- hang (text "Top-level binding with no type signature:")
- 2 (pprPrefixName name <+> dcolon <+> ty_msg) }
-
- add_warn name msg
- = when (name `elemNameSet` sig_ns && export_check name)
- (addDiagnosticAt (WarningWithFlag flag) (getSrcSpan name) msg)
-
- export_check name
- = warn_missing_sigs || not warn_only_exported || name `elemNameSet` exports
+ = when (warn_pat_syns || warn_exported_pat_syns)
+ (mapM_ add_pat_syn_warn pat_syns) >>
+ when (warn_binds || warn_exported_binds)
+ (mapM_ add_bind_warn binds)
+
+ add_pat_syn_warn p
+ = when export_check $
+ add_warn name flag $
+ hang (text "Pattern synonym with no type signature:")
+ 2 (text "pattern" <+> pprPrefixName name <+> dcolon <+> pp_ty)
+ where
+ name = patSynName p
+ pp_ty = pprPatSynType p
+ export_check = warn_pat_syns || name `elemNameSet` exports
+ flag | warn_pat_syns
+ = Opt_WarnMissingPatternSynonymSignatures
+ | otherwise
+ = Opt_WarnMissingExportedPatternSynonymSignatures
+
+ add_bind_warn :: Id -> IOEnv (Env TcGblEnv TcLclEnv) ()
+ add_bind_warn id
+ = do { env <- tcInitTidyEnv -- Why not use emptyTidyEnv?
+ ; let (_, ty) = tidyOpenType env (idType id)
+ ty_msg = pprSigmaType ty
+
+ ; when export_check $
+ add_warn name flag $
+ hang (text "Top-level binding with no type signature:")
+ 2 (pprPrefixName name <+> dcolon <+> ty_msg) }
+ where
+ name = idName id
+ export_check = warn_binds || name `elemNameSet` exports
+ flag | warn_binds
+ = Opt_WarnMissingSignatures
+ | otherwise
+ = Opt_WarnMissingExportedSignatures
+
+ add_warn name flag msg
+ = when not_ghc_generated
+ (addDiagnosticAt (WarningWithFlag flag) (getSrcSpan name) msg)
+ where
+ not_ghc_generated
+ = name `elemNameSet` sig_ns
; add_sig_warns }
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst
index f34d4c7ca2..dc21cd468f 100644
--- a/docs/users_guide/using-warnings.rst
+++ b/docs/users_guide/using-warnings.rst
@@ -1204,6 +1204,24 @@ of ``-W(no-)*``.
This option is off by default.
+.. ghc-flag:: -Wmissing-exported-pattern-synonym-signatures
+ :shortdesc: warn about pattern synonyms without signatures, only if they
+ are exported
+ :type: dynamic
+ :reverse: -Wno-missing-exported-pattern-synonym-signatures
+ :category:
+
+ .. index::
+ single: type signatures, missing, pattern synonyms
+
+ If you would like GHC to check that every exported pattern synonym has a
+ type signature, but not check unexported pattern synonyms, use the
+ :ghc-flag:`-Wmissing-exported-pattern-synonym-signatures` option. If this
+ option is used in conjunction with
+ :ghc-flag:`-Wmissing-pattern-synonym-signatures` then every pattern synonym
+ must have a type signature. As part of the warning GHC also reports the
+ inferred type. The option is off by default.
+
.. ghc-flag:: -Wname-shadowing
:shortdesc: warn when names are shadowed
:type: dynamic
diff --git a/testsuite/tests/warnings/should_compile/T14794a.hs b/testsuite/tests/warnings/should_compile/T14794a.hs
index 224eaf64f7..216ef832b3 100644
--- a/testsuite/tests/warnings/should_compile/T14794a.hs
+++ b/testsuite/tests/warnings/should_compile/T14794a.hs
@@ -1,31 +1,16 @@
{-# LANGUAGE PatternSynonyms #-}
-{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures #-}
+{-# OPTIONS_GHC -Wmissing-signatures #-}
-module T14794a (test1, pattern Test2, test3, pattern Test4) where
+module T14794a (testExported, pattern TestExported) where
--- This should generate warnings with;
--- -Wmissing-signatures -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+-- These should generate warnings:
-test3 = True
+testExported = True
-pattern Test4 <- True
+testUnexported = True
-test7 = True
+-- These should not generate warnings:
-pattern Test8 <- True
+pattern TestExported <- 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
+pattern TestUnexported <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794a.stderr b/testsuite/tests/warnings/should_compile/T14794a.stderr
index 166d59ab37..807a070350 100644
--- a/testsuite/tests/warnings/should_compile/T14794a.stderr
+++ b/testsuite/tests/warnings/should_compile/T14794a.stderr
@@ -1,12 +1,6 @@
-T14794a.hs:9:1: warning: [-Wmissing-signatures (in -Wall)]
- Top-level binding with no type signature: test3 :: Bool
+T14794a.hs:8:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: testExported :: 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
+T14794a.hs:10:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: testUnexported :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794b.hs b/testsuite/tests/warnings/should_compile/T14794b.hs
index 7c542b4dc1..90501d0fa7 100644
--- a/testsuite/tests/warnings/should_compile/T14794b.hs
+++ b/testsuite/tests/warnings/should_compile/T14794b.hs
@@ -1,31 +1,16 @@
{-# LANGUAGE PatternSynonyms #-}
-{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-exported-signatures #-}
+{-# OPTIONS_GHC -Wmissing-exported-signatures #-}
-module T14794b (test1, pattern Test2, test3, pattern Test4) where
+module T14794b (testExported, pattern TestExported) where
--- This should generate warnings with;
--- -Wmissing-signatures -Wmissing-exported-signatures
+-- These should generate warnings:
-test3 = True
+testExported = True
-pattern Test4 <- True
+-- These should not generate warnings:
-test7 = True
+testUnexported = True
-pattern Test8 <- True
+pattern TestExported <- 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
+pattern TestUnexported <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794b.stderr b/testsuite/tests/warnings/should_compile/T14794b.stderr
index 6109a4c985..8f7f7e805b 100644
--- a/testsuite/tests/warnings/should_compile/T14794b.stderr
+++ b/testsuite/tests/warnings/should_compile/T14794b.stderr
@@ -1,12 +1,3 @@
-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
+T14794b.hs:8:1: warning: [-Wmissing-exported-signatures]
+ Top-level binding with no type signature: testExported :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794c.hs b/testsuite/tests/warnings/should_compile/T14794c.hs
index 742ca3c91c..fd30cfdfcd 100644
--- a/testsuite/tests/warnings/should_compile/T14794c.hs
+++ b/testsuite/tests/warnings/should_compile/T14794c.hs
@@ -1,31 +1,16 @@
{-# LANGUAGE PatternSynonyms #-}
-{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-pattern-synonym-signatures #-}
+{-# OPTIONS_GHC -Wmissing-signatures -Wmissing-exported-signatures #-}
-module T14794c (test1, pattern Test2, test3, pattern Test4) where
+module T14794c (testExported, pattern TestExported) where
--- This should generate warnings with;
--- -Wmissing-signatures -Wmissing-pattern-synonym-signatures
+-- These should generate warnings:
-test3 = True
+testExported = True
-pattern Test4 <- True
+testUnexported = True
-test7 = True
+-- These should not generate warnings:
-pattern Test8 <- True
+pattern TestExported <- 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
+pattern TestUnexported <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794c.stderr b/testsuite/tests/warnings/should_compile/T14794c.stderr
index 95cbb4d16f..413eea960f 100644
--- a/testsuite/tests/warnings/should_compile/T14794c.stderr
+++ b/testsuite/tests/warnings/should_compile/T14794c.stderr
@@ -1,12 +1,6 @@
-T14794c.hs:9:1: warning: [-Wmissing-signatures (in -Wall)]
- Top-level binding with no type signature: test3 :: Bool
+T14794c.hs:8:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: testExported :: 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
+T14794c.hs:10:1: warning: [-Wmissing-signatures (in -Wall)]
+ Top-level binding with no type signature: testUnexported :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794d.hs b/testsuite/tests/warnings/should_compile/T14794d.hs
index 8928df75d3..bb9913e6d9 100644
--- a/testsuite/tests/warnings/should_compile/T14794d.hs
+++ b/testsuite/tests/warnings/should_compile/T14794d.hs
@@ -1,31 +1,16 @@
{-# LANGUAGE PatternSynonyms #-}
-{-# OPTIONS_GHC -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures #-}
+{-# OPTIONS_GHC -Wmissing-pattern-synonym-signatures #-}
-module T14794d (test1, pattern Test2, test3, pattern Test4) where
+module T14794d (testExported, pattern TestExported) where
--- This should generate warnings with;
--- -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+-- These should generate warnings:
-test3 = True
+pattern TestExported <- True
-pattern Test4 <- True
+pattern TestUnexported <- True
+-- These should not generate warnings:
--- This should not generate warnings with;
--- -Wmissing-exported-signatures -Wmissing-pattern-synonym-signatures
+testExported = True
-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
+testUnexported = True
diff --git a/testsuite/tests/warnings/should_compile/T14794d.stderr b/testsuite/tests/warnings/should_compile/T14794d.stderr
index 3388d17316..61177b520e 100644
--- a/testsuite/tests/warnings/should_compile/T14794d.stderr
+++ b/testsuite/tests/warnings/should_compile/T14794d.stderr
@@ -1,6 +1,8 @@
-T14794d.hs:9:1: warning: [-Wmissing-exported-signatures]
- Top-level binding with no type signature: test3 :: Bool
+T14794d.hs:8:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)]
+ Pattern synonym with no type signature:
+ pattern TestExported :: Bool
-T14794d.hs:11:1: warning: [-Wmissing-exported-signatures]
- Pattern synonym with no type signature: pattern Test4 :: Bool
+T14794d.hs:10:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)]
+ Pattern synonym with no type signature:
+ pattern TestUnexported :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794e.hs b/testsuite/tests/warnings/should_compile/T14794e.hs
index 051cf347d6..b53244de6c 100644
--- a/testsuite/tests/warnings/should_compile/T14794e.hs
+++ b/testsuite/tests/warnings/should_compile/T14794e.hs
@@ -1,31 +1,16 @@
{-# LANGUAGE PatternSynonyms #-}
-{-# OPTIONS_GHC -Wmissing-signatures #-}
+{-# OPTIONS_GHC -Wmissing-exported-pattern-synonym-signatures #-}
-module T14794e (test1, pattern Test2, test3, pattern Test4) where
+module T14794e (testExported, pattern TestExported) where
--- This should generate warnings with;
--- -Wmissing-signatures
+-- These should generate warnings:
-test3 = True
+pattern TestExported <- True
-pattern Test4 <- True
+-- These should not generate warnings:
-test7 = True
+testExported = True
-pattern Test8 <- True
+testUnexported = 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
+pattern TestUnexported <- True
diff --git a/testsuite/tests/warnings/should_compile/T14794e.stderr b/testsuite/tests/warnings/should_compile/T14794e.stderr
index f0e4ddbc4c..b7c70b6e51 100644
--- a/testsuite/tests/warnings/should_compile/T14794e.stderr
+++ b/testsuite/tests/warnings/should_compile/T14794e.stderr
@@ -1,12 +1,4 @@
-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
+T14794e.hs:8:1: warning: [-Wmissing-exported-pattern-synonym-signatures]
+ Pattern synonym with no type signature:
+ pattern TestExported :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794f.hs b/testsuite/tests/warnings/should_compile/T14794f.hs
index c2cf58f174..2ebb7e0235 100644
--- a/testsuite/tests/warnings/should_compile/T14794f.hs
+++ b/testsuite/tests/warnings/should_compile/T14794f.hs
@@ -1,31 +1,16 @@
{-# LANGUAGE PatternSynonyms #-}
-{-# OPTIONS_GHC -Wmissing-exported-signatures #-}
+{-# OPTIONS_GHC -Wmissing-pattern-synonym-signatures -Wmissing-exported-pattern-synonym-signatures #-}
-module T14794f (test1, pattern Test2, test3, pattern Test4) where
+module T14794d (testExported, pattern TestExported) where
--- This should generate warnings with;
--- -Wmissing-exported-signatures
+-- These should generate warnings:
-test3 = True
+pattern TestExported <- True
+pattern TestUnexported <- True
--- This should not generate warnings with;
--- -Wmissing-exported-signatures
+-- These should not generate warnings:
-test1 :: Bool
-test1 = True
+testExported = 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
+testUnexported = True
diff --git a/testsuite/tests/warnings/should_compile/T14794f.stderr b/testsuite/tests/warnings/should_compile/T14794f.stderr
index b751aad98e..fd138d5911 100644
--- a/testsuite/tests/warnings/should_compile/T14794f.stderr
+++ b/testsuite/tests/warnings/should_compile/T14794f.stderr
@@ -1,3 +1,8 @@
-T14794f.hs:9:1: warning: [-Wmissing-exported-signatures]
- Top-level binding with no type signature: test3 :: Bool
+T14794f.hs:8:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)]
+ Pattern synonym with no type signature:
+ pattern TestExported :: Bool
+
+T14794f.hs:10:1: warning: [-Wmissing-pattern-synonym-signatures (in -Wall)]
+ Pattern synonym with no type signature:
+ pattern TestUnexported :: Bool
diff --git a/testsuite/tests/warnings/should_compile/T14794g.hs b/testsuite/tests/warnings/should_compile/T14794g.hs
deleted file mode 100644
index eec2210203..0000000000
--- a/testsuite/tests/warnings/should_compile/T14794g.hs
+++ /dev/null
@@ -1,31 +0,0 @@
-{-# 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
deleted file mode 100644
index abd3bf205d..0000000000
--- a/testsuite/tests/warnings/should_compile/T14794g.stderr
+++ /dev/null
@@ -1,6 +0,0 @@
-
-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/all.T b/testsuite/tests/warnings/should_compile/all.T
index a2b82c9661..849ae5edfa 100644
--- a/testsuite/tests/warnings/should_compile/all.T
+++ b/testsuite/tests/warnings/should_compile/all.T
@@ -4,7 +4,6 @@ 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'])