summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcRnExports.hs
diff options
context:
space:
mode:
authorchessai <chessai1996@gmail.com>2018-10-02 14:46:08 +0200
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>2018-10-02 16:00:19 +0200
commitabfb91fb0ea27eb618f297b1d3ba60cfa021afe0 (patch)
treef35b012fb723e44c015a97c69c128019755fd580 /compiler/typecheck/TcRnExports.hs
parentcaffff1238097821cd2879f7285010a6565afd52 (diff)
downloadhaskell-abfb91fb0ea27eb618f297b1d3ba60cfa021afe0.tar.gz
resolve T13704
Summary: allow -main-is to change export list for default module header, allowing one to change the entry point to one's program. Test Plan: ./validate Reviewers: bgamari, nomeata, mpickering Reviewed By: mpickering Subscribers: mpickering, rwbarton, carter GHC Trac Issues: #13704 Differential Revision: https://phabricator.haskell.org/D5189
Diffstat (limited to 'compiler/typecheck/TcRnExports.hs')
-rw-r--r--compiler/typecheck/TcRnExports.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/typecheck/TcRnExports.hs b/compiler/typecheck/TcRnExports.hs
index dbe2b4b22b..1b57608a41 100644
--- a/compiler/typecheck/TcRnExports.hs
+++ b/compiler/typecheck/TcRnExports.hs
@@ -33,7 +33,7 @@ import DataCon
import PatSyn
import Maybes
import Util (capitalise)
-
+import FastString (fsLit)
import Control.Monad
import DynFlags
@@ -124,19 +124,18 @@ tcRnExports explicit_mod exports
-- list, to avoid bleating about re-exporting a deprecated
-- thing (especially via 'module Foo' export item)
do {
- -- If the module header is omitted altogether, then behave
- -- as if the user had written "module Main(main) where..."
- -- EXCEPT in interactive mode, when we behave as if he had
+ -- In interactive mode, we behave as if he had
-- written "module Main where ..."
- -- Reason: don't want to complain about 'main' not in scope
- -- in interactive mode
; dflags <- getDynFlags
+ ; let default_main = case mainFunIs dflags of
+ Just main_fun -> mkUnqual varName (fsLit main_fun)
+ Nothing -> main_RDR_Unqual
; let real_exports
| explicit_mod = exports
| ghcLink dflags == LinkInMemory = Nothing
| otherwise
= Just (noLoc [noLoc (IEVar noExt
- (noLoc (IEName $ noLoc main_RDR_Unqual)))])
+ (noLoc (IEName $ noLoc default_main)))])
-- ToDo: the 'noLoc' here is unhelpful if 'main'
-- turns out to be out of scope