[GHC] #10752: Print which warning-flag controls/enabled an emitted warning

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature | Status: new request | Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Both `gcc` and `clang` tell which warning flag a reported warning can be controlled with, e.g. {{{ $ clang-3.5 -Wall -c hello.c hello.c:3:7: warning: unused variable 'x' [-Wunused-variable] int x; ^ 1 warning generated. }}} {{{ $ gcc -Wall -c hello.c hello.c: In function ‘main’: hello.c:3:7: warning: unused variable ‘x’ [-Wunused-variable] int x; ^ hello.c:4:1: warning: control reaches end of non-void function [-Wreturn- type] } ^ }}} With GHC however, we need to lookup the documentation (or memorise all warning flags) to find out which `-fno-warn-*` flag we need to use to silence a specific warning. I propose we augment GHC's warnings in a similar style to how `gcc`/`clang` report flags in compile warnings. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by osa1): * cc: osa1 (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by osa1): This is a great idea and it should be just a straightforward refactoring: - Modify `ErrUtils.makeIntoWarning` to get a `Maybe WarningFlag` as argument. - Modify `ErrUtils.ErrMsg` to record a `WarningFlag`. - Since we want to show flags uniformly in messages, maybe modify `LogAction` to pass this `Maybe WarningFlag`. Then modify `DynFlags.defaultLogAction` to print these flags. - Fix all the compile errors by passing warning flags to `makeIntoWarning`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): +1 from me. I look these up with some frequency. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: quchen Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * owner: => quchen * version: 7.10.2 => * milestone: 8.0.1 => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: quchen Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by hvr): * wikipage: => Design/Warnings -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: quchen Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Comment (by asr): +1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: quchen Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by asr): * cc: asr (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by barrucadu): * owner: quchen => barrucadu -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1934 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by barrucadu): * differential: => Phab:D1934 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1934 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- @@ -30,0 +30,23 @@ + + ----- + + As an obvious extension, (which maybe should be controlled by some `-f` + flag, e.g. `-f(no-)show-warning-groups`), GHC could then also show by + which warning-group a given warning is implied, e.g. + + + {{{ + WCompatWarningsOn.hs:16:1: warning: [-Wsemigroup (in -Wcompat)] + Local definition of ‘<>’ clashes with a future Prelude name. + This will become an error in a future release. + + WCompatWarningsOn.hs:22:3: warning: [-Wnoncanonical-monoid-instances (in + -Wcompat)] + Noncanonical ‘(<>) = mappend’ definition detected + in the instance declaration for ‘Semi.Semigroup S’. + Move definition from ‘mappend’ to ‘(<>)’ + }}} + + For the warning-sets which form a superset chain (Weverything > Wextra > + Wall > Wdefault) we'd only mention the smallest one (and omit the trivial + `-Weverything` set altogether) to keep the output concise. New description: Both `gcc` and `clang` tell which warning flag a reported warning can be controlled with, e.g. {{{ $ clang-3.5 -Wall -c hello.c hello.c:3:7: warning: unused variable 'x' [-Wunused-variable] int x; ^ 1 warning generated. }}} {{{ $ gcc -Wall -c hello.c hello.c: In function ‘main’: hello.c:3:7: warning: unused variable ‘x’ [-Wunused-variable] int x; ^ hello.c:4:1: warning: control reaches end of non-void function [-Wreturn- type] } ^ }}} With GHC however, we need to lookup the documentation (or memorise all warning flags) to find out which `-fno-warn-*` flag we need to use to silence a specific warning. I propose we augment GHC's warnings in a similar style to how `gcc`/`clang` report flags in compile warnings. ----- As an obvious extension, (which maybe should be controlled by some `-f` flag, e.g. `-f(no-)show-warning-groups`), GHC could then also show by which warning-group a given warning is implied, e.g. {{{ WCompatWarningsOn.hs:16:1: warning: [-Wsemigroup (in -Wcompat)] Local definition of ‘<>’ clashes with a future Prelude name. This will become an error in a future release. WCompatWarningsOn.hs:22:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)] Noncanonical ‘(<>) = mappend’ definition detected in the instance declaration for ‘Semi.Semigroup S’. Move definition from ‘mappend’ to ‘(<>)’ }}} For the warning-sets which form a superset chain (Weverything > Wextra > Wall > Wdefault) we'd only mention the smallest one (and omit the trivial `-Weverything` set altogether) to keep the output concise. -- Comment (by hvr): @barrucadu This looks very promising... but have you talked to David (`quchen`) before you took the ticket from him? He had already started working on a warning refactoring in his Github repo afaik (see .e.g. https://github.com/quchen/ghc/commits/warn-refactoring)... PS: I've extended the ticket description with a bonus task -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1934 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Comment (by barrucadu): I had not, no. I assumed that since nothing had been updated here in a few months nobody was actively working on this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1943 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by barrucadu): * differential: Phab:D1934 => Phab:D1943 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1943 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by hvr): * status: new => closed * resolution: => fixed * milestone: 8.2.1 => 8.0.1 Comment: Let's call it a day and declare this ticket's scope done... at least I didn't notice any other warning-flags not being annotated in warnings (but there could still be!). There'll likely be follow-up tickets for evolving this feature in the future. ----- Merged to ghc-8.0 via - 975353bfdfab375cb5c47dc2460792190abac277 - 966cc28ffe1707685cb908753bb6f8fb78fc86c9 - 2ffd9b167a107a82fff42adb22d15b185d8b8757 - 94b2681507db793359b101b945c710e504971556 - 02e91accf082967cd28ad0d081f774117ee3386b - 209143945233726a8cf5c4eb2605a4f8084e5fa0 - 4f5b7ad8fe567bc520e5c1b185beadda9007afea -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: closed
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version:
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Thomas Miedema

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: merge Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1943 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by bgamari): * status: closed => merge Comment: This introduced a small bug which is fixed by Phab:D2077. This will need merging. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:24 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10752: Print which warning-flag controls/enabled an emitted warning
-------------------------------------+-------------------------------------
Reporter: hvr | Owner: barrucadu
Type: feature request | Status: merge
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version:
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1943
Wiki Page: Design/Warnings |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10752: Print which warning-flag controls/enabled an emitted warning -------------------------------------+------------------------------------- Reporter: hvr | Owner: barrucadu Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1943 Wiki Page: Design/Warnings | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed Comment: Merged as 8e672317ddcad936f2dc3c0497499cb50207954e. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10752#comment:26 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC