From 0e7790abf7d19d19f84c86dc95e50beb65462d12 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 17 Nov 2018 12:40:23 +0100 Subject: Fix trac #15702, as a followon to fix for #13704. Summary: The effect of this change is that -main-is changes the default export list for the main module, but does not apply the same change to non-main modules. This fixes some cases where -main-is was used to wrap a module that expected that default behavior (exporting `main`, even when that wasn't the main entry point name). Reviewers: mpickering, monoidal, bgamari Subscribers: rwbarton, carter GHC Trac Issues: #13704, #15702 Differential Revision: https://phabricator.haskell.org/D5322 --- compiler/typecheck/TcRnExports.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/typecheck/TcRnExports.hs') diff --git a/compiler/typecheck/TcRnExports.hs b/compiler/typecheck/TcRnExports.hs index 1b57608a41..a2f892ba1e 100644 --- a/compiler/typecheck/TcRnExports.hs +++ b/compiler/typecheck/TcRnExports.hs @@ -127,9 +127,11 @@ tcRnExports explicit_mod exports -- In interactive mode, we behave as if he had -- written "module Main where ..." ; dflags <- getDynFlags + ; let is_main_mod = mainModIs dflags == this_mod ; let default_main = case mainFunIs dflags of - Just main_fun -> mkUnqual varName (fsLit main_fun) - Nothing -> main_RDR_Unqual + Just main_fun + | is_main_mod -> mkUnqual varName (fsLit main_fun) + _ -> main_RDR_Unqual ; let real_exports | explicit_mod = exports | ghcLink dflags == LinkInMemory = Nothing -- cgit v1.2.1