diff options
author | Thomas Miedema <thomasmiedema@gmail.com> | 2015-02-23 03:38:26 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-02-23 03:38:27 -0600 |
commit | 0fa20726b0587530712677e50a56c2b03ba43095 (patch) | |
tree | b82eaaf4828a17dfc72845ac11a918feed801bc3 /testsuite/tests | |
parent | b2be772a97f6e7fe9f1d1c28108949f81a13158b (diff) | |
download | haskell-0fa20726b0587530712677e50a56c2b03ba43095.tar.gz |
Error out on `Main` without `main` in GHCi (#7765)
Summary:
GHC does 2 validation checks for module `Main`:
* does `main` exist
* is `main` exported (#414)
The second check is done in ghc as well as in ghci (and runghc and ghc -e).
The first check however is currently not done in ghci, to prevent "'main' is
not in scope" errors when loading simple scripts. See commit d28ba8c8009 for
more information.
This commit tightens the special case for ghci. When the file does not contain
a main function, but does contain an explicit module header (i.e. "module Main
where"), then /do/ raise an error in ghci (and runghc and ghc -e) as well
Test Plan:
module/T7765: a module Main with an explicit module header but without a
main function should be an error for all Ways.
Additionaly: delete test module/mod174. It was added in commit 5a54c38, but it
is a duplicate of module/T414.
Reviewers: austin
Reviewed By: austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D649
GHC Trac Issues: #7765
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/deriving/should_fail/T5686.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog012/FooBar.hs (renamed from testsuite/tests/ghci/prog012/Main.hs) | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog012/prog012.script | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci022.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci027.script | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci027_1.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/ghci027_2.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/module/T7765.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/module/T7765.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/module/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/module/mod174.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/module/mod174.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/parser/should_fail/readFail013.hs | 2 |
13 files changed, 20 insertions, 29 deletions
diff --git a/testsuite/tests/deriving/should_fail/T5686.hs b/testsuite/tests/deriving/should_fail/T5686.hs index 425a13c839..a61df0627b 100644 --- a/testsuite/tests/deriving/should_fail/T5686.hs +++ b/testsuite/tests/deriving/should_fail/T5686.hs @@ -1,7 +1,7 @@ -{-# LANGUAGE TypeFamilies, DeriveFunctor #-}
-module Main where
-
-data U a = U (G a) deriving Functor
-
-class A a where
- type G a
+{-# LANGUAGE TypeFamilies, DeriveFunctor #-} +module T5686 where + +data U a = U (G a) deriving Functor + +class A a where + type G a diff --git a/testsuite/tests/ghci/prog012/Main.hs b/testsuite/tests/ghci/prog012/FooBar.hs index d49d063551..eeb29bbdbb 100644 --- a/testsuite/tests/ghci/prog012/Main.hs +++ b/testsuite/tests/ghci/prog012/FooBar.hs @@ -1,4 +1,4 @@ -module Main where +module FooBar where import Foo import Bar diff --git a/testsuite/tests/ghci/prog012/prog012.script b/testsuite/tests/ghci/prog012/prog012.script index 49af938b75..5e178389ac 100644 --- a/testsuite/tests/ghci/prog012/prog012.script +++ b/testsuite/tests/ghci/prog012/prog012.script @@ -10,7 +10,7 @@ :shell cp Bar1.hs Bar.hs -:load Main.hs +:load FooBar.hs :shell sleep 1 :shell cp Bar2.hs Bar.hs diff --git a/testsuite/tests/ghci/scripts/ghci022.hs b/testsuite/tests/ghci/scripts/ghci022.hs index d49fdba319..f87946a758 100644 --- a/testsuite/tests/ghci/scripts/ghci022.hs +++ b/testsuite/tests/ghci/scripts/ghci022.hs @@ -1,2 +1,2 @@ -module Main where +module GHCi022 where 'a' ' diff --git a/testsuite/tests/ghci/scripts/ghci027.script b/testsuite/tests/ghci/scripts/ghci027.script index aaf0ac5544..7a24f527bb 100644 --- a/testsuite/tests/ghci/scripts/ghci027.script +++ b/testsuite/tests/ghci/scripts/ghci027.script @@ -1,8 +1,8 @@ -- Test for #1617 :!cp ghci027_1.hs ghci027.hs :load ghci027 -:browse *Main +:browse *T1617 :!sleep 1 :!cp ghci027_2.hs ghci027.hs :reload -:browse *Main +:browse *T1617 diff --git a/testsuite/tests/ghci/scripts/ghci027_1.hs b/testsuite/tests/ghci/scripts/ghci027_1.hs index a1a7bfac37..23d52f0fee 100644 --- a/testsuite/tests/ghci/scripts/ghci027_1.hs +++ b/testsuite/tests/ghci/scripts/ghci027_1.hs @@ -1,5 +1,5 @@ -- Test for #1617 -module Main where +module T1617 where import Prelude () import Control.Monad (mplus) import qualified Control.Monad (mplus) diff --git a/testsuite/tests/ghci/scripts/ghci027_2.hs b/testsuite/tests/ghci/scripts/ghci027_2.hs index df99d7d1c0..c4db784dc2 100644 --- a/testsuite/tests/ghci/scripts/ghci027_2.hs +++ b/testsuite/tests/ghci/scripts/ghci027_2.hs @@ -1,5 +1,5 @@ -- Test for #1617 -module Main where +module T1617 where import Prelude () --import Control.Monad (mplus) import qualified Control.Monad (mplus) diff --git a/testsuite/tests/module/T7765.hs b/testsuite/tests/module/T7765.hs new file mode 100644 index 0000000000..6ca9a1fce6 --- /dev/null +++ b/testsuite/tests/module/T7765.hs @@ -0,0 +1 @@ +module Main where diff --git a/testsuite/tests/module/T7765.stderr b/testsuite/tests/module/T7765.stderr new file mode 100644 index 0000000000..bc8377d20d --- /dev/null +++ b/testsuite/tests/module/T7765.stderr @@ -0,0 +1,2 @@ + +T7765.hs:1:1: The IO action ‘main’ is not defined in module ‘Main’ diff --git a/testsuite/tests/module/all.T b/testsuite/tests/module/all.T index 58632bea73..c86a5f8806 100644 --- a/testsuite/tests/module/all.T +++ b/testsuite/tests/module/all.T @@ -319,8 +319,7 @@ test('mod172', extra_clean(['Mod172_B.hi', 'Mod172_B.o', 'Mod172_C.hi', 'Mod172_ test('mod173', extra_clean(['Mod173_Aux.hi', 'Mod173_Aux.o']), multimod_compile, ['mod173', '-v0']) -test('mod174', normal, compile_fail, ['']) - +# mod174 has been deleted # mod175 is a sub-directory test('mod176', normal, compile, ['-fwarn-unused-imports']) @@ -343,5 +342,6 @@ test('T414', normal, compile_fail, ['']) test('T414a', normal, compile, ['']) test('T414b', normal, compile, ['']) test('T3776', normal, compile, ['']) +test('T7765', normal, compile_fail, ['']) test('T9061', normal, compile, ['']) test('T9997', normal, compile, ['']) diff --git a/testsuite/tests/module/mod174.hs b/testsuite/tests/module/mod174.hs deleted file mode 100644 index 8e8149db7a..0000000000 --- a/testsuite/tests/module/mod174.hs +++ /dev/null @@ -1,9 +0,0 @@ - --- Test for trac #414 --- If main is not exported from Main then we should emit an error --- instead of running it anyway - -module Main () where - -main = putStrLn "Hello, World" - diff --git a/testsuite/tests/module/mod174.stderr b/testsuite/tests/module/mod174.stderr deleted file mode 100644 index a035f92b90..0000000000 --- a/testsuite/tests/module/mod174.stderr +++ /dev/null @@ -1,3 +0,0 @@ - -mod174.hs:1:1: - The IO action ‘main’ is not exported by module ‘Main’ diff --git a/testsuite/tests/parser/should_fail/readFail013.hs b/testsuite/tests/parser/should_fail/readFail013.hs index 97e926d49c..4850f3a1a5 100644 --- a/testsuite/tests/parser/should_fail/readFail013.hs +++ b/testsuite/tests/parser/should_fail/readFail013.hs @@ -1,4 +1,4 @@ -module Main where +module ReadFail013 where -- !!! unterminated `` a = ``s`` |