
#12056: Too aggressive `-w` option -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #11429, #11789 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie):
It looks like this only happens when -w is combined with `-Wunrecognised-warning-flags`.
To be clear, what I meant by that is that `-w` is too aggressive only when placed before `-Wunrecognised-warning-flags`. When `-w` is combined with other (existing) `-W` flags, GHC does the right thing (take the order in which the flags are passed into account). Here is an example, with `Test.hs` containing: {{{ module Test where import System.FilePath }}} * TEST `-w` BEFORE. `-w` disables all warning flags, but since we supply `-Wunused-imports` afterwards, we *do* get a warning: {{{ $ ghc -w -Wunused-imports -fforce-recomp Test.hs [1 of 1] Compiling Test ( Test.hs, Test.o ) Test.hs:2:1: warning: [-Wunused-imports] The import of ‘System.FilePath’ is redundant except perhaps to import instances from ‘System.FilePath’ To import instances alone, use: import System.FilePath() }}} * TEST `-w` AFTER We give `-Wunused-imports` first. But since we give `-w` afterwards, which reverts the previous flag, we do *not* get a warning: {{{ $ ghc -Wunused-imports -w -fforce-recomp Test.hs }}} Both are expected behavior. == Question What should happen in the following example: {{{ ghc -Wfoo1 -w -Wfoo2 -Wunrecognised-warning-flags -Wfoo3 Main.hs }}} == Option 1 * warn about `-Wfoo` (since `-Wunrecognised-warning-flags` is on by default) * not warn about `-Wfoo2` (since it comes after `-w`) * warn about `-Wfoo3` (since it comes after `-Wunrecognised-warning- flags`) == Option 2 * warn about all `-Wfoo*`, since `-Wunrecognised-warning-flags` came after `-w`, so `-Wunrecognised-warning-flags` is enabled wozgonon: thanks for working on this! I think all these flags are Dynamic though, so I'm not sure that `Note` is relevant. The text "on the commandline" is coming from `ghc/Main.hs` most likely. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12056#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler