Skip to content

Clarify documentation of -Wdeprecations vs -Wwarnings-deprecations

The documented and official flag for the warning when a module, function or type with a WARNING or DEPRECATED pragma is used is -fwarn-warnings-deprecations. (See for instance https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_guide/options-sanity.html). If the goal is turn off the warning I use -fno-warn-warnings-deprecations flag. By default -fwarn-warnings-deprecations on.

In the next example shows a warning by using the flag mention above.

$ cat Foo.hs
{-# OPTIONS_GHC -fwarn-warnings-deprecations #-}
import Data.Version (Version(Version, versionBranch, versionTags))
main :: IO ()
main = do
  let v = Version {
          versionBranch = [1,0,0]
        , versionTags = ["beta"]
        }
  return ()

and GHC outputs:

$ ghc Foo.hs
[1 of 1] Compiling Main             ( Foo.hs, Foo.o )

Foo.hs:9:11: warning: [-Wdeprecations]
    In the use of ‘versionTags’ (imported from Data.Version):
    Deprecated: "See GHC ticket #2496"
Linking Foo ...

The first unexcepted behavior is the warning message showed above.

Following the convention the warning message should be:

Foo.hs:9:11: warning: [-Wwarnings-deprecations]

The second unexcepted behavior happened when I used a pragma to silenced the warning warnings-deprecations, I committed the mistake to misspelled it, but surprisingly GHC didn't complaint about the unknown pragma, it seems treated again like a synonymous of -fno-warn-warnings-deprecations in this case.

{-# OPTIONS_GHC -fno-warn-deprecations  #-}
import Data.Version (Version(Version, versionBranch, versionTags))
main :: IO ()
main = do
  let v = Version {
          versionBranch = [1,0,0]
        , versionTags = ["beta"]
        }
  return ()

Searching a little, I found it is not documented the flag -Wdeprecations in recent versions of GHC ( I tested with 7.8.2 too) but it does for instance available in GHC 6.3.0 (See https://manned.org/ghc-cvs/42a4c961) but it actually continues appearing in the source code of the recent GHC. See https://github.com/mlen/ghc/search?utf8=%E2%9C%93&q=deprecations.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC asr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information