Skip to content

Regression: Detection of unused imports is imprecise (since GHC 8.0.1)

GHCs detection of unused imports used to be very precise. But apparently this changed with GHC 8.0.1. I already noticed for a while that there is something fishy going on and finally came up with a minimal example.

Steps to reproduce:

-- Bar.hs
module Bar (bar, module Control.Monad) where

import Control.Monad

bar :: Integer
bar = 23
-- Foo.hs
module Foo where

import Bar
import Control.Monad (forM_)

foo :: Monad m => [a] -> (a -> m ()) -> m ()
foo = forM_

baz :: Integer
baz = bar
$ ghci -Wall -Werror Foo.hs
  • *Expected result:** The program is reject.
  • *Actual result:** The program was reject by GHC < 8.0.1, however later versions of GHC accept the program.
Trac metadata
Trac field Value
Version 8.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information