+ `plusFV`
+ namesNeededForFlattening
+ -- this will be empty unless flattening is activated
+
+checkMain ghci_mode mod_name gbl_env
+ -- LOOKUP main IF WE'RE IN MODULE Main
+ -- The main point of this is to drag in the declaration for 'main',
+ -- its in another module, and for the Prelude function 'runMain',
+ -- so that the type checker will find them
+ --
+ -- We have to return the main_name separately, because it's a
+ -- bona fide 'use', and should be recorded as such, but the others
+ -- aren't
+ | mod_name /= mAIN_Name
+ = returnRn (Nothing, emptyFVs, emptyFVs)
+
+ | not (main_RDR_Unqual `elemRdrEnv` gbl_env)
+ = complain_no_main `thenRn_`
+ returnRn (Nothing, emptyFVs, emptyFVs)
+
+ | otherwise
+ = lookupSrcName gbl_env main_RDR_Unqual `thenRn` \ main_name ->
+ returnRn (Just main_name, unitFV main_name, unitFV runMainName)
+
+ where
+ complain_no_main | ghci_mode == Interactive = addWarnRn noMainMsg
+ | otherwise = addErrRn noMainMsg
+ -- In interactive mode, only warn about the absence of main