Skip to content

Weird handling of exports named main in 8.10-rc1

Testing the new 8.10 release candidate:

We need 2 modules:

-- M1.hs
module M1 (main) where
main :: IO ()
main = pure () -- seem crucial that it's called main

-- M2.hs
module M2 (M2.main) where
import M1
main :: IO ()
main = putStrLn "test"

GHC 8.10-rc1:

$ ghc -c M1.hs

$ ghc -c M2.hs

M2.hs:1:1: error:
    Ambiguous occurrence ‘main’
    It could refer to
       either ‘M1.main’, imported from ‘M1’ at M2.hs:2:1-9
           or ‘M2.main’, defined at M2.hs:4:1
  |
1 | module M2 (M2.main) where
  | ^

GHC 8.8.2:

$ ghc -c M1.hs
$ ghc -c M2.hs
# no output, success

This also happens in --make mode.

This does not happen if the identifier is not named main.

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