Skip to content

Cannot declare hs-boot declaration if there is already a value in scope

This code no longer works:

-- A.hs-boot
module A where
concat :: Int -> Int -- overlaps with Prelude's concat

-- B.hs
module B where
import Prelude ()
import {-# SOURCE #-} A
x = concat 3

-- A.hs
module A where
import B
concat n = n + 2

Building ghc --make A, this crashes with:

[1 of 3] Compiling A[boot]          ( A.hs-boot, A.o-boot )
[2 of 3] Compiling B                ( B.hs, B.o )

B.hs:4:5: error:
    • Can't find interface-file declaration for variable concat
        Probable cause: bug in .hi-boot file, or inconsistent .hi file
        Use -ddump-if-trace to get an idea of which file caused the error
    • In the expression: concat 3
      In an equation for ‘x’: x = concat 3

The trouble is that renaming has botched up the top-level declaration for boot:

ezyang@sabre:~$ ghc-8.0 -c A.hs-boot -ddump-rn -dppr-debug
A.hs-boot:1:1:
    
    ==================== Renamer ====================
    {A.hs-boot:2:1-20}
    base-4.9.0.0:Data.Foldable.concat{v r2S} ::
      {A.hs-boot:2:11-20}
      ghc-prim-0.5.0.0:GHC.Types.Int{(w) tc 3J}
      -> ghc-prim-0.5.0.0:GHC.Types.Int{(w) tc 3J}

Is a regression from 7.10. The dodginess is proximal to renameSig but I haven't quite narrowed it down yet.

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