Commit 66584914 authored by manav's avatar manav Committed by Ben Gamari

Make warning names more consistent

- Replace "Sigs" with "Signatures" in WarningFlag data constructors.
- Replace "PatSyn" with "PatternSynonym" in WarningFlag data
  constructors.
- Deprecate "missing-local-sigs" in favor of "missing-local-signatures".
- Deprecate "missing-exported-sigs" in favor of
  "missing-exported-signatures".
- Deprecate "missing-pat-syn-signatures" in favor of
  "missing-pattern-synonym-signatures".
- Replace "ddump-strsigs" with "ddump-str-signatures"

These complete the tasks that were explicitly mentioned in #11583

Test Plan:
Executed `ghc --show-options` and verified that the flags were changed
as expected.

Reviewers: svenpanne, austin, bgamari

Reviewed By: austin, bgamari

Subscribers: mpickering, thomie

Differential Revision: https://phabricator.haskell.org/D1939

GHC Trac Issues: #11583
parent 673efccb
......@@ -335,7 +335,7 @@ data DumpFlag
| Opt_D_dump_stg
| Opt_D_dump_call_arity
| Opt_D_dump_stranal
| Opt_D_dump_strsigs
| Opt_D_dump_str_signatures
| Opt_D_dump_tc
| Opt_D_dump_types
| Opt_D_dump_rules
......@@ -548,8 +548,8 @@ data WarningFlag =
| Opt_WarnMissingFields
| Opt_WarnMissingImportList
| Opt_WarnMissingMethods
| Opt_WarnMissingSigs
| Opt_WarnMissingLocalSigs
| Opt_WarnMissingSignatures
| Opt_WarnMissingLocalSignatures
| Opt_WarnNameShadowing
| Opt_WarnOverlappingPatterns
| Opt_WarnTypeDefaults
......@@ -588,14 +588,14 @@ data WarningFlag =
| Opt_WarnInlineRuleShadowing
| Opt_WarnTypedHoles
| Opt_WarnPartialTypeSignatures
| Opt_WarnMissingExportedSigs
| Opt_WarnMissingExportedSignatures
| Opt_WarnUntickedPromotedConstructors
| Opt_WarnDerivingTypeable
| Opt_WarnDeferredTypeErrors
| Opt_WarnNonCanonicalMonadInstances -- since 8.0
| Opt_WarnNonCanonicalMonadFailInstances -- since 8.0
| Opt_WarnNonCanonicalMonoidInstances -- since 8.0
| Opt_WarnMissingPatSynSigs -- since 8.0
| Opt_WarnMissingPatternSynonymSignatures -- since 8.0
| Opt_WarnUnrecognisedWarningFlags -- since 8.0
deriving (Eq, Show, Enum)
......@@ -2629,8 +2629,8 @@ dynamic_flags_deps = [
(setDumpFlag Opt_D_dump_call_arity)
, make_ord_flag defGhcFlag "ddump-stranal"
(setDumpFlag Opt_D_dump_stranal)
, make_ord_flag defGhcFlag "ddump-strsigs"
(setDumpFlag Opt_D_dump_strsigs)
, make_ord_flag defGhcFlag "ddump-str-signatures"
(setDumpFlag Opt_D_dump_str_signatures)
, make_ord_flag defGhcFlag "ddump-tc"
(setDumpFlag Opt_D_dump_tc)
, make_ord_flag defGhcFlag "ddump-types"
......@@ -3183,12 +3183,16 @@ wWarningFlagsDeps = [
flagSpec "identities" Opt_WarnIdentities,
flagSpec "missing-fields" Opt_WarnMissingFields,
flagSpec "missing-import-lists" Opt_WarnMissingImportList,
flagSpec "missing-local-sigs" Opt_WarnMissingLocalSigs,
depFlagSpec "missing-local-sigs" Opt_WarnMissingLocalSignatures
"it is replaced by -Wmissing-local-signatures",
flagSpec "missing-local-signatures" Opt_WarnMissingLocalSignatures,
flagSpec "missing-methods" Opt_WarnMissingMethods,
flagSpec "missing-monadfail-instances" Opt_WarnMissingMonadFailInstances,
flagSpec "semigroup" Opt_WarnSemigroup,
flagSpec "missing-signatures" Opt_WarnMissingSigs,
flagSpec "missing-exported-sigs" Opt_WarnMissingExportedSigs,
flagSpec "missing-signatures" Opt_WarnMissingSignatures,
depFlagSpec "missing-exported-sigs" Opt_WarnMissingExportedSignatures
"it is replaced by -Wmissing-exported-signatures",
flagSpec "missing-exported-signatures" Opt_WarnMissingExportedSignatures,
flagSpec "monomorphism-restriction" Opt_WarnMonomorphism,
flagSpec "name-shadowing" Opt_WarnNameShadowing,
flagSpec "noncanonical-monad-instances"
......@@ -3225,7 +3229,8 @@ wWarningFlagsDeps = [
flagSpec "unused-type-patterns" Opt_WarnUnusedTypePatterns,
flagSpec "warnings-deprecations" Opt_WarnWarningsDeprecations,
flagSpec "wrong-do-bind" Opt_WarnWrongDoBind,
flagSpec "missing-pat-syn-signatures" Opt_WarnMissingPatSynSigs,
flagSpec "missing-pattern-synonym-signatures"
Opt_WarnMissingPatternSynonymSignatures,
flagSpec "unrecognised-warning-flags" Opt_WarnUnrecognisedWarningFlags ]
-- | These @-\<blah\>@ flags can all be reversed with @-no-\<blah\>@
......@@ -3798,13 +3803,13 @@ minusWallOpts
= minusWOpts ++
[ Opt_WarnTypeDefaults,
Opt_WarnNameShadowing,
Opt_WarnMissingSigs,
Opt_WarnMissingSignatures,
Opt_WarnHiShadows,
Opt_WarnOrphans,
Opt_WarnUnusedDoBind,
Opt_WarnTrustworthySafe,
Opt_WarnUntickedPromotedConstructors,
Opt_WarnMissingPatSynSigs
Opt_WarnMissingPatternSynonymSignatures
]
-- | Things you get with -Weverything, i.e. *all* known warnings flags
......
......@@ -1480,7 +1480,7 @@ reportUnusedNames _export_decls gbl_env
= do { traceRn ((text "RUN") <+> (ppr (tcg_dus gbl_env)))
; warnUnusedImportDecls gbl_env
; warnUnusedTopBinds unused_locals
; warnMissingSigs gbl_env }
; warnMissingSignatures gbl_env }
where
used_names :: NameSet
used_names = findUses (tcg_dus gbl_env) emptyNameSet
......@@ -1556,8 +1556,8 @@ warnUnusedImportDecls gbl_env
printMinimalImports usage }
-- | Warn the user about top level binders that lack type signatures.
warnMissingSigs :: TcGblEnv -> RnM ()
warnMissingSigs gbl_env
warnMissingSignatures :: TcGblEnv -> RnM ()
warnMissingSignatures gbl_env
= do { let exports = availsToNameSet (tcg_exports gbl_env)
sig_ns = tcg_sigs gbl_env
binds = tcg_binds gbl_env
......@@ -1565,9 +1565,9 @@ warnMissingSigs gbl_env
-- Warn about missing signatures
-- Do this only when we we have a type to offer
; warn_missing_sigs <- woptM Opt_WarnMissingSigs
; warn_only_exported <- woptM Opt_WarnMissingExportedSigs
; warn_pat_syns <- woptM Opt_WarnMissingPatSynSigs
; warn_missing_sigs <- woptM Opt_WarnMissingSignatures
; warn_only_exported <- woptM Opt_WarnMissingExportedSignatures
; warn_pat_syns <- woptM Opt_WarnMissingPatternSynonymSignatures
; let sig_warn
| warn_only_exported = topSigWarnIfExported exports sig_ns
......
......@@ -48,7 +48,8 @@ dmdAnalProgram :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram
dmdAnalProgram dflags fam_envs binds
= do {
let { binds_plus_dmds = do_prog binds } ;
dumpIfSet_dyn dflags Opt_D_dump_strsigs "Strictness signatures" $
dumpIfSet_dyn dflags Opt_D_dump_str_signatures
"Strictness signatures" $
dumpStrSig binds_plus_dmds ;
return binds_plus_dmds
}
......
......@@ -706,7 +706,7 @@ mkExport prag_fn qtvs theta
else addErrCtxtM (mk_impedence_match_msg mono_info sel_poly_ty poly_ty) $
tcSubType_NC sig_ctxt sel_poly_ty (mkCheckExpType poly_ty)
; warn_missing_sigs <- woptM Opt_WarnMissingLocalSigs
; warn_missing_sigs <- woptM Opt_WarnMissingLocalSignatures
; when warn_missing_sigs $ localSigWarn poly_id mb_sig
; return (ABE { abe_wrap = wrap
......@@ -855,12 +855,12 @@ localSigWarn :: Id -> Maybe TcIdSigInfo -> TcM ()
localSigWarn id mb_sig
| Just _ <- mb_sig = return ()
| not (isSigmaTy (idType id)) = return ()
| otherwise = warnMissingSig msg id
| otherwise = warnMissingSignatures msg id
where
msg = text "Polymorphic local binding with no type signature:"
warnMissingSig :: SDoc -> Id -> TcM ()
warnMissingSig msg id
warnMissingSignatures :: SDoc -> Id -> TcM ()
warnMissingSignatures msg id
= do { env0 <- tcInitTidyEnv
; let (env1, tidy_ty) = tidyOpenType env0 (idType id)
; addWarnTcM (env1, mk_msg tidy_ty) }
......
......@@ -271,9 +271,10 @@ Compiler
warnings makes sure the definition of ``Semigroup`` as a superclass of
``Monoid`` does not break any code.
- Added the :ghc-flag:`-Wmissing-pat-syn-signatures` flag. When enabled, this will issue
a warning when a pattern synonym definition doesn't have a type signature.
It is turned off by default but enabled by :ghc-flag:`-Wall`.
- Added the :ghc-flag:`-Wmissing-pattern-synonym-signatures`
flag. When enabled, this will issue a warning when a pattern
synonym definition doesn't have a type signature. It is turned off
by default but enabled by :ghc-flag:`-Wall`.
- Added the :ghc-flag:`-Wunused-type-patterns` flag to report unused
type variables in data and type family instances. This flag is not implied
......@@ -310,6 +311,15 @@ Compiler
typecheck, ``Control.Exception.TypeError`` will now be thrown instead of
``Control.Exception.ErrorCall``.
- :ghc-flag:`-Wmissing-local-sigs` is now deprecated in favor of
:ghc-flag:`-Wmissing-local-signatures`.
- :ghc-flag:`-Wmissing-exported-sigs` is now deprecated in favor of
:ghc-flag:`-Wmissing-exported-signatures`.
- :ghc-flag:`-ddump-strsigs` has been renamed to
:ghc-flag:`-ddump-str-signatures`.
GHCi
~~~~
......
......@@ -105,7 +105,7 @@ Dumping out compiler intermediate structures
Dump strictness analyser output
.. ghc-flag:: -ddump-strsigs
.. ghc-flag:: -ddump-str-signatures
Dump strictness signatures
......
......@@ -62,8 +62,8 @@ The following flags are simple ways to select standard "packages" of warnings:
* :ghc-flag:`-Wincomplete-record-updates`
* :ghc-flag:`-Wmonomorphism-restriction`
* :ghc-flag:`-Wimplicit-prelude`
* :ghc-flag:`-Wmissing-local-sigs`
* :ghc-flag:`-Wmissing-exported-sigs`
* :ghc-flag:`-Wmissing-local-signatures`
* :ghc-flag:`-Wmissing-exported-signatures`
* :ghc-flag:`-Wmissing-import-lists`
* :ghc-flag:`-Widentities`
......@@ -595,35 +595,54 @@ of ``-W(no-)*``.
.. ghc-flag:: -Wmissing-exported-sigs
.. index::
single: type signatures, missing
This option is now deprecated in favour of
:ghc-flag:`-Wmissing-exported-signatures`.
.. ghc-flag:: -Wmissing-exported-signatures
.. index::
single: type signatures, missing
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-sigs` option. This option
takes precedence over :ghc-flag:`-Wmissing-signatures`. As part of the
warning GHC also reports the inferred type. The option is off by
default.
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
reports the inferred type. The option is off by default.
.. ghc-flag:: -Wmissing-local-sigs
.. index::
single: type signatures, missing
If you use the :ghc-flag:`-Wmissing-local-sigs` flag GHC will warn you
about any polymorphic local bindings. As part of the warning GHC
also reports the inferred type. The option is off by default.
This option is now deprecated in favour of
:ghc-flag:`-Wmissing-local-signatures`.
.. ghc-flag:: -Wmissing-local-signatures
.. index::
single: type signatures, missing
If you use the :ghc-flag:`-Wmissing-local-signatures` flag GHC
will warn you about any polymorphic local bindings. As part of the
warning GHC also reports the inferred type. The option is off by
default.
.. ghc-flag:: -Wmissing-pat-syn-signatures
.. ghc-flag:: -Wmissing-pattern-synonym-signatures
.. index::
single: type signatures, missing, pattern synonyms
If you would like GHC to check that every pattern synonym has a type
signature, use the :ghc-flag:`-Wmissing-pat-syn-signatures` option. If this option is
used in conjunction with :ghc-flag:`-Wmissing-exported-sigs` then only
exported pattern synonyms must have a type signature. GHC also reports the
inferred type. This option is off by default.
If you would like GHC to check that every pattern synonym has a
type signature, use the
:ghc-flag:`-Wmissing-pattern-synonym-signatures` option. If this
option is used in conjunction with
:ghc-flag:`-Wmissing-exported-signatures` then only exported pattern
synonyms must have a type signature. GHC also reports the inferred
type. This option is off by default.
.. ghc-flag:: -Wname-shadowing
......
{-# LANGUAGE PatternSynonyms #-}
-- turn on with -fwarn-missing-pat-syn-signatures
-- turn on with -fwarn-missing-pattern-synonym-signatures
module Foo where
......
......@@ -26,6 +26,6 @@ test('poly-export-fail2', expect_broken(10653), compile_fail, [''])
test('export-super-class-fail', expect_broken(10653), compile_fail, [''])
test('export-type-synonym', normal, compile_fail, [''])
test('export-ps-rec-sel', normal, compile_fail, [''])
test('T11053', normal, compile, ['-fwarn-missing-pat-syn-signatures'])
test('T11053', normal, compile, ['-fwarn-missing-pattern-synonym-signatures'])
test('T10426', normal, compile_fail, [''])
test('T11265', normal, compile_fail, [''])
# This directory contains tests where we annotate functions with expected
# type signatures, and verify that these actually those found by the compiler
setTestOpts(extra_hc_opts('-ddump-strsigs'))
setTestOpts(extra_hc_opts('-ddump-str-signatures'))
# We are testing the result of an optimization, so no use
# running them in various runtimes
......
{-# OPTIONS_GHC -fwarn-missing-exported-sigs #-}
{-# OPTIONS_GHC -fwarn-missing-exported-signatures #-}
module Bug (Data.List.intercalate, x) where
......
# -fwarn-missing-exported-sigs should take precedence over -fwarn-missing-signatures
test('T2526', normal, compile, ['-fwarn-missing-signatures -fwarn-missing-exported-sigs'])
# -fwarn-missing-exported-signatures should take precedence over -fwarn-missing-signatures
test('T2526', normal, compile, ['-fwarn-missing-signatures -fwarn-missing-exported-signatures'])
test('T9178', extra_clean(['T9178.o', 'T9178DataType.o',
'T9178.hi', 'T9178DataType.hi']),
multimod_compile, ['T9178', '-Wall'])
test('T9230', normal, compile_without_flag('-fno-warn-tabs'), [''])
test('T10908', normal, compile, [''])
test('T11077', normal, compile, ['-fwarn-missing-exported-sigs'])
test('T11077', normal, compile, ['-fwarn-missing-exported-signatures'])
test('T11128', normal, compile, [''])
test('T11128b', normal, compile, [''])
test('PluralS', normal, compile, [''])
......
......@@ -120,7 +120,7 @@ compilerDebuggingOptions =
, flagDescription = "Dump strictness analyser output"
, flagType = DynamicFlag
}
, flag { flagName = "-ddump-strsigs"
, flag { flagName = "-ddump-str-signatures"
, flagDescription = "Dump strictness signatures"
, flagType = DynamicFlag
}
......
......@@ -141,17 +141,32 @@ warningsOptions =
}
, flag { flagName = "-Wmissing-exported-sigs"
, flagDescription =
"*(deprecated)* "++
"warn about top-level functions without signatures, only if they "++
"are exported. takes precedence over -Wmissing-signatures"
, flagType = DynamicFlag
, flagReverse = "-Wno-missing-exported-sigs"
}
, flag { flagName = "-Wmissing-exported-signatures"
, flagDescription =
"warn about top-level functions without signatures, only if they "++
"are exported. takes precedence over -Wmissing-signatures"
, flagType = DynamicFlag
, flagReverse = "-Wno-missing-exported-signatures"
}
, flag { flagName = "-Wmissing-local-sigs"
, flagDescription =
"*(deprecated)* "++
"warn about polymorphic local bindings without signatures"
, flagType = DynamicFlag
, flagReverse = "-Wno-missing-local-sigs"
}
, flag { flagName = "-Wmissing-local-signatures"
, flagDescription =
"warn about polymorphic local bindings without signatures"
, flagType = DynamicFlag
, flagReverse = "-Wno-missing-local-signatures"
}
, flag { flagName = "-Wmissing-monadfail-instances"
, flagDescription =
"warn when a failable pattern is used in a do-block that does " ++
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment