Opened 3 years ago

Closed 7 days ago

#11647 closed bug (fixed)

GHCi does not honour implicit `module Main (main) where` for re-exported `main`s

Reported by: hvr Owned by: RolandSenn
Priority: normal Milestone: 8.8.1
Component: GHCi Version: 7.10.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: make test TEST=T11647
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5162
Wiki Page:

Description

Haskell2010 states:

An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be module Main(main) where.

Consider the following two modules:

-- module Main (main) where
import Main2 (main)
module Main2 (main) where
main :: IO ()
main = return ()

A non-interactive GHC happily compiles ghc --make Main, however, GHCi fails with

$ ghci Main.hs
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
unknown option: 'c'
[1 of 2] Compiling Main2            ( Main2.hs, interpreted )
[2 of 2] Compiling Main             ( Main.hs, interpreted )

Main.hs:1:1: The IO action ‘main’ is not exported by module ‘Main’
Failed, modules loaded: Main2.

For GHCi we need to uncomment the explicit module Main (main) where line to make it work.

Change History (6)

comment:1 Changed 3 years ago by hvr

Type of failure: None/UnknownGHC rejects valid program

comment:2 Changed 2 months ago by RolandSenn

Owner: set to RolandSenn

I'll work on this.

comment:3 Changed 2 months ago by RolandSenn

Differential Rev(s): Phab:D5162
Status: newpatch
Test Case: make test TEST=T11647

comment:4 Changed 11 days ago by RolandSenn

Milestone: 8.8.1

comment:5 Changed 7 days ago by Krzysztof Gogolewski <krz.gogolewski@…>

In 400f3ed/ghc:

GHCi does not need a main function

Summary: In GHCi we don't check anymore, whether a main function is exported.

Test Plan: make test TEST=T11647

Reviewers: hvr, osa1, monoidal, mpickering, bgamari

Reviewed By: osa1, mpickering

Subscribers: rwbarton, carter

GHC Trac Issues: #11647

Differential Revision: https://phabricator.haskell.org/D5162

comment:6 Changed 7 days ago by monoidal

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.