diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2015-11-10 17:07:10 +0100 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2015-11-13 10:13:20 +0100 |
commit | e66f79dfb22031dd3f75dd3eb341e8269ab51d83 (patch) | |
tree | 157fdd402b439ac8c82439d37d02084b4e899fd9 /testsuite/tests/rename | |
parent | 2290c8bd8c3faee0cb7dc1c2c7951bb9d5e3ebf9 (diff) | |
download | haskell-e66f79dfb22031dd3f75dd3eb341e8269ab51d83.tar.gz |
Give helpful advice when a fully qualified name is not in scope
This implements #11071. It needs to thread through a GlobalRdrEnv
corresponding to the export list of the module if its exports were not
restricted.
A refactoring of ImportedModsVal into a proper data type follows.
Differential Revision: https://phabricator.haskell.org/D1462
Diffstat (limited to 'testsuite/tests/rename')
13 files changed, 118 insertions, 13 deletions
diff --git a/testsuite/tests/rename/prog002/rename.prog002.stderr b/testsuite/tests/rename/prog002/rename.prog002.stderr index b9dbf7f54a..01ab86946e 100644 --- a/testsuite/tests/rename/prog002/rename.prog002.stderr +++ b/testsuite/tests/rename/prog002/rename.prog002.stderr @@ -1,2 +1,5 @@ -rnfail037.hs:8:7: Not in scope: data constructor ‘Rn037Help.C’ +rnfail037.hs:8:7: error: + Not in scope: data constructor ‘Rn037Help.C’ + Perhaps you want to remove ‘C’ from the explicit hiding list + in the import of ‘Rn037Help’ (rnfail037.hs:4:1-28). diff --git a/testsuite/tests/rename/should_fail/T10781.stderr b/testsuite/tests/rename/should_fail/T10781.stderr index 5d4dc3c098..d86f0d1beb 100644 --- a/testsuite/tests/rename/should_fail/T10781.stderr +++ b/testsuite/tests/rename/should_fail/T10781.stderr @@ -1,2 +1,4 @@ -T10781.hs:12:5: error: Not in scope: ‘Foo._name’ +T10781.hs:12:5: error: + Not in scope: ‘Foo._name’ + No module named ‘Foo’ is imported. diff --git a/testsuite/tests/rename/should_fail/T11071.hs b/testsuite/tests/rename/should_fail/T11071.hs new file mode 100644 index 0000000000..ad31bc0c80 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T11071.hs @@ -0,0 +1,28 @@ +module T11071 where + +import Data.List (lines) +import qualified Data.Map as M () +import qualified Data.IntMap as M () +import qualified Data.IntMap as M () -- just to see if this confused the code + +import qualified Data.Ord as Ord hiding (Down) + +import qualified Data.Map as M' hiding (size, filter) +import qualified Data.Map as M' hiding (size) +import qualified Data.IntMap as M' hiding (size) +import qualified System.IO as M' () -- unrelated + +ignore :: a -> IO () +ignore = const (return ()) + +main = do + ignore NoSuchModule.foo -- no such module + ignore Data.List.foobar -- does not exist (one import) + ignore M.foobar -- does not exist (two imports) + ignore M'.foobar -- does not exist (three imports) + ignore Data.List.sort -- needs import + ignore Data.List.unlines -- needs import, similar to imported + ignore M.size -- multiple modules to import from + ignore M.valid -- only one module to import from + ignore Ord.Down -- explicit hiding + ignore M'.size -- hidden and/or missing in import list diff --git a/testsuite/tests/rename/should_fail/T11071.stderr b/testsuite/tests/rename/should_fail/T11071.stderr new file mode 100644 index 0000000000..e3d5e30377 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T11071.stderr @@ -0,0 +1,53 @@ + +T11071.hs:19:12: error: + Not in scope: ‘NoSuchModule.foo’ + No module named ‘NoSuchModule’ is imported. + +T11071.hs:20:12: error: + Not in scope: ‘Data.List.foobar’ + Module ‘Data.List’ does not export ‘foobar’. + +T11071.hs:21:12: error: + Not in scope: ‘M.foobar’ + Neither ‘Data.Map’ nor ‘Data.IntMap’ exports ‘foobar’. + +T11071.hs:22:12: error: + Not in scope: ‘M'.foobar’ + Neither ‘Data.Map’, ‘Data.IntMap’ nor ‘System.IO’ exports ‘foobar’. + +T11071.hs:23:12: error: + Not in scope: ‘Data.List.sort’ + Perhaps you want to add ‘sort’ to the import list in the import of + ‘Data.List’ (T11071.hs:3:1-24). + +T11071.hs:24:12: error: + Not in scope: ‘Data.List.unlines’ + Perhaps you meant ‘Data.List.lines’ (imported from Data.List) + Perhaps you want to add ‘unlines’ to the import list + in the import of ‘Data.List’ (T11071.hs:3:1-24). + +T11071.hs:25:12: error: + Not in scope: ‘M.size’ + Perhaps you want to add ‘size’ to one of these import lists: + ‘Data.Map’ (T11071.hs:4:1-33) + ‘Data.IntMap’ (T11071.hs:5:1-36) + +T11071.hs:26:12: error: + Not in scope: ‘M.valid’ + Perhaps you meant one of these: + ‘M'.valid’ (imported from Data.Map), + ‘M'.valid’ (imported from Data.Map) + Perhaps you want to add ‘valid’ to the import list in the import of + ‘Data.Map’ (T11071.hs:4:1-33). + +T11071.hs:27:12: error: + Not in scope: data constructor ‘Ord.Down’ + Perhaps you want to remove ‘Down’ from the explicit hiding list + in the import of ‘Data.Ord’ (T11071.hs:8:1-46). + +T11071.hs:28:12: error: + Not in scope: ‘M'.size’ + Perhaps you want to remove ‘size’ from the hiding clauses + in one of these imports: + ‘Data.Map’ (T11071.hs:10:1-53) + ‘Data.IntMap’ (T11071.hs:12:1-48) diff --git a/testsuite/tests/rename/should_fail/T2901.stderr b/testsuite/tests/rename/should_fail/T2901.stderr index b240139bd8..d5a2247ce1 100644 --- a/testsuite/tests/rename/should_fail/T2901.stderr +++ b/testsuite/tests/rename/should_fail/T2901.stderr @@ -1,4 +1,7 @@ -T2901.hs:6:5: Not in scope: data constructor ‘F.Foo’ +T2901.hs:6:5: error: + Not in scope: data constructor ‘F.Foo’ + No module named ‘F’ is imported. -T2901.hs:6:13: ‘F.field’ is not a (visible) constructor field name +T2901.hs:6:13: error: + ‘F.field’ is not a (visible) constructor field name diff --git a/testsuite/tests/rename/should_fail/T5657.stderr b/testsuite/tests/rename/should_fail/T5657.stderr index aa5f870b7b..5663b900d9 100644 --- a/testsuite/tests/rename/should_fail/T5657.stderr +++ b/testsuite/tests/rename/should_fail/T5657.stderr @@ -1,5 +1,7 @@ -T5657.hs:3:8: Not in scope: ‘LT..’ +T5657.hs:3:8: error: + Not in scope: ‘LT..’ + No module named ‘LT’ is imported. -T5657.hs:3:8: +T5657.hs:3:8: error: A section must be enclosed in parentheses thus: (LT.. GT) diff --git a/testsuite/tests/rename/should_fail/T5892b.stderr b/testsuite/tests/rename/should_fail/T5892b.stderr index 994ea78c11..0f93c21f68 100644 --- a/testsuite/tests/rename/should_fail/T5892b.stderr +++ b/testsuite/tests/rename/should_fail/T5892b.stderr @@ -1,2 +1,4 @@ -T5892b.hs:11:7: Not in scope: ‘T5892b.subForest’ +T5892b.hs:11:7: error: + Not in scope: ‘T5892b.subForest’ + No module named ‘T5892b’ is imported. diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index 48814ec983..66dfeaa916 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -138,3 +138,4 @@ test('T10618', normal, compile_fail, ['']) test('T10668', normal, compile_fail, ['']) test('T5001b', normal, compile_fail, ['']) test('T10781', normal, compile_fail, ['']) +test('T11071', normal, compile_fail, ['']) diff --git a/testsuite/tests/rename/should_fail/rnfail030.stderr b/testsuite/tests/rename/should_fail/rnfail030.stderr index 5b2cd36358..462dc5fa2c 100644 --- a/testsuite/tests/rename/should_fail/rnfail030.stderr +++ b/testsuite/tests/rename/should_fail/rnfail030.stderr @@ -1,2 +1,5 @@ -rnfail030.hs:2:21: Not in scope: ‘Data.List.map’ +rnfail030.hs:2:21: error: + Not in scope: ‘Data.List.map’ + Perhaps you want to add ‘map’ to the import list in the import of + ‘Data.List’ (rnfail030.hs:3:1-19). diff --git a/testsuite/tests/rename/should_fail/rnfail031.stderr b/testsuite/tests/rename/should_fail/rnfail031.stderr index 828d5121c8..95d8ea1561 100644 --- a/testsuite/tests/rename/should_fail/rnfail031.stderr +++ b/testsuite/tests/rename/should_fail/rnfail031.stderr @@ -1,2 +1,5 @@ -rnfail031.hs:2:21: Not in scope: ‘Data.List.map’ +rnfail031.hs:2:21: error: + Not in scope: ‘Data.List.map’ + Perhaps you want to add ‘map’ to the import list in the import of + ‘Data.List’ (rnfail031.hs:3:1-36). diff --git a/testsuite/tests/rename/should_fail/rnfail032.stderr b/testsuite/tests/rename/should_fail/rnfail032.stderr index 2169fd502e..70d80a0322 100644 --- a/testsuite/tests/rename/should_fail/rnfail032.stderr +++ b/testsuite/tests/rename/should_fail/rnfail032.stderr @@ -1,7 +1,9 @@ -rnfail032.hs:2:21: +rnfail032.hs:2:21: error: Not in scope: ‘Data.List.map’ Perhaps you meant one of these: ‘Data.List.zip’ (imported from Data.List), ‘Data.List.all’ (imported from Data.List), ‘Data.List.and’ (imported from Data.List) + Perhaps you want to remove ‘map’ from the explicit hiding list + in the import of ‘Data.List’ (rnfail032.hs:3:1-41). diff --git a/testsuite/tests/rename/should_fail/rnfail033.stderr b/testsuite/tests/rename/should_fail/rnfail033.stderr index 6b6849d1e5..277b42fb16 100644 --- a/testsuite/tests/rename/should_fail/rnfail033.stderr +++ b/testsuite/tests/rename/should_fail/rnfail033.stderr @@ -1,7 +1,9 @@ -rnfail033.hs:2:21: +rnfail033.hs:2:21: error: Not in scope: ‘Data.List.map’ Perhaps you meant one of these: ‘Data.List.zip’ (imported from Data.List), ‘Data.List.all’ (imported from Data.List), ‘Data.List.and’ (imported from Data.List) + Perhaps you want to remove ‘map’ from the explicit hiding list + in the import of ‘Data.List’ (rnfail033.hs:3:1-31). diff --git a/testsuite/tests/rename/should_fail/rnfail034.stderr b/testsuite/tests/rename/should_fail/rnfail034.stderr index 78bc649c29..63e6eb5037 100644 --- a/testsuite/tests/rename/should_fail/rnfail034.stderr +++ b/testsuite/tests/rename/should_fail/rnfail034.stderr @@ -1,6 +1,7 @@ -rnfail034.hs:4:11: Qualified name in binding position: M.y +rnfail034.hs:4:11: error: Qualified name in binding position: M.y -rnfail034.hs:4:26: +rnfail034.hs:4:26: error: Not in scope: ‘M.y’ Perhaps you meant ‘M.g’ (line 4) + No module named ‘M’ is imported. |