Commit 2206fa8c authored by quchen's avatar quchen Committed by Herbert Valerio Riedel

Add `-W(no-)xxx` aliases for `-f(no-)warn-xxx` flags

This also updates the user's guide to refer to the `-W`-based warning
flags by default.

Quoting the release note entry:

| Warnings can now be controlled with `-W(no-)...` flags in addition to
| the old `-f(no-)warn...` ones. This was done as the first part of a
| rewrite of the warning system to provide better control over warnings,
| better warning messages, and more common syntax compared to other
| compilers. The old `-fwarn...`-based warning flags will remain
| functional for the forseeable future.

This is part of
https://ghc.haskell.org/wiki/Design/Warnings
and addresses #11218

Reviewed By: hvr, bgamari

Differential Revision: https://phabricator.haskell.org/D1613
parent 3a48e6ef
......@@ -48,7 +48,8 @@ module DynFlags (
PkgConfRef(..),
Option(..), showOpt,
DynLibLoader(..),
fFlags, fWarningFlags, fLangFlags, xFlags,
fFlags, fLangFlags, xFlags,
wWarningFlags,
dynFlagDependencies,
tablesNextToCode, mkTablesNextToCode,
SigOf, getSigOf,
......@@ -503,7 +504,7 @@ data WarningFlag =
| Opt_WarnUnusedPatternBinds
| Opt_WarnUnusedImports
| Opt_WarnUnusedMatches
| Opt_WarnContextQuantification -- remove in 8.2
| Opt_WarnContextQuantification -- remove in 8.2
| Opt_WarnWarningsDeprecations
| Opt_WarnDeprecatedFlags
| Opt_WarnAMP -- Introduced in GHC 7.8, obsolete since 7.10
......@@ -2610,8 +2611,10 @@ dynamic_flags = [
, defFlag "fno-glasgow-exts"
(NoArg (do disableGlasgowExts
deprecate "Use individual extensions instead"))
, defFlag "fwarn-unused-binds" (NoArg enableUnusedBinds)
, defFlag "fno-warn-unused-binds" (NoArg disableUnusedBinds)
, defFlag "Wunused-binds" (NoArg enableUnusedBinds)
, defFlag "Wno-unused-binds" (NoArg disableUnusedBinds)
, defHiddenFlag "fwarn-unused-binds" (NoArg enableUnusedBinds)
, defHiddenFlag "fno-warn-unused-binds" (NoArg disableUnusedBinds)
------ Safe Haskell flags -------------------------------------------
, defFlag "fpackage-trust" (NoArg setPackageTrust)
......@@ -2622,20 +2625,22 @@ dynamic_flags = [
------ Debugging flags ----------------------------------------------
, defGhcFlag "g" (OptIntSuffix setDebugLevel)
]
++ map (mkFlag turnOn "" setGeneralFlag ) negatableFlags
++ map (mkFlag turnOff "no-" unSetGeneralFlag) negatableFlags
++ map (mkFlag turnOn "d" setGeneralFlag ) dFlags
++ map (mkFlag turnOff "dno-" unSetGeneralFlag) dFlags
++ map (mkFlag turnOn "f" setGeneralFlag ) fFlags
++ map (mkFlag turnOff "fno-" unSetGeneralFlag) fFlags
++ map (mkFlag turnOn "f" setWarningFlag ) fWarningFlags
++ map (mkFlag turnOff "fno-" unSetWarningFlag) fWarningFlags
++ map (mkFlag turnOn "f" setExtensionFlag ) fLangFlags
++ map (mkFlag turnOff "fno-" unSetExtensionFlag) fLangFlags
++ map (mkFlag turnOn "X" setExtensionFlag ) xFlags
++ map (mkFlag turnOff "XNo" unSetExtensionFlag) xFlags
++ map (mkFlag turnOn "X" setLanguage) languageFlags
++ map (mkFlag turnOn "X" setSafeHaskell) safeHaskellFlags
++ map (mkFlag turnOn "" setGeneralFlag ) negatableFlags
++ map (mkFlag turnOff "no-" unSetGeneralFlag ) negatableFlags
++ map (mkFlag turnOn "d" setGeneralFlag ) dFlags
++ map (mkFlag turnOff "dno-" unSetGeneralFlag ) dFlags
++ map (mkFlag turnOn "f" setGeneralFlag ) fFlags
++ map (mkFlag turnOff "fno-" unSetGeneralFlag ) fFlags
++ map (mkFlag turnOn "W" setWarningFlag ) wWarningFlags
++ map (mkFlag turnOff "Wno-" unSetWarningFlag ) wWarningFlags
++ map (mkFlag turnOn "fwarn-" setWarningFlag . hideFlag) wWarningFlags
++ map (mkFlag turnOff "fno-warn-" unSetWarningFlag . hideFlag) wWarningFlags
++ map (mkFlag turnOn "f" setExtensionFlag ) fLangFlags
++ map (mkFlag turnOff "fno-" unSetExtensionFlag) fLangFlags
++ map (mkFlag turnOn "X" setExtensionFlag ) xFlags
++ map (mkFlag turnOff "XNo" unSetExtensionFlag) xFlags
++ map (mkFlag turnOn "X" setLanguage ) languageFlags
++ map (mkFlag turnOn "X" setSafeHaskell ) safeHaskellFlags
++ [ defFlag "XGenerics"
(NoArg (deprecate $
"it does nothing; look into -XDefaultSignatures " ++
......@@ -2740,6 +2745,13 @@ flagHiddenSpec name flag = flagHiddenSpec' name flag nop
flagHiddenSpec' :: String -> flag -> (TurnOnFlag -> DynP ()) -> FlagSpec flag
flagHiddenSpec' name flag act = FlagSpec name flag act HiddenFlag
-- | Hide a 'FlagSpec' from being displayed in @--show-options@.
--
-- This is for example useful for flags that are obsolete, but should not
-- (yet) be deprecated for compatibility reasons.
hideFlag :: FlagSpec a -> FlagSpec a
hideFlag fs = fs { flagSpecGhcMode = HiddenFlag }
mkFlag :: TurnOnFlag -- ^ True <=> it should be turned on
-> String -- ^ The flag prefix
-> (flag -> DynP ()) -- ^ What to do when the flag is found
......@@ -2765,80 +2777,80 @@ useInstead flag turn_on
nop :: TurnOnFlag -> DynP ()
nop _ = return ()
-- | These @-f\<blah\>@ flags can all be reversed with @-fno-\<blah\>@
fWarningFlags :: [FlagSpec WarningFlag]
fWarningFlags = [
-- | These @-W\<blah\>@ flags can all be reversed with @-Wno-\<blah\>@
wWarningFlags :: [FlagSpec WarningFlag]
wWarningFlags = [
-- See Note [Updating flag description in the User's Guide]
-- See Note [Supporting CLI completion]
-- Please keep the list of flags below sorted alphabetically
flagSpec "warn-alternative-layout-rule-transitional"
flagSpec "alternative-layout-rule-transitional"
Opt_WarnAlternativeLayoutRuleTransitional,
flagSpec' "warn-amp" Opt_WarnAMP
flagSpec' "amp" Opt_WarnAMP
(\_ -> deprecate "it has no effect"),
flagSpec' "warn-auto-orphans" Opt_WarnAutoOrphans
flagSpec' "auto-orphans" Opt_WarnAutoOrphans
(\_ -> deprecate "it has no effect"),
flagSpec "warn-deferred-type-errors" Opt_WarnDeferredTypeErrors,
flagSpec "warn-deprecations" Opt_WarnWarningsDeprecations,
flagSpec "warn-deprecated-flags" Opt_WarnDeprecatedFlags,
flagSpec "warn-deriving-typeable" Opt_WarnDerivingTypeable,
flagSpec "warn-dodgy-exports" Opt_WarnDodgyExports,
flagSpec "warn-dodgy-foreign-imports" Opt_WarnDodgyForeignImports,
flagSpec "warn-dodgy-imports" Opt_WarnDodgyImports,
flagSpec "warn-empty-enumerations" Opt_WarnEmptyEnumerations,
flagSpec' "warn-context-quantification" Opt_WarnContextQuantification
flagSpec "deferred-type-errors" Opt_WarnDeferredTypeErrors,
flagSpec "deprecations" Opt_WarnWarningsDeprecations,
flagSpec "deprecated-flags" Opt_WarnDeprecatedFlags,
flagSpec "deriving-typeable" Opt_WarnDerivingTypeable,
flagSpec "dodgy-exports" Opt_WarnDodgyExports,
flagSpec "dodgy-foreign-imports" Opt_WarnDodgyForeignImports,
flagSpec "dodgy-imports" Opt_WarnDodgyImports,
flagSpec "empty-enumerations" Opt_WarnEmptyEnumerations,
flagSpec' "context-quantification" Opt_WarnContextQuantification
(\_ -> deprecate "it is subsumed by an error message that cannot be disabled"),
flagSpec' "warn-duplicate-constraints" Opt_WarnDuplicateConstraints
(\_ -> deprecate "it is subsumed by -fwarn-redundant-constraints"),
flagSpec "warn-redundant-constraints" Opt_WarnRedundantConstraints,
flagSpec "warn-duplicate-exports" Opt_WarnDuplicateExports,
flagSpec "warn-hi-shadowing" Opt_WarnHiShadows,
flagSpec "warn-implicit-prelude" Opt_WarnImplicitPrelude,
flagSpec "warn-incomplete-patterns" Opt_WarnIncompletePatterns,
flagSpec "warn-incomplete-record-updates" Opt_WarnIncompletePatternsRecUpd,
flagSpec "warn-incomplete-uni-patterns" Opt_WarnIncompleteUniPatterns,
flagSpec "warn-inline-rule-shadowing" Opt_WarnInlineRuleShadowing,
flagSpec "warn-identities" Opt_WarnIdentities,
flagSpec "warn-missing-fields" Opt_WarnMissingFields,
flagSpec "warn-missing-import-lists" Opt_WarnMissingImportList,
flagSpec "warn-missing-local-sigs" Opt_WarnMissingLocalSigs,
flagSpec "warn-missing-methods" Opt_WarnMissingMethods,
flagSpec "warn-missing-monadfail-instance" Opt_WarnMissingMonadFailInstance,
flagSpec "warn-semigroup" Opt_WarnSemigroup,
flagSpec "warn-missing-signatures" Opt_WarnMissingSigs,
flagSpec "warn-missing-exported-sigs" Opt_WarnMissingExportedSigs,
flagSpec "warn-monomorphism-restriction" Opt_WarnMonomorphism,
flagSpec "warn-name-shadowing" Opt_WarnNameShadowing,
flagSpec "warn-noncanonical-monad-instances"
flagSpec' "duplicate-constraints" Opt_WarnDuplicateConstraints
(\_ -> deprecate "it is subsumed by -Wredundant-constraints"),
flagSpec "redundant-constraints" Opt_WarnRedundantConstraints,
flagSpec "duplicate-exports" Opt_WarnDuplicateExports,
flagSpec "hi-shadowing" Opt_WarnHiShadows,
flagSpec "implicit-prelude" Opt_WarnImplicitPrelude,
flagSpec "incomplete-patterns" Opt_WarnIncompletePatterns,
flagSpec "incomplete-record-updates" Opt_WarnIncompletePatternsRecUpd,
flagSpec "incomplete-uni-patterns" Opt_WarnIncompleteUniPatterns,
flagSpec "inline-rule-shadowing" Opt_WarnInlineRuleShadowing,
flagSpec "identities" Opt_WarnIdentities,
flagSpec "missing-fields" Opt_WarnMissingFields,
flagSpec "missing-import-lists" Opt_WarnMissingImportList,
flagSpec "missing-local-sigs" Opt_WarnMissingLocalSigs,
flagSpec "missing-methods" Opt_WarnMissingMethods,
flagSpec "missing-monadfail-instance" Opt_WarnMissingMonadFailInstance,
flagSpec "semigroup" Opt_WarnSemigroup,
flagSpec "missing-signatures" Opt_WarnMissingSigs,
flagSpec "missing-exported-sigs" Opt_WarnMissingExportedSigs,
flagSpec "monomorphism-restriction" Opt_WarnMonomorphism,
flagSpec "name-shadowing" Opt_WarnNameShadowing,
flagSpec "noncanonical-monad-instances"
Opt_WarnNonCanonicalMonadInstances,
flagSpec "warn-noncanonical-monoid-instances"
flagSpec "noncanonical-monoid-instances"
Opt_WarnNonCanonicalMonoidInstances,
flagSpec "warn-orphans" Opt_WarnOrphans,
flagSpec "warn-overflowed-literals" Opt_WarnOverflowedLiterals,
flagSpec "warn-overlapping-patterns" Opt_WarnOverlappingPatterns,
flagSpec "warn-missed-specialisations" Opt_WarnMissedSpecs,
flagSpec "warn-all-missed-specialisations" Opt_WarnAllMissedSpecs,
flagSpec' "warn-safe" Opt_WarnSafe setWarnSafe,
flagSpec "warn-trustworthy-safe" Opt_WarnTrustworthySafe,
flagSpec "warn-tabs" Opt_WarnTabs,
flagSpec "warn-type-defaults" Opt_WarnTypeDefaults,
flagSpec "warn-typed-holes" Opt_WarnTypedHoles,
flagSpec "warn-partial-type-signatures" Opt_WarnPartialTypeSignatures,
flagSpec "warn-unrecognised-pragmas" Opt_WarnUnrecognisedPragmas,
flagSpec' "warn-unsafe" Opt_WarnUnsafe setWarnUnsafe,
flagSpec "warn-unsupported-calling-conventions"
flagSpec "orphans" Opt_WarnOrphans,
flagSpec "overflowed-literals" Opt_WarnOverflowedLiterals,
flagSpec "overlapping-patterns" Opt_WarnOverlappingPatterns,
flagSpec "missed-specialisations" Opt_WarnMissedSpecs,
flagSpec "all-missed-specialisations" Opt_WarnAllMissedSpecs,
flagSpec' "safe" Opt_WarnSafe setWarnSafe,
flagSpec "trustworthy-safe" Opt_WarnTrustworthySafe,
flagSpec "tabs" Opt_WarnTabs,
flagSpec "type-defaults" Opt_WarnTypeDefaults,
flagSpec "typed-holes" Opt_WarnTypedHoles,
flagSpec "partial-type-signatures" Opt_WarnPartialTypeSignatures,
flagSpec "unrecognised-pragmas" Opt_WarnUnrecognisedPragmas,
flagSpec' "unsafe" Opt_WarnUnsafe setWarnUnsafe,
flagSpec "unsupported-calling-conventions"
Opt_WarnUnsupportedCallingConventions,
flagSpec "warn-unsupported-llvm-version" Opt_WarnUnsupportedLlvmVersion,
flagSpec "warn-unticked-promoted-constructors"
flagSpec "unsupported-llvm-version" Opt_WarnUnsupportedLlvmVersion,
flagSpec "unticked-promoted-constructors"
Opt_WarnUntickedPromotedConstructors,
flagSpec "warn-unused-do-bind" Opt_WarnUnusedDoBind,
flagSpec "warn-unused-imports" Opt_WarnUnusedImports,
flagSpec "warn-unused-local-binds" Opt_WarnUnusedLocalBinds,
flagSpec "warn-unused-matches" Opt_WarnUnusedMatches,
flagSpec "warn-unused-pattern-binds" Opt_WarnUnusedPatternBinds,
flagSpec "warn-unused-top-binds" Opt_WarnUnusedTopBinds,
flagSpec "warn-warnings-deprecations" Opt_WarnWarningsDeprecations,
flagSpec "warn-wrong-do-bind" Opt_WarnWrongDoBind,
flagSpec "warn-missing-pat-syn-sigs" Opt_WarnMissingPatSynSigs]
flagSpec "unused-do-bind" Opt_WarnUnusedDoBind,
flagSpec "unused-imports" Opt_WarnUnusedImports,
flagSpec "unused-local-binds" Opt_WarnUnusedLocalBinds,
flagSpec "unused-matches" Opt_WarnUnusedMatches,
flagSpec "unused-pattern-binds" Opt_WarnUnusedPatternBinds,
flagSpec "unused-top-binds" Opt_WarnUnusedTopBinds,
flagSpec "warnings-deprecations" Opt_WarnWarningsDeprecations,
flagSpec "wrong-do-bind" Opt_WarnWrongDoBind,
flagSpec "missing-pat-syn-sigs" Opt_WarnMissingPatSynSigs]
-- | These @-\<blah\>@ flags can all be reversed with @-no-\<blah\>@
negatableFlags :: [FlagSpec GeneralFlag]
......@@ -3405,7 +3417,7 @@ enableUnusedBinds = mapM_ setWarningFlag unusedBindsFlags
disableUnusedBinds :: DynP ()
disableUnusedBinds = mapM_ unSetWarningFlag unusedBindsFlags
-- Things you get with -fwarn-unused-binds
-- Things you get with -Wunused-binds
unusedBindsFlags :: [WarningFlag]
unusedBindsFlags = [ Opt_WarnUnusedTopBinds
, Opt_WarnUnusedLocalBinds
......
......@@ -270,8 +270,8 @@ ioMsgMaybe' ioA = do
#ifdef GHCI
hscTcRnLookupRdrName :: HscEnv -> Located RdrName -> IO [Name]
hscTcRnLookupRdrName hsc_env0 rdr_name
= runInteractiveHsc hsc_env0 $
hscTcRnLookupRdrName hsc_env0 rdr_name
= runInteractiveHsc hsc_env0 $
do { hsc_env <- getHscEnv
; ioMsgMaybe $ tcRnLookupRdrName hsc_env rdr_name }
#endif
......@@ -809,8 +809,8 @@ hscFileFrontEnd mod_summary = do
--
-- It used to be that we only did safe inference on modules that had no Safe
-- Haskell flags, but now we perform safe inference on all modules as we want
-- to allow users to set the `-fwarn-safe`, `-fwarn-unsafe` and
-- `-fwarn-trustworthy-safe` flags on Trustworthy and Unsafe modules so that a
-- to allow users to set the `-Wsafe`, `-Wunsafe` and
-- `-Wtrustworthy-safe` flags on Trustworthy and Unsafe modules so that a
-- user can ensure their assumptions are correct and see reasons for why a
-- module is safe or unsafe.
--
......
......@@ -182,7 +182,7 @@ execStmt stmt ExecOptions{..} = do
-- wait on this when a computation is running
statusMVar <- liftIO $ newEmptyMVar
-- Turn off -fwarn-unused-local-binds when running a statement, to hide
-- Turn off -Wunused-local-binds when running a statement, to hide
-- warnings about the implicit bindings we introduce.
let ic = hsc_IC hsc_env -- use the interactive dflags
idflags' = ic_dflags ic `wopt_unset` Opt_WarnUnusedLocalBinds
......
......@@ -178,7 +178,7 @@ data NameMaker
= LamMk -- Lambdas
Bool -- True <=> report unused bindings
-- (even if True, the warning only comes out
-- if -fwarn-unused-matches is on)
-- if -Wunused-matches is on)
| LetMk -- Let bindings, incl top level
-- Do *not* check for unused bindings
......
......@@ -491,7 +491,7 @@ warnMissingAT :: Name -> TcM ()
warnMissingAT name
= do { warn <- woptM Opt_WarnMissingMethods
; traceTc "warn" (ppr name <+> ppr warn)
; warnTc warn -- Warn only if -fwarn-missing-methods
; warnTc warn -- Warn only if -Wmissing-methods
(ptext (sLit "No explicit") <+> text "associated type"
<+> ptext (sLit "or default declaration for ")
<+> quotes (ppr name)) }
......@@ -443,7 +443,7 @@ Consider this (see Trac #1954):
module Bug(P) where
newtype P a = MkP (IO a) deriving Monad
If you compile with -fwarn-unused-binds you do not expect the warning
If you compile with -Wunused-binds you do not expect the warning
"Defined but not used: data consructor MkP". Yet the newtype deriving
code does not explicitly mention MkP, but it should behave as if you
had written
......
......@@ -259,7 +259,7 @@ data ReportErrCtxt
, cec_expr_holes :: HoleChoice -- Holes in expressions
, cec_type_holes :: HoleChoice -- Holes in types
, cec_warn_redundant :: Bool -- True <=> -fwarn-redundant-constraints
, cec_warn_redundant :: Bool -- True <=> -Wredundant-constraints
, cec_suppress :: Bool -- True <=> More important errors have occurred,
-- so create bindings if need be, but
......@@ -590,7 +590,7 @@ maybeReportHoleError ctxt ct err
-- Otherwise this is a typed hole in an expression
| otherwise
= -- If deferring, report a warning only if -fwarn-typed-holds is on
= -- If deferring, report a warning only if -Wtyped-holds is on
case cec_expr_holes ctxt of
HoleError -> reportError err
HoleWarn -> reportWarning err
......
......@@ -340,7 +340,7 @@ How is this implemented? It's complicated! So we'll step through it all:
compilation should fail. These are handled as normal constraint resolution
failures from here-on (see step 6).
Otherwise, we may be inferring safety (or using `-fwarn-unsafe`), and
Otherwise, we may be inferring safety (or using `-Wunsafe`), and
compilation should succeed, but print warnings and/or mark the compiled module
as `-XUnsafe`. In this case, we call `insertSafeOverlapFailureTcS` which adds
the unsafe (but resolved!) constraint to the `inert_safehask` field of
......@@ -350,7 +350,7 @@ How is this implemented? It's complicated! So we'll step through it all:
constraint resolution. Once finished, we call `getSafeOverlapFailures` to
retrieve the list of overlapping instances that were successfully resolved,
but unsafe. Remember, this is only applicable for generating warnings
(`-fwarn-unsafe`) or inferring a module unsafe. `-XSafe` and `-XTrustworthy`
(`-Wunsafe`) or inferring a module unsafe. `-XSafe` and `-XTrustworthy`
cause compilation failure by not resolving the unsafe constraint at all.
`simpl_top` returns a list of unresolved constraints (all types), and resolved
(but unsafe) resolved dictionary constraints.
......
......@@ -160,6 +160,13 @@ Language
Compiler
~~~~~~~~
- Warnings can now be controlled with ``-W(no-)...`` flags in addition to
the old ``-f(no-)warn...`` ones. This was done as the first part of a
rewrite of the warning system to provide better control over warnings,
better warning messages, and more common syntax compared to other
compilers. The old ``-f``-based warning flags will remain functional for
the forseeable future.
- Added the option ``-dth-dec-file``. This dumps out a .th.hs file of
all Template Haskell declarations in a corresponding .hs file. The
idea is that application developers can check this into their
......@@ -184,14 +191,14 @@ Compiler
Enabling ``-fworker-wrapper`` while strictness analysis is disabled (by
``-fno-strictness``) has no effect.
- Added the options ``-fwarn-missed-specialisations`` and
``-fwarn-all-missed-specialisations``. When enabled, the simplifier will
- Added the options ``-Wmissed-specialisations`` and
``-Wall-missed-specialisations``. When enabled, the simplifier will
produce a warning when a overloaded imported function cannot be
specialised (typically due to a missing ``INLINEABLE`` pragma). This
is intended to alert users to cases where they apply ``INLINEABLE`` but
may not get the speed-up they expect.
- Added the option ``-fwarn-noncanonical-monad-instances`` which helps
- Added the option ``-Wnoncanonical-monad-instances`` which helps
detect noncanonical ``Applicative``/``Monad`` instance definitions.
See flag description in :ref:`options-sanity` for more details.
......@@ -204,19 +211,19 @@ Compiler
allows library authors eager to make their code future compatible to adapt
to new features before they even generate warnings.
- Added the ``-fwarn-missing-monadfail-instance`` flag. When enabled, this
- Added the ``-Wmissing-monadfail-instance`` flag. When enabled, this
will issue a warning if a failable pattern is used in a context that does
not have a ``MonadFail`` constraint. This flag represents phase 1 of the
`MonadFail Proposal (MFP)
<https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail>`__.
- Added the ``-fwarn-semigroup`` flag. When enabled, this
- Added the ``-Wsemigroup`` flag. When enabled, this
will issue a warning if a type is an instance of ``Monoid`` but not
``Semigroup``, and when a custom definition ``(<>)`` is made. Fixing these
warnings makes sure the definition of ``Semigroup`` as a superclass of
``Monoid`` does not break any code.
- Added the ``-fwarn-missing-pat-syn-sigs`` flag. When enabled, this will issue
- Added the ``-Wmissing-pat-syn-sigs`` 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 ``-Wall``.
......
......@@ -1372,7 +1372,7 @@ breakpoint. Note: GHC considers the TAB character to have a width of 1,
wherever it occurs; in other words it counts characters, rather than
columns. This matches what some editors do, and doesn't match others.
The best advice is to avoid tab characters in your source code
altogether (see ``-fwarn-tabs`` in :ref:`options-sanity`).
altogether (see ``-Wtabs`` in :ref:`options-sanity`).
If the module is omitted, then the most recently-loaded module is used.
......@@ -2697,11 +2697,11 @@ Setting GHC command-line options in GHCi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Normal GHC command-line options may also be set using ``:set``. For
example, to turn on ``-fwarn-missing-signatures``, you would say:
example, to turn on ``-Wmissing-signatures``, you would say:
::
Prelude> :set -fwarn-missing-signatures
Prelude> :set -Wmissing-signatures
Any GHC command-line option that is designated as dynamic (see the table
in :ref:`flag-reference`), may be set using ``:set``. To unset an
......@@ -2712,7 +2712,7 @@ option, you can set the reverse option:
::
Prelude> :set -fno-warn-incomplete-patterns -XNoMultiParamTypeClasses
Prelude> :set -Wno-incomplete-patterns -XNoMultiParamTypeClasses
:ref:`flag-reference` lists the reverse for each option where
applicable.
......
......@@ -2029,7 +2029,7 @@ example, consider these two candidate definitions of ``absurd``:
We much prefer (B). Why? Because GHC can figure out that
``(True :~: False)`` is an empty type. So (B) has no partiality and GHC
should be able to compile with ``-fwarn-incomplete-patterns``. (Though
should be able to compile with ``-Wincomplete-patterns``. (Though
the pattern match checking is not yet clever enough to do that.) On the
other hand (A) looks dangerous, and GHC doesn't check to make sure that,
in fact, the function can never get called.
......@@ -2156,7 +2156,7 @@ interests of supporting backward compatibility; for example, a newer
version of ``A`` might export ``g``, and you want ``B`` to work in
either case.
The warning ``-fwarn-dodgy-imports``, which is off by default but
The warning ``-Wdodgy-imports``, which is off by default but
included with ``-W``, warns if you hide something that the imported
module does not export.
......@@ -4494,7 +4494,7 @@ methods.
This is
mostly useful in classes whose `minimal set <#minimal-pragma>`__ is
empty, and especially when writing
`generic functions <#generic-programming>`__.
`generic functions <#generic-programming>`__.
As an example, consider a simple pretty-printer class ``SPretty``, which outputs
pretty strings: ::
......@@ -8510,7 +8510,7 @@ example:
newtype Swizzle' = MkSwizzle' (Ord a => [a] -> [a])
As of GHC 7.10, this is deprecated. The
``-fwarn-context-quantification`` flag detects this situation and issues
``-Wcontext-quantification`` flag detects this situation and issues
a warning. In GHC 8.0 this flag was deprecated and declarations such as
``MkSwizzle'`` will cause an out-of-scope error.
......@@ -9264,7 +9264,7 @@ in a partial type signature, informing the programmer of the inferred
type. When the ``-XPartialTypeSignatures`` flag is enabled, the
type-checker will accept the inferred type for each hole, generating
warnings instead of errors. Additionally, these warnings can be silenced
with the ``-fno-warn-partial-type-signatures`` flag.
with the ``-Wno-partial-type-signatures`` flag.
.. _pts-syntax:
......@@ -9563,7 +9563,7 @@ Enabling deferring of type errors
The flag ``-fdefer-type-errors`` controls whether type errors are
deferred to runtime. Type errors will still be emitted as warnings, but
will not prevent compilation. You can use
``-fno-warn-deferred-type-errors`` to suppress these warnings.
``-Wno-deferred-type-errors`` to suppress these warnings.
This flag implies the ``-fdefer-typed-holes`` flag, which enables this
behaviour for `typed holes <#typed-holes>`__. Should you so wish, it is
......@@ -11250,7 +11250,7 @@ library in which one module gathers together and re-exports the exports
of several others.
You can suppress the warnings with the flag
``-fno-warn-warnings-deprecations``.
``-Wno-warnings-deprecations``.
.. _minimal-pragma:
......@@ -11296,10 +11296,10 @@ If no ``MINIMAL`` pragma is given in the class declaration, it is just as if
a pragma ``{-# MINIMAL op1, op2, ..., opn #-}`` was given, where the
``opi`` are the methods (a) that lack a default method in the class
declaration, and (b) whose name that does not start with an underscore
(c.f. ``-fwarn-missing-methods``, :ref:`options-sanity`).
(c.f. ``-Wmissing-methods``, :ref:`options-sanity`).
This warning can be turned off with the flag
``-fno-warn-missing-methods``.
``-Wno-missing-methods``.
.. _inline-noinline-pragma:
......@@ -12143,7 +12143,7 @@ been a better chance that ``f``\'s RULE might fire.
The way to get predictable behaviour is to use a NOINLINE pragma, or an
INLINE[⟨phase⟩] pragma, on ``f``, to ensure that it is not inlined until
its RULEs have had a chance to fire. The warning flag
``-fwarn-inline-rule-shadowing`` (see :ref:`options-sanity`) warns about
``-Winline-rule-shadowing`` (see :ref:`options-sanity`) warns about
this situation.
.. _conlike:
......
......@@ -28,7 +28,7 @@ directories in the system search path.
runghc will try to work out where the boundaries between
``[runghc flags]`` and ``[GHC flags]``, and ``[program args]`` and
``module`` are, but you can use a ``--`` flag if it doesn't get it
right. For example, ``runghc -- -fwarn-unused-bindings Foo`` means
right. For example, ``runghc -- -Wunused-bindings Foo`` means
runghc won't try to use ``warn-unused-bindings`` as the path to GHC, but
instead will pass the flag to GHC. If a GHC flag doesn't start with a
dash then you need to prefix it with ``--ghc-arg=`` or runghc will think
......
......@@ -690,17 +690,17 @@ And one general flag:
And three warning flags:
``-fwarn-unsafe``
``-Wunsafe``
Issue a warning if the module being compiled is regarded to be
unsafe. Should be used to check the safety type of modules when
using safe inference.
``-fwarn-safe``
``-Wsafe``
Issue a warning if the module being compiled is regarded to be safe.
Should be used to check the safety type of modules when using safe
inference.
``-fwarn-trustworthy-safe``
``-Wtrustworthy-safe``
Issue a warning if the module being compiled is marked as
-XTrustworthy but it could instead be marked as
-XSafe , a more informative bound. Can be used to detect once a Safe Haskell
......@@ -742,7 +742,7 @@ taken:
There is a more detailed discussion of the issues involved in
compilation safety and some potential solutions on the
:ghc-wiki:`GHC Wiki <SafeHaskell/SafeCompilation>`.
Additionally, the use of :ref:`annotations <annotation-pragmas>` is forbidden,
as that would allow bypassing Safe Haskell restrictions. See :ghc-ticket:`10826`
for details.
......@@ -1071,9 +1071,9 @@ module:
of the variables, type constructors, or classes that are free in the
left hand side of the rule are declared in ``M``.
If you use the flag ``-fwarn-orphans``, GHC will warn you if you are
If you use the flag ``-Worphans``, GHC will warn you if you are
creating an orphan module. Like any warning, you can switch the warning
off with ``-fno-warn-orphans``, and ``-Werror`` will make the
off with ``-Wno-orphans``, and ``-Werror`` will make the
compilation fail if the warning is issued.
You can identify an orphan module by looking in its interface file,
......
......@@ -130,7 +130,7 @@ Overloaded functions are not your friend:
Give explicit type signatures:
Signatures are the basic trick; putting them on exported, top-level
functions is good software-engineering practice, anyway. (Tip: using
``-fwarn-missing-signatures``-fwarn-missing-signatures option can
``-Wmissing-signatures``-Wmissing-signatures option can
help enforce good signature-practice).
The automatic specialisation of overloaded functions (with ``-O``)
......
This diff is collapsed.
......@@ -98,14 +98,14 @@ Command line options in source files
Sometimes it is useful to make the connection between a source file and
the command-line options it requires quite tight. For instance, if a
Haskell source file deliberately uses name shadowing, it should be
compiled with the ``-fno-warn-name-shadowing`` option. Rather than
compiled with the ``-Wno-name-shadowing`` option. Rather than
maintaining the list of per-file options in a ``Makefile``, it is
possible to do this directly in the source file using the
``OPTIONS_GHC`` :ref:`pragma <options-pragma>`.
::
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -Wno-name-shadowing #-}
module X where
...
......@@ -678,7 +678,7 @@ See also the ``--help``, ``--version``, ``--numeric-version``, and
users should not need to worry about the subtleties here; ``~`` is
probably what you want. Without ``-fprint-equality-relations``, GHC
prints all of these as ``~``.
``-fprint-expanded-synonyms``
.. index::
single: -fprint-expanded-synonyms
......
......@@ -2093,18 +2093,18 @@ showDynFlags show_all dflags = do
showLanguages' show_all dflags
putStrLn $ showSDoc dflags $
text "GHCi-specific dynamic flag settings:" $$
nest 2 (vcat (map (setting gopt) ghciFlags))
nest 2 (vcat (map (setting "-f" "-fno-" gopt) ghciFlags))
putStrLn $ showSDoc dflags $
text "other dynamic, non-language, flag settings:" $$
nest 2 (vcat (map (setting gopt) others))
nest 2 (vcat (map (setting "-f" "-fno-" gopt) others))
putStrLn $ showSDoc dflags $
text "warning settings:" $$
nest 2 (vcat (map (setting wopt) DynFlags.fWarningFlags))
nest 2 (vcat (map (setting "-W" "-Wno-" wopt) DynFlags.wWarningFlags))