Skip to content

Winferred-safe-imports: Do not exit with error

Problem:

$ cat A.hs                                                                                                        
{-# LANGUAGE Safe #-}
module A where
import B (double)
quad :: Int -> Int
quad = double . double

$ cat B.hs                                                                                                      module B where
double :: Int -> Int
double n = n + n

$ ghc A.hs -Winferred-safe-imports
[1 of 2] Compiling B                ( B.hs, B.o )
[2 of 2] Compiling A                ( A.hs, A.o )

A.hs:5:1: warning: [-Winferred-safe-imports]
    Importing Safe-Inferred module B from explicitly Safe module
  |
5 | import B (double)
  | ^^^^^^^^^^^^^^^^^

$ echo $?
1

I have no idea what I am doing and, unfortunately, I currently do not have a setup that would allow me to build GHC, but that function had a suspicious name, so I decided I would try to make this change blindly.

Introduced in !890 (closed) (cc @phadej @bgamari).

Merge request reports