diff options
author | Roland Senn <rsx@bluewin.ch> | 2020-03-14 17:33:02 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-03-25 14:45:04 -0400 |
commit | 703221f408b023a1b3433938572e7b5c24b4af60 (patch) | |
tree | 505a0b419f288b73d2034e96d4b7f398a7488733 /testsuite | |
parent | 2643ba465cd2a133b6f495f34fc59cd1a6d23525 (diff) | |
download | haskell-703221f408b023a1b3433938572e7b5c24b4af60.tar.gz |
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.
Diffstat (limited to 'testsuite')
19 files changed, 51 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T16453E1.hs b/testsuite/tests/typecheck/should_fail/T16453E1.hs new file mode 100644 index 0000000000..3e910dd453 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16453E1.hs @@ -0,0 +1,2 @@ +module Main where +import T16453T diff --git a/testsuite/tests/typecheck/should_fail/T16453E1.stderr b/testsuite/tests/typecheck/should_fail/T16453E1.stderr new file mode 100644 index 0000000000..d435ab8e1e --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16453E1.stderr @@ -0,0 +1,2 @@ +T16453E1.hs:1:1: error: + The IO action ‘main’ is not defined in module ‘Main’ diff --git a/testsuite/tests/typecheck/should_fail/T16453E2.hs b/testsuite/tests/typecheck/should_fail/T16453E2.hs new file mode 100644 index 0000000000..d27e2e6c41 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16453E2.hs @@ -0,0 +1,3 @@ +module Main (T16453T.main, T16453S.main) where +import T16453T +import T16453S diff --git a/testsuite/tests/typecheck/should_fail/T16453E2.stderr b/testsuite/tests/typecheck/should_fail/T16453E2.stderr new file mode 100644 index 0000000000..4999d60cc7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16453E2.stderr @@ -0,0 +1,9 @@ +T16453E2.hs:1:1: + 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) diff --git a/testsuite/tests/typecheck/should_fail/T16453S.hs b/testsuite/tests/typecheck/should_fail/T16453S.hs new file mode 100644 index 0000000000..c9e966dca9 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16453S.hs @@ -0,0 +1,2 @@ +module T16453S where +main = putStrLn "T16453S" diff --git a/testsuite/tests/typecheck/should_fail/T16453T.hs b/testsuite/tests/typecheck/should_fail/T16453T.hs new file mode 100644 index 0000000000..98ea6255f7 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16453T.hs @@ -0,0 +1,2 @@ +module T16453T where +main = putStrLn "T16453T" diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 60e50ca241..4f8f08ed85 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -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, ['']) diff --git a/testsuite/tests/typecheck/should_run/T16453M0.hs b/testsuite/tests/typecheck/should_run/T16453M0.hs new file mode 100644 index 0000000000..08ace5d99e --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M0.hs @@ -0,0 +1,3 @@ +module Main where +import T16453T +main = putStrLn "T16453M0" diff --git a/testsuite/tests/typecheck/should_run/T16453M0.stdout b/testsuite/tests/typecheck/should_run/T16453M0.stdout new file mode 100644 index 0000000000..e61283f99c --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M0.stdout @@ -0,0 +1 @@ +T16453M0 diff --git a/testsuite/tests/typecheck/should_run/T16453M1.hs b/testsuite/tests/typecheck/should_run/T16453M1.hs new file mode 100644 index 0000000000..aa240f2c75 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M1.hs @@ -0,0 +1,3 @@ +module Main (T16453T.main) where +import T16453T +main = putStrLn "T16453M1" diff --git a/testsuite/tests/typecheck/should_run/T16453M1.stdout b/testsuite/tests/typecheck/should_run/T16453M1.stdout new file mode 100644 index 0000000000..e4dfbcd44f --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M1.stdout @@ -0,0 +1 @@ +T16453T diff --git a/testsuite/tests/typecheck/should_run/T16453M2.hs b/testsuite/tests/typecheck/should_run/T16453M2.hs new file mode 100644 index 0000000000..acf4e6791b --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M2.hs @@ -0,0 +1,3 @@ +module Main (Main.main) where +import T16453T +main = putStrLn "T16453M2" diff --git a/testsuite/tests/typecheck/should_run/T16453M2.stdout b/testsuite/tests/typecheck/should_run/T16453M2.stdout new file mode 100644 index 0000000000..ab13919690 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M2.stdout @@ -0,0 +1 @@ +T16453M2 diff --git a/testsuite/tests/typecheck/should_run/T16453M3.hs b/testsuite/tests/typecheck/should_run/T16453M3.hs new file mode 100644 index 0000000000..167d8fde7c --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M3.hs @@ -0,0 +1,3 @@ +module Main (module Main) where +import T16453T +main = putStrLn "T16453M3" diff --git a/testsuite/tests/typecheck/should_run/T16453M3.stdout b/testsuite/tests/typecheck/should_run/T16453M3.stdout new file mode 100644 index 0000000000..f0c95103e7 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M3.stdout @@ -0,0 +1 @@ +T16453M3 diff --git a/testsuite/tests/typecheck/should_run/T16453M4.hs b/testsuite/tests/typecheck/should_run/T16453M4.hs new file mode 100644 index 0000000000..a1ec32bda6 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M4.hs @@ -0,0 +1,3 @@ +module Main (module T16453T) where +import T16453T +main = putStrLn "T16453M4" diff --git a/testsuite/tests/typecheck/should_run/T16453M4.stdout b/testsuite/tests/typecheck/should_run/T16453M4.stdout new file mode 100644 index 0000000000..e4dfbcd44f --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453M4.stdout @@ -0,0 +1 @@ +T16453T diff --git a/testsuite/tests/typecheck/should_run/T16453T.hs b/testsuite/tests/typecheck/should_run/T16453T.hs new file mode 100644 index 0000000000..98ea6255f7 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T16453T.hs @@ -0,0 +1,2 @@ +module T16453T where +main = putStrLn "T16453T" diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T index 512362f1bb..4cd7a1b73c 100755 --- a/testsuite/tests/typecheck/should_run/all.T +++ b/testsuite/tests/typecheck/should_run/all.T @@ -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, ['']) |