Use export list of Main module in function TcRnDriver.hs:check_main. Fix #16453.
The function compiler/typecheck/TcRnDriver.hs:check_main
calls
compiler/GHC/Rename/Env.hs:lookupOccRn_maybe
to collect the main
function(s) in scope of the Main
module. If there are multiple main
functions in scope,
lookupOccRn_maybe
throws the ambigous main
error mentioned in #16453 (closed).
This MR:
- Provide the export list of the
Main
module as parameter to thecheck_main
function. - Instead of
lookupOccRn_maybe
call the functionlookupInfoOccRn
. It returns the listmains_all
of all the main functions in scope. - Select from this list
mains_all
allmain
functions that are in the export list. - If this new list contains exactly one single
main
function, then typechecking continues. - Otherwise issue an appropriate error message.
Note: main
function always means the function name from the main-is
spec.