[commit: ghc] master: GHCi does not need a main function (400f3ed)

git at git.haskell.org git at git.haskell.org
Sun Nov 11 13:30:27 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/400f3ed8ca830513ac6870d28bf46ed6b6bb720b/ghc

>---------------------------------------------------------------

commit 400f3ed8ca830513ac6870d28bf46ed6b6bb720b
Author: roland <rsx at bluewin.ch>
Date:   Sun Nov 11 11:19:30 2018 +0100

    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


>---------------------------------------------------------------

400f3ed8ca830513ac6870d28bf46ed6b6bb720b
 compiler/typecheck/TcRnDriver.hs                                  | 8 +++++---
 testsuite/tests/typecheck/should_run/T11647.hs                    | 1 +
 testsuite/tests/typecheck/should_run/T11647.script                | 2 ++
 .../{dynlibs/T5373B.hs => typecheck/should_run/T11647Sub.hs}      | 2 +-
 testsuite/tests/typecheck/should_run/all.T                        | 1 +
 5 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 4fa1723..a3e2a2f 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 0000000..37ca876
--- /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 0000000..7966e18
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T11647.script
@@ -0,0 +1,2 @@
+:l T11647.hs
+main
diff --git a/testsuite/tests/dynlibs/T5373B.hs b/testsuite/tests/typecheck/should_run/T11647Sub.hs
similarity index 51%
copy from testsuite/tests/dynlibs/T5373B.hs
copy to testsuite/tests/typecheck/should_run/T11647Sub.hs
index 0570fb1..b807c95 100644
--- a/testsuite/tests/dynlibs/T5373B.hs
+++ b/testsuite/tests/typecheck/should_run/T11647Sub.hs
@@ -1,4 +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 bdf70e0..a41df81 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'])
 



More information about the ghc-commits mailing list