Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,324
    • Issues 4,324
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Wiki
    • Design
  • warnings

Last edited by Ben Gamari Apr 01, 2019
Page history New page

warnings

Redesigned GHC Warnings

GHC currently uses a somewhat unsatisfying warning CLI:

-W      (enable normal warnings)
-w      (disable all warnings)
-Wall   (enable almost all warnings)
-Werror (make warnings fatal)
-Wwarn  (make warnings non-fatal)

-Wduplicate-exports
-Widentities
-Wmissing-signatures
-Wunused-binds
...

By reusing the GCC CLI convention for warning-flags, we can make GHC's CLI a bit more intuitive to people used to GCC (& Clang's) CLI.

Changes to be implemented, and timing

Already implemented in GHC 8.0:

  • (#11218 (closed)) Keep the current -f(no-)warn-$WARNTYPE flags as hidden flag aliases for newly introduced -W(no-)$WARNTYPE` flags more in line with GCC's conventions, e.g.

    • -Worphans instead of fwarn-orphans
    • -Wno-missing-methods instead of -fno-warn-missing-methods

    This is already done in GHC 8.0.

  • (#11429 (closed)) Make unrecognised -W flags a warning (-Wunrecognised-warning-flags) rather than an error.

  • (#11370 (closed)) Remove warn-redundant-constraints from the default constraint set and the -Wall constraint set

  • (#11451 (closed)) Split off -Wunused-foralls and -Wunused-type-patterns from -Wunused-matches. Make -Wall imply -Wunused-foralls and -Wunused-type-patterns, but not imply -Wunused-type-patterns

Proposedalso implemented for GHC 8.0:

  • (phab:D1850) Introduce some new warning sets, e.g.

    • Define set -Wstandard (modulo bikeshed, maybe -Wdefault?) to denote the set of warnings on by default, together with its negation -Wno-standard
    • Define set -Weverything (c.f. clang's -Weverything as precedent) to comprise really *all* warnings (together with its negation -Wno-everything for symmetry, which is a synonym for -w)
    • Define set -Wextra (modulo bikeshed, maybe -Wnormal?) as synonym for -W, together with its negation -Wno-extra
    • (#11000 (closed)) Define set -Wcompat to denote all warnings about future compatility GHC currently knows about (like e.g. -Wcompat-amp, -Wcompat-mfp, -Wcompat-mrp) In addition, have ghc provide a way to dump the current warning-sets (in a format that's parseable by humans and machines)
  • (#10752 (closed)) When emitting warnings/errors, show which warning flag was responsible, e.g.

    foo.hs:1:1: Warning:  [-Wmissing-signatures]
      Top-level binding with no type signature: main :: IO ()

    making it easier to silence specific warnings via e.g. -Wno-missing-signatures

Anytime someone is motivated

  • (#11219 (closed)) Introduce variant of -Werror (c.f. GCC's -Werror=*) which allows to specify the individual warnings to be promoted to errors, e.g.

    • -Wall -Werror=orphans would only promote -Worphans warnings into errors
    • -Wall -Werror -Wno-error=missing-methods would promote all warnings except -Wmissing-methods into errors
  • (this is subsumed by -Weverything now)Introduce -Wpedantic, which turns on warnings that -Wall doesn't turn on (e.g., -Wredundant-constraints and -Wunused-type-patterns)

Intended usage of warnings

Here is the proposed warning framework:

  • Intended meanings

    • -Wdefault: the ones you get by default. This indicate things that are almost certainly wrong.
    • -Wall: indicate suspicious code
    • -Wcompat: indicate code that in future releases may trigger errors or -Wdefault warnings. Subset of -Wall.
  • With no flags, GHC implements the "default warnings". You can get these by saying -Wdefault (yet to be implemented).

  • When GHC implements a new warning it is put into the -Weverything set. In the next release, that warning may move into the -Wall set or the -Wdefault set. So libraray authors may want to future-proof their libraries by compiling with -Weverything.

  • A flag should only move into -Wall or -Wdefault if there is a reasonable way for a library author to change their source code to avoid the warning. Experimental, unpredicatable, or compiler-writer-guidance warnings should not be in -Wall.

  • Libraries on Hackage should not be distributed with -Werror, so that any warnings do not abort compilation. Authors may want to use -Wall to help encourage other contributors to improve the library to avoid the warning; but -Wdefault is more typical usage.

To -Wcompat ⊂ -Wall, or not? (#11494 (closed))

See Design/Warnings/Wcompat.

Clone repository

GHC Home
GHC User's Guide

Joining In

Newcomers info
Mailing Lists & IRC
The GHC Team

Documentation

GHC Status Info
Working conventions
Building Guide
Debugging
Commentary

Wiki

Title Index
Recent Changes