Commit 703221f4 authored by Roland Senn's avatar Roland Senn Committed by Marge Bot

Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453)

- Provide the export list of the `Main` module as parameter to the
  `compiler/typecheck/TcRnDriver.hs:check_main` function.
- Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`.
  It returns the list `mains_all` of all the main functions in scope.
- Select from this list `mains_all` all `main` functions that are in
  the export list of the `Main` module.
- If this new list contains exactly one single `main` function, then
  typechecking continues.
- Otherwise issue an appropriate error message.
parent 2643ba46
Pipeline #17105 passed with stages
in 507 minutes and 46 seconds
......@@ -17,6 +17,7 @@ module TcExpr ( tcPolyExpr, tcMonoExpr, tcMonoExprNC,
tcSyntaxOp, tcSyntaxOpGen, SyntaxOpType(..), synKnownType,
getFixedTyVars ) where
#include "HsVersions.h"
......@@ -2193,10 +2194,16 @@ disambiguateSelector lr@(L _ rdr) parent_type
-- occurrence" error, then give up.
ambiguousSelector :: Located RdrName -> TcM a
ambiguousSelector (L _ rdr)
= do { addAmbiguousNameErr rdr
; failM }
-- | This name really is ambiguous, so add a suitable "ambiguous
-- occurrence" error, then continue
addAmbiguousNameErr :: RdrName -> TcM ()
addAmbiguousNameErr rdr
= do { env <- getGlobalRdrEnv
; let gres = lookupGRE_RdrName rdr env
; setErrCtxt [] $ addNameClashErrRn rdr gres
; failM }
; setErrCtxt [] $ addNameClashErrRn rdr gres}
-- Disambiguate the fields in a record update.
-- See Note [Disambiguating record fields]
This diff is collapsed.
T16453E1.hs:1:1: error:
The IO action ‘main’ is not defined in module ‘Main’
module Main (T16453T.main, T16453S.main) where
import T16453T
import T16453S
Ambiguous occurrence ‘main’
It could refer to
either ‘T16453T.main’,
imported from ‘T16453T’ at T16453E2.hs:2:1-14
(and originally defined at T16453T.hs:2:1-4)
or ‘T16453S.main’,
imported from ‘T16453S’ at T16453E2.hs:3:1-14
(and originally defined at T16453S.hs:2:1-4)
module T16453S where
main = putStrLn "T16453S"
module T16453T where
main = putStrLn "T16453T"
......@@ -516,6 +516,10 @@ test('T16255', normal, compile_fail, [''])
test('T16204c', normal, compile_fail, [''])
test('T16394', normal, compile_fail, [''])
test('T16414', normal, compile_fail, [''])
test('T16453E1', extra_files(['T16453T.hs', 'T16453S.hs']), multimod_compile_fail,
['T16453E1.hs', '-v0'])
test('T16453E2', extra_files(['T16453T.hs', 'T16453S.hs']),
multimod_compile_fail, ['T16453E2.hs', '-v0'])
test('T16456', normal, compile_fail, ['-fprint-explicit-foralls'])
test('T16627', normal, compile_fail, [''])
test('T502', normal, compile_fail, [''])
module Main where
import T16453T
main = putStrLn "T16453M0"
module Main (T16453T.main) where
import T16453T
main = putStrLn "T16453M1"
module Main (Main.main) where
import T16453T
main = putStrLn "T16453M2"
module Main (module Main) where
import T16453T
main = putStrLn "T16453M3"
module Main (module T16453T) where
import T16453T
main = putStrLn "T16453M4"
module T16453T where
main = putStrLn "T16453T"
......@@ -135,6 +135,11 @@ test('T14218', normal, compile_and_run, [''])
test('T14236', normal, compile_and_run, [''])
test('T14925', normal, compile_and_run, [''])
test('T14341', normal, compile_and_run, [''])
test('T16453M0', extra_files(['T16453T.hs']), compile_and_run, [''])
test('T16453M1', extra_files(['T16453T.hs']), compile_and_run, [''])
test('T16453M2', extra_files(['T16453T.hs']), compile_and_run, [''])
test('T16453M3', extra_files(['T16453T.hs']), compile_and_run, [''])
test('T16453M4', extra_files(['T16453T.hs']), compile_and_run, [''])
test('UnliftedNewtypesRun', normal, compile_and_run, [''])
test('UnliftedNewtypesFamilyRun', normal, compile_and_run, [''])
test('UnliftedNewtypesDependentFamilyRun', normal, compile_and_run, [''])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment