diff options
| author | Roland Senn <rsx@bluewin.ch> | 2019-09-25 09:39:44 +0200 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-04 21:47:07 -0400 |
| commit | 93f02b6223b8fc4d85ece389ac0520ee9cc20f2f (patch) | |
| tree | 4ac9e60ca2464cc5a4f4213bcdbae7fabb33365a /compiler | |
| parent | 0d31ccdd5754b10fb27fcdc95ddd6c937ecec1bd (diff) | |
| download | haskell-93f02b6223b8fc4d85ece389ac0520ee9cc20f2f.tar.gz | |
New fix for #11647. Avoid side effects like #17171
If a main module doesn't contain a header, we omit the check whether the main module is exported.
With this patch GHC, GHCi and runghc use the same code.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/typecheck/TcRnDriver.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs index 6c61487152..c7f1cf62d5 100644 --- a/compiler/typecheck/TcRnDriver.hs +++ b/compiler/typecheck/TcRnDriver.hs @@ -271,8 +271,10 @@ tcRnModuleTcRnM hsc_env mod_sum ; tcg_env <- tcRnExports explicit_mod_hdr export_ies tcg_env ; traceRn "rn4b: after exports" empty - ; -- Check main is exported(must be after tcRnExports) - checkMainExported tcg_env + ; -- When a module header is specified, + -- check that the main module exports a main function. + -- (must be after tcRnExports) + when explicit_mod_hdr $ checkMainExported tcg_env ; -- Compare hi-boot iface (if any) with the real thing -- Must be done after processing the exports tcg_env <- checkHiBootIface tcg_env boot_info @@ -1801,11 +1803,10 @@ checkMainExported tcg_env Just main_name -> do { dflags <- getDynFlags ; let main_mod = mainModIs dflags - ; when (ghcLink dflags /= LinkInMemory) $ -- #11647 - checkTc (main_name `elem` + ; 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) } + text "The" <+> ppMainFn (nameRdrName main_name) <+> + text "is not exported by module" <+> quotes (ppr main_mod) } ppMainFn :: RdrName -> SDoc ppMainFn main_fn |
