Opened 13 years ago

Last modified 5 months ago

#602 new task (None)

Warning Suppression

Reported by: simonmar Owned by:
Priority: lowest Milestone:
Component: Compiler Version: None
Keywords: warnings Cc: ntc2
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: N/A
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page: Design/LocalWarningPragmas

Description (last modified by igloo)

It should be possible to suppress particular kinds of warnings for parts of a source file.

One way to achieve this is to allow parts of a file to be delimited by pragmas specifying the warnings to be suppressed, and then filter out the warnings during compilation based on the source location attached to the warning.

Change History (31)

comment:1 Changed 12 years ago by simonmar

Architecture: Unknown
Description: modified (diff)
difficulty: Moderate (1 day)
Operating System: Unknown

comment:2 Changed 11 years ago by igloo

Description: modified (diff)
Milestone: 6.8
Test Case: N/A

comment:3 Changed 11 years ago by igloo

Keywords: warnings added

comment:4 Changed 10 years ago by simonmar

Milestone: 6.8 branch6.10 branch

comment:5 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:6 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:7 Changed 9 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:8 Changed 8 years ago by simonmar

difficulty: Moderate (1 day)Moderate (less than a day)

comment:9 Changed 8 years ago by igloo

Type of failure: Other

comment:10 Changed 8 years ago by simonmar

See also #3820

comment:11 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:12 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:13 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:14 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:15 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:16 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:17 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:18 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:19 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:20 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:21 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:22 Changed 2 years ago by edgar.zhavoronkov

Hi everyone! Do someone know, if there is such pragma or i need to implement it myself?

comment:23 Changed 2 years ago by goldfire

This has not been implemented. You're welcome to try to specify this feature concretely and try to put together a patch!

The specification comes first. :)

comment:24 in reply to:  23 Changed 2 years ago by edgar.zhavoronkov

Replying to goldfire:

This has not been implemented. You're welcome to try to specify this feature concretely and try to put together a patch!

The specification comes first. :)

Wrote some sort of informal specification with couple of use cases https://ghc.haskell.org/trac/ghc/wiki/Design/LocalWarningPragmas

comment:25 Changed 2 years ago by bgamari

One point in the design space that anyone thinking about this should probably be aware of is that taken by Rust.

comment:26 Changed 2 years ago by goldfire

And Rust's support reminds me very much of Java's.

Both Rust and Java support warning suppression (or, for Rust, generation) based on scopes. Is that reasonable for Haskell? Maybe. We would continue to allow OPTIONS to specify flags for the whole file, but we could then also support local flags for definitions (or parts of definitions). The one thing this design wouldn't allow is setting warning suppression for a whole bunch of definitions (but not all). That may be an acceptable tradeoff.

While we're thinking about this, it might be reasonable to consider adding arbitrary option-changes locally. (For example, I'd love to be able to turn on LANGUAGE pragmas only for part of a file.)

comment:27 Changed 2 years ago by thomie

Jeremy mentions in https://mail.haskell.org/pipermail/libraries/2015-October/026376.html:

.NET has a very flexible system for suppressing code analysis warnings, it may be informative for formulating a GHC solution.

https://msdn.microsoft.com/en-us/library/ms244717.aspx

Last edited 2 years ago by bgamari (previous) (diff)

comment:28 Changed 2 years ago by hvr

Wiki Page: Design/LocalWarningPragmas

comment:29 Changed 22 months ago by thomie

Type of failure: OtherIncorrect warning at compile-time

comment:30 Changed 22 months ago by thomie

Milestone: 8.0.1

Possible use cases:

Last edited 18 months ago by thomie (previous) (diff)

comment:31 Changed 5 months ago by ntc2

Cc: ntc2 added
Note: See TracTickets for help on using tickets.