Skip to content

`-fdefer-out-of-scope-variables` results in worse error messages for qualified names

Consider the following files:

module Data.List where
x :: Integer
x = 123
module Bar where
import qualified Data.List as ThisList
wrong1 = ThisList.map

Compiling Bar with GHC 9.2 or 9.4, we get an acceptable error message:

Main.hs:4:10: error:
    Not in scope: ThisList.map
    NB: the module Data.List does not export map.
    Suggested fix: Perhaps use ThisList.x (imported from Data.List)
  |
4 | wrong1 = ThisList.map
  |          ^^^^^^^^^^^^

However, with GHC 9.4, the error message changes (for the worse) with -fdefer-out-of-scope-variables:

Main.hs:4:10: warning: [-Wdeferred-out-of-scope-variables]
    Variable not in scope: map
    Suggested fixes:
       Perhaps use one of these:
          map (imported from Prelude), max (imported from Prelude),
          fmap (imported from Prelude)
       Perhaps you want to add map to the import list in the import of
        Prelude (Main.hs:2:8-10).
  |
4 | wrong1 = ThisList.map
  |          ^^^^^^^^^^^^

This is a regression as the message doesn't change with -fdefer-out-of-scope-variables for GHC 9.2.

Edited by Zubin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information