Opened 11 months ago

Last modified 10 months ago

#9037 new feature request

Add option to make selected warnings errors

Reported by: nh2 Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.2
Keywords: Cc: mail@…, schyler
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

It would be great if GHC offered a -ferror-* flag for every -fwarn-* flag, that turns the given type of warning into an error.

For example, I would like to always error on uninitialized record fields, but don't want to go full -Werror.

Change History (2)

comment:1 Changed 11 months ago by schyler

The rust compiler has a nice system where you don't need tons and tons of flags for warnings/errors/ignores.

For example:

Kyles-iMac:~ kvanb$ rustc -W

Available lint options:
    -W <foo>           Warn about <foo>
    -A <foo>           Allow <foo>
    -D <foo>           Deny <foo>
    -F <foo>           Forbid <foo> (deny, and deny all overrides)


Available lint checks:

                             name  default  meaning
                             ----  -------  -------

             non-camel-case-types  allow    types, variants and traits should have camel case names
              managed-heap-memory  allow    use of managed (@ type) heap memory
                owned-heap-memory  allow    use of owned (~ type) heap memory
                         unstable  allow    detects use of #[unstable] items (incl. items with no stability attribute)
                      heap-memory  allow    use of any (~ type or @ type) heap memory
        unnecessary-qualification  allow    detects unnecessarily qualified names
            non-uppercase-statics  allow    static constants should have uppercase identifiers
                      missing-doc  allow    detects missing documentation for public members
                     unsafe-block  allow    usage of an `unsafe` block
                 unreachable-code  warn     detects unreachable code
                       deprecated  warn     detects use of #[deprecated] items
                   unused-imports  warn     imports that are never used
                         warnings  warn     mass-change the level for lints which produce warnings
                   path-statement  warn     path statements with no effect
                           ctypes  warn     proper use of std::libc types in foreign modules
                  dead-assignment  warn     detect assignments that will never be read
                    unused-unsafe  warn     unnecessary use of an `unsafe` block
                       unused-mut  warn     detect mut variables which don't need to be mutable
    non-uppercase-pattern-statics  warn     static constants in match patterns should be all caps
                unrecognized-lint  warn     unrecognized lint attribute
                  unused-variable  warn     detect variables which are not used in any way
                        dead-code  warn     detect piece of code that will never be used
           unnecessary-allocation  warn     detects unnecessary allocations that can be eliminated
                  attribute-usage  warn     detects bad use of attributes
                    type-overflow  warn     literal out of range for its type
                      type-limits  warn     comparisons made useless by limits of the types involved
                       while-true  warn     suggest using loop { } instead of while(true) { }
                     experimental  warn     detects use of #[experimental] items
                 unknown-features  deny     unknown features found in create-level #[feature] directives

Maybe a long term goal might be to build something similar-ish. Just a thought.

comment:2 Changed 10 months ago by schyler

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