Allow disabling warnings on a per-block of code basis
Haskell developers frequently want to disable a warning, but not for their whole project. Right now the only way to do that is on a per-file basis. This isn't ideal, because it's a pretty broad brush for what is often a warning you only want to disable in one place. The way other compilers solve this is by allowing you to ignore warnings only between two lines in the code. Here's Clang and GCC:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
int a;
#pragma clang diagnostic pop
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
write(foo, bar, baz);
#pragma GCC diagnostic pop
Examples of warnings people may want to ignore only in a certain location:
In yesod-core/yesod/Core.hs, deprecation warnings are disabled for the whole file, but it's not clear what deprecations are trying to be avoided. It's possible that code is no longer relevant.
The tests for the yesod-test
package test a function that yesod-test has deprecated, but still wants to test. Because of this, it ignores all deprecation warnings, when it could be only ignoring them for a few lines.
It's pretty easy to find examples of this; just search a repo for {-# OPTIONS_GHC -fno
and you'll probably find cases where warnings are disabled in a more broad way than is necessary.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |