Error out on `Main` without `main` in GHCi (#7765)
authorThomas Miedema <thomasmiedema@gmail.com>
Mon, 23 Feb 2015 09:38:26 +0000 (03:38 -0600)
committerAustin Seipp <austin@well-typed.com>
Mon, 23 Feb 2015 09:38:27 +0000 (03:38 -0600)
commit0fa20726b0587530712677e50a56c2b03ba43095
treeb82eaaf4828a17dfc72845ac11a918feed801bc3
parentb2be772a97f6e7fe9f1d1c28108949f81a13158b
Error out on `Main` without `main` in GHCi (#7765)

Summary:
GHC does 2 validation checks for module `Main`:
* does `main` exist
* is `main` exported (#414)

The second check is done in ghc as well as in ghci (and runghc and ghc -e).
The first check however is currently not done in ghci, to prevent "'main' is
not in scope" errors when loading simple scripts. See commit d28ba8c8009 for
more information.

This commit tightens the special case for ghci. When the file does not contain
a main function, but does contain an explicit module header (i.e. "module Main
where"), then /do/ raise an error in ghci (and runghc and ghc -e) as well

Test Plan:
module/T7765: a module Main with an explicit module header but without a
main function should be an error for all Ways.

Additionaly: delete test module/mod174. It was added in commit 5a54c38, but it
is a duplicate of module/T414.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

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

GHC Trac Issues: #7765
18 files changed:
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/utils/IOEnv.hs
docs/users_guide/7.12.1-notes.xml
testsuite/tests/deriving/should_fail/T5686.hs
testsuite/tests/ghci/prog012/FooBar.hs [moved from testsuite/tests/ghci/prog012/Main.hs with 53% similarity]
testsuite/tests/ghci/prog012/prog012.script
testsuite/tests/ghci/scripts/ghci022.hs
testsuite/tests/ghci/scripts/ghci027.script
testsuite/tests/ghci/scripts/ghci027_1.hs
testsuite/tests/ghci/scripts/ghci027_2.hs
testsuite/tests/module/T7765.hs [new file with mode: 0644]
testsuite/tests/module/T7765.stderr [new file with mode: 0644]
testsuite/tests/module/all.T
testsuite/tests/module/mod174.hs [deleted file]
testsuite/tests/module/mod174.stderr [deleted file]
testsuite/tests/parser/should_fail/readFail013.hs