Skip to content

"-main-is" flag is broken for recent ghc-head

Here is a minimal reproduction:

Main.hs:

main :: IO ()
main = putStrLn "Main"

Main2.hs:

module Main2 where

import Main

main2 :: IO ()
main2 = do
  putStrLn "Main2"
  main

Run ghc with something like /home/terrorjack/.stack/programs/x86_64-linux/ghc-8.7.20181003/bin/ghc -main-is Main2.main2 Main.hs Main2.hs, and it reports the following error:

[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:1:1: error:
    Not in scope: ‘main2’
    Perhaps you meant ‘main’ (line 2)
  |
1 | main :: IO ()
  | ^

Meanwhile, the exact same flags work for ghc-8.6.1, and also a previous ghc-head build on d90946ce, so some accidental breakage might be in a recent commit.

Trac metadata
Trac field Value
Version 8.6.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