GHCi does not need a main function
authorroland <rsx@bluewin.ch>
Sun, 11 Nov 2018 10:19:30 +0000 (11:19 +0100)
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>
Sun, 11 Nov 2018 10:19:31 +0000 (11:19 +0100)
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

compiler/typecheck/TcRnDriver.hs
testsuite/tests/typecheck/should_run/T11647.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T11647.script [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T11647Sub.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/all.T

index 4fa1723..a3e2a2f 100644 (file)
@@ -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 (file)
index 0000000..37ca876
--- /dev/null
@@ -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 (file)
index 0000000..7966e18
--- /dev/null
@@ -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 (file)
index 0000000..b807c95
--- /dev/null
@@ -0,0 +1,4 @@
+module T11647Sub (main) where
+
+main :: IO ()
+main = return ()
index bdf70e0..a41df81 100755 (executable)
@@ -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'])