diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2016-05-10 08:41:46 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-05-10 12:02:14 +0200 |
commit | 53f26f5a45f146e1cc988bbcf76a362c877beaa2 (patch) | |
tree | 3f7c270f496f90fe3683f1536bea7ec13dd3dd9d /testsuite/tests/module | |
parent | 3ca78062968f7ab6efff82122101e6f91b8c2cef (diff) | |
download | haskell-53f26f5a45f146e1cc988bbcf76a362c877beaa2.tar.gz |
Forbid variables to be parents in import lists.
In the long discussion on #11432, it was decided that when a type
constructor is parsed as a variable ((--.->) is one example) then in
order to export the type constructor then the user should be required to
use the ExplicitNamespaces keyword.
This was implemented in quite an indirect manner in the renamer. It
is much more direct to enforce this in the parser at the expense of
slighty worse error messages. Further to this, the check in the
renamer was actually slightly wrong. If the variable was in scope
then no error was raised, this was causing panics, see #12026 for an
example.
Reviewers: austin, bgamari
Subscribers: davean, skvadrik, thomie
Differential Revision: https://phabricator.haskell.org/D2181
GHC Trac Issues: #12026
Diffstat (limited to 'testsuite/tests/module')
-rw-r--r-- | testsuite/tests/module/T11432.stderr | 12 | ||||
-rw-r--r-- | testsuite/tests/module/T11432a.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/module/T11432a.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/module/T12026.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/module/T12026.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/module/all.T | 4 | ||||
-rw-r--r-- | testsuite/tests/module/mod89.stderr | 12 |
7 files changed, 31 insertions, 19 deletions
diff --git a/testsuite/tests/module/T11432.stderr b/testsuite/tests/module/T11432.stderr index bf2a58b0a0..9e61092e37 100644 --- a/testsuite/tests/module/T11432.stderr +++ b/testsuite/tests/module/T11432.stderr @@ -1,10 +1,4 @@ -T11432.hs:7:16: - Not in scope: ‘-.->’ - Note: use ‘type’ keyword to export type constructor ‘-.->’ - defined at T11432.hs:9:1 - (requires TypeOperators extension) - -T11432.hs:7:16: - The export item ‘(-.->)(..)’ - attempts to export constructors or class methods that are not visible here +T11432.hs:7:16: error: + Expecting a type constructor but found a variable. + If ‘-.->’ is a type constructor then enable ExplicitNamespaces and use the 'type' keyword. diff --git a/testsuite/tests/module/T11432a.hs b/testsuite/tests/module/T11432a.hs new file mode 100644 index 0000000000..824fd6f0f5 --- /dev/null +++ b/testsuite/tests/module/T11432a.hs @@ -0,0 +1,11 @@ +{- +We expect to get a suggestion to add 'type' keyword +and enable TypeOperators extension. +-} + +{-# LANGUAGE TypeOperators #-} +module T11432a ((-.->)()) where + +newtype (f -.-> g) a = Fn { apFn :: f a -> g a } + +(-.->) = id diff --git a/testsuite/tests/module/T11432a.stderr b/testsuite/tests/module/T11432a.stderr new file mode 100644 index 0000000000..2542af3fe0 --- /dev/null +++ b/testsuite/tests/module/T11432a.stderr @@ -0,0 +1,4 @@ + +T11432a.hs:7:17: error: + Expecting a type constructor but found a variable. + If ‘-.->’ is a type constructor then enable ExplicitNamespaces and use the 'type' keyword. diff --git a/testsuite/tests/module/T12026.hs b/testsuite/tests/module/T12026.hs new file mode 100644 index 0000000000..3e831791c1 --- /dev/null +++ b/testsuite/tests/module/T12026.hs @@ -0,0 +1,3 @@ +module T12026 where + +import Prelude (map ()) diff --git a/testsuite/tests/module/T12026.stderr b/testsuite/tests/module/T12026.stderr new file mode 100644 index 0000000000..38d53d7049 --- /dev/null +++ b/testsuite/tests/module/T12026.stderr @@ -0,0 +1,4 @@ + +T12026.hs:3:17: error: + Expecting a type constructor but found a variable. + If ‘map’ is a type constructor then enable ExplicitNamespaces and use the 'type' keyword. diff --git a/testsuite/tests/module/all.T b/testsuite/tests/module/all.T index d86dfede9d..ca81c5e9e8 100644 --- a/testsuite/tests/module/all.T +++ b/testsuite/tests/module/all.T @@ -116,7 +116,7 @@ test('mod85', normal, compile, ['']) test('mod86', normal, compile, ['']) test('mod87', normal, compile_fail, ['']) test('mod88', normal, compile_fail, ['']) -test('mod89', normal, compile, ['']) +test('mod89', normal, compile_fail, ['']) test('mod90', normal, compile_fail, ['']) test('mod91', normal, compile_fail, ['']) test('mod92', normal, compile, ['']) @@ -348,3 +348,5 @@ test('T9997', normal, compile, ['']) test('T10233', extra_clean(['T01233a.hi', 'T01233a.o']), multimod_compile, ['T10233', '-v0']) test('T11432', normal, compile_fail, ['']) +test('T11432a', normal, compile_fail, ['']) +test('T12026', normal, compile_fail, ['']) diff --git a/testsuite/tests/module/mod89.stderr b/testsuite/tests/module/mod89.stderr index a1e335c9ff..afdc46466f 100644 --- a/testsuite/tests/module/mod89.stderr +++ b/testsuite/tests/module/mod89.stderr @@ -1,10 +1,4 @@ -mod89.hs:5:1: warning: [-Wdodgy-imports (in -Wextra)] - The import item ‘map(..)’ suggests that - ‘map’ has (in-scope) constructors or class methods, - but it has none - -mod89.hs:5:1: warning: [-Wunused-imports (in -Wextra)] - The import of ‘Prelude’ is redundant - except perhaps to import instances from ‘Prelude’ - To import instances alone, use: import Prelude() +mod89.hs:5:16: error: + Expecting a type constructor but found a variable. + If ‘map’ is a type constructor then enable ExplicitNamespaces and use the 'type' keyword. |