Opened 20 months ago

Last modified 10 months ago

#14794 new bug

-Weverything should not enable -Wmissing-exported-signatures

Reported by: MaxGabriel Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.2.1
Keywords: Cc: quasicomputational
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect error/warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The -Weverything compiler flag enables every compiler warning. That includes -Wmissing-exported-signatures, which disables -Wmissing-signatures (With -Wmissing-signatures, every top-level binding without a signature generates a warning, with -Wmissing-exported-signatures, only exported bindings generate a warning).

While technically "every warning" includes -Wmissing-exported-signatures, I don't think this matches how people use -Weverything. At least personally I think of it as "-Wall isn't enough, give me the strictest possible warning settings", but actually -Weverything can have fewer warnings than -Wall because of -Wmissing-exported-signatures.

Example reproduction case:

-- Main.hs
{-# LANGUAGE Safe #-}

module Main (main) where

import Prelude (IO, putStrLn, show, ($))
import Foo (foo)

main :: IO ()
main = putStrLn $ show foo

-- Foo.hs
{-# LANGUAGE Safe #-}

module Foo (foo) where

import Prelude (Integer)

foo :: Integer
foo = bar

bar = (1 :: Integer)

Expected: when compiling with -Weverything, I get a superset of -Wall's warnings. Actual:

Actual -Wall:

maximiliantagher@Maximilians-MacBook-Pro ~/D/C/H/ghc-warning> ghc -Wall Main.hs Foo.hs
[1 of 2] Compiling Foo              ( Foo.hs, Foo.o )

Foo.hs:10:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: bar :: Integer
   |
10 | bar = (1 :: Integer)
   | ^^^
[2 of 2] Compiling Main             ( Main.hs, Main.o )
Linking Main ...

Actual -Weverything (note: you should remove run rm main.o main.hi main Foo.o Foo.hi in between invocations of the ghc to avoid it using something pre-built):

maximiliantagher@Maximilians-MacBook-Pro ~/D/C/H/ghc-warning> ghc -Weverything Main.hs Foo.hs
[1 of 2] Compiling Foo              ( Foo.hs, Foo.o )

<no location info>: warning: [-Wsafe]
    ‘Foo’ has been inferred as safe!
[2 of 2] Compiling Main             ( Main.hs, Main.o )

<no location info>: warning: [-Wsafe]
    ‘Main’ has been inferred as safe!
Linking Main ...

(I'm not familiar enough with Safe Haskell to get those warnings to go away—I tried the SafeHaskell pragma but that didn't seem to work. In any case, unrelated to this issue)

I tested with these versions:

  • GHC: The Glorious Glasgow Haskell Compilation System, version 8.2.1
  • OS Version: Mac OS 10.13.3 (17D47) (High Sierra)

Change History (4)

comment:1 Changed 15 months ago by MaxGabriel

Ah, this is totally unrelated, but to get rid of those safe warnings I believe I just would need -Wno-safe. I was trying -Wno-unsafe by mistake, before.

comment:2 Changed 14 months ago by taylorfausak

👍 I agree! I would like it if -Weverything did not enable -Wmissing-exported-signatures.

Here is a way to reproduce the problem with Stack:

#!/usr/bin/env stack
-- stack --resolver ghc-8.4.3 script
{-# OPTIONS_GHC -Weverything -Wno-implicit-prelude -Wno-safe #-}

module Main ( main ) where

main :: IO ()
main = pure shouldWarn

shouldWarn = ()

With -Wall instead of -Weverything, I get this warning:

.../Example.hs:10:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: shouldWarn :: ()
   |
10 | shouldWarn = ()
   | ^^^^^^^^^^

comment:3 Changed 10 months ago by crockeea

+1

comment:4 Changed 10 months ago by quasicomputational

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