Newcomer help (Trac #12056)

Sean Gillespie sean at mistersg.net
Wed May 17 01:02:22 UTC 2017


Howdy,

I started looking at Trac #12056 (https://ghc.haskell.org/trac/ghc/ticket/12056),
but I'm a bit stuck.

Indeed, if I run the following command, I get no warnings

    ghc Main.hs -Wfoo -w -Wunrecognised-warning-flags -Wbar

But if I also specify -Wdeprecated-flags, I get warnings again

    ghc Main.hs -Wfoo -w -Wunrecognised-warning-flags -Wdeprecated-flags -Wbar 

    on the commandline: warning: unrecognised warning flag: -Wfoo 

    on the commandline: warning: unrecognised warning flag: -Wbar

Then I found this little function in compiler/main/HscTypes

    handleFlagWarnings :: DynFlags -> [Located String] -> IO ()
    handleFlagWarnings dflags warns
     = when (wopt Opt_WarnDeprecatedFlags dflags) $ do
            -- It would be nicer if warns :: [Located MsgDoc], but that
            -- has circular import problems.
          let bag = listToBag [ mkPlainWarnMsg dflags loc (text warn)
                              | L loc warn <- warns ]
    
          printOrThrowWarnings dflags bag

So I updated it accept Opt_WarnDeprecatedFlags and Opt_WarnUnrecognisedWarningsFlags.
Complete patch here: https://phabricator.haskell.org/D3581

Unfortunately when I did that, -Wno-deprecated-flags no longer had an effect so long
as -Wunrecognised-warnings-flags

    ./inplace/bin/ghc-stage2 -Wunrecognised-warning-flags -Wno-deprecated-flags -XOverlappingInstances

    on the commandline: warning:
        -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS

And now that is where I'm stuck; I can't seem to find a place where I can distinguish
between the different warning types. Even WarnReason is set to NoReason because of
the usage of mkPlainWarnMsg.

So if I could get some guidance on this, I'd be very grateful.

Thanks
Sean G


More information about the ghc-devs mailing list