Opened 12 years ago

Last modified 3 months ago

#602 new task (None)

Warning Suppression

Reported by: simonmar Owned by:
Priority: lowest Milestone:
Component: Compiler Version: None
Keywords: warnings Cc:
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 (30)

comment:1 Changed 11 years ago by simonmar

  • Architecture set to Unknown
  • Description modified (diff)
  • difficulty set to Moderate (1 day)
  • Operating System set to Unknown

comment:2 Changed 10 years ago by igloo

  • Description modified (diff)
  • Milestone set to 6.8
  • Test Case set to N/A

comment:3 Changed 10 years ago by igloo

  • Keywords warnings added

comment:4 Changed 9 years ago by simonmar

  • Milestone changed from 6.8 branch to 6.10 branch

comment:5 Changed 8 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 8 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:7 Changed 7 years ago by igloo

  • Milestone changed from 6.10 branch to 6.12 branch

comment:8 Changed 7 years ago by simonmar

  • difficulty changed from Moderate (1 day) to Moderate (less than a day)

comment:9 Changed 7 years ago by igloo

  • Type of failure set to Other

comment:10 Changed 7 years ago by simonmar

See also #3820

comment:11 Changed 6 years ago by igloo

  • Milestone changed from 6.12 branch to 6.12.3

comment:12 Changed 6 years ago by igloo

  • Milestone changed from 6.12.3 to 6.14.1
  • Priority changed from normal to low

comment:13 Changed 6 years ago by igloo

  • Milestone changed from 7.0.1 to 7.0.2

comment:14 Changed 5 years ago by igloo

  • Milestone changed from 7.0.2 to 7.2.1

comment:15 Changed 5 years ago by igloo

  • Milestone changed from 7.2.1 to 7.4.1

comment:16 Changed 5 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1
  • Priority changed from low to lowest

comment:17 Changed 4 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:18 Changed 2 years ago by thoughtpolice

  • Milestone changed from 7.6.2 to 7.10.1

Moving to 7.10.1.

comment:19 Changed 20 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.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 20 months 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 12 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

comment:22 Changed 10 months ago by edgar.zhavoronkov

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

comment:23 follow-up: Changed 10 months 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 10 months 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 10 months 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 10 months 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 10 months 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 10 months ago by bgamari (previous) (diff)

comment:28 Changed 10 months ago by hvr

  • Wiki Page set to Design/LocalWarningPragmas

comment:29 Changed 7 months ago by thomie

  • Type of failure changed from Other to Incorrect warning at compile-time

comment:30 Changed 7 months ago by thomie

  • Milestone 8.0.1 deleted

Possible use cases:

Last edited 3 months ago by thomie (previous) (diff)
Note: See TracTickets for help on using tickets.