shahn
shahn

Reputation: 617

Can ghc treat certain specified warnings as errors and others as warnings?

Can ghc somehow be convinced to treat certain types of warnings as errors and others as warnings, while still reporting them?

I hoped, this would be possible with something like this:

ghc -Werror -fwarn-missing-methods -Wwarn -fwarn-missing-signatures

, but I had no luck with that. (I think gcc doesn't support this either.)

Upvotes: 12

Views: 817

Answers (3)

Alex R
Alex R

Reputation: 2221

Note that starting GHC 8.2.1, this feature exists! It was described by Trac ticket #11219 and now you can do ghc -Werror=missing-methods -Wmissing-signatures!

Upvotes: 8

Don Stewart
Don Stewart

Reputation: 137947

If this is of great concern, you could consider enabling and disabling warnings on a per-module basis. So that in some modules you'd have:

 {-# OPTIONS_GHC -Wall -Werror #-}

to here about everything, while in others:

 {-# OPTIONS_GHC -w -Werror -fwarn-missing-methods #-}

to only enable some things as errors.

Upvotes: 2

hammar
hammar

Reputation: 139840

No, it's an all-or-nothing switch. However, you can do

ghc -Werror -fwarn-missing-methods -fno-warn-missing-signatures

Although this causes GHC to swallow the warning completely, which might not be what you wanted.

Upvotes: 5

Related Questions