summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroland <rsx@bluewin.ch>2018-11-11 11:19:30 +0100
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>2018-11-11 11:19:31 +0100
commit400f3ed8ca830513ac6870d28bf46ed6b6bb720b (patch)
treef36ac86e562d8493a38edd532780b6e8693c5598
parent63a817074a8d49798bfd46a6545906fff143e924 (diff)
downloadhaskell-400f3ed8ca830513ac6870d28bf46ed6b6bb720b.tar.gz
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
-rw-r--r--compiler/typecheck/TcRnDriver.hs8
-rw-r--r--testsuite/tests/typecheck/should_run/T11647.hs1
-rw-r--r--testsuite/tests/typecheck/should_run/T11647.script2
-rw-r--r--testsuite/tests/typecheck/should_run/T11647Sub.hs4
-rwxr-xr-xtestsuite/tests/typecheck/should_run/all.T1
5 files changed, 13 insertions, 3 deletions
diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 4fa1723676..a3e2a2f433 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -1758,9 +1758,11 @@ checkMainExported tcg_env
Just main_name ->
do { dflags <- getDynFlags
; let main_mod = mainModIs dflags
- ; checkTc (main_name `elem` concatMap availNames (tcg_exports tcg_env)) $
- text "The" <+> ppMainFn (nameRdrName main_name) <+>
- text "is not exported by module" <+> quotes (ppr main_mod) }
+ ; when (ghcLink dflags /= LinkInMemory) $ -- #11647
+ checkTc (main_name `elem`
+ concatMap availNames (tcg_exports tcg_env)) $
+ text "The" <+> ppMainFn (nameRdrName main_name) <+>
+ text "is not exported by module" <+> quotes (ppr main_mod) }
ppMainFn :: RdrName -> SDoc
ppMainFn main_fn
diff --git a/testsuite/tests/typecheck/should_run/T11647.hs b/testsuite/tests/typecheck/should_run/T11647.hs
new file mode 100644
index 0000000000..37ca8761f6
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T11647.hs
@@ -0,0 +1 @@
+import T11647Sub (main)
diff --git a/testsuite/tests/typecheck/should_run/T11647.script b/testsuite/tests/typecheck/should_run/T11647.script
new file mode 100644
index 0000000000..7966e183de
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T11647.script
@@ -0,0 +1,2 @@
+:l T11647.hs
+main
diff --git a/testsuite/tests/typecheck/should_run/T11647Sub.hs b/testsuite/tests/typecheck/should_run/T11647Sub.hs
new file mode 100644
index 0000000000..b807c95049
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T11647Sub.hs
@@ -0,0 +1,4 @@
+module T11647Sub (main) where
+
+main :: IO ()
+main = return ()
diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T
index bdf70e0844..a41df81729 100755
--- a/testsuite/tests/typecheck/should_run/all.T
+++ b/testsuite/tests/typecheck/should_run/all.T
@@ -125,6 +125,7 @@ test('TestTypeableBinary', normal, compile_and_run, [''])
test('Typeable1', normal, compile_fail, ['-Werror'])
test('TypeableEq', normal, compile_and_run, [''])
test('T13435', normal, compile_and_run, [''])
+test('T11647', normal, ghci_script, ['T11647.script'])
test('T11715', exit_code(1), compile_and_run, [''])
test('T13594a', normal, ghci_script, ['T13594a.script'])