diff options
author | Sean D Gillespie <sean@mistersg.net> | 2018-06-17 11:22:20 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-06-17 12:41:17 -0400 |
commit | df0f148feae4c3b9653260edff843d561d6d5918 (patch) | |
tree | 3ad522f40192f0f25d7a10ee1ac1a9623e8d0e95 /testsuite/tests/package | |
parent | ccd8ce405db89142932daea3fdace8814b110798 (diff) | |
download | haskell-df0f148feae4c3b9653260edff843d561d6d5918.tar.gz |
Improve error message when importing an unusable package
If a module cannot be found because it is ignored or from an unusable
package, report this to the user and the reason it is unusable.
Currently, GHC displays the standard "Cannot find module error". For
example:
```
<no location info>: error:
Could not find module ‘Control.Monad.Random’
Perhaps you meant
Control.Monad.Reader (from mtl-2.2.2)
Control.Monad.Cont (from mtl-2.2.2)
Control.Monad.Error (from mtl-2.2.2)
```
GHC does, however, indicate unusable/ignored packages with the -v flag:
```
package MonadRandom-0.5.1-1421RgpXdhC8e8UI7D3emA is unusable due to
missing dependencies:
fail-4.9.0.0-BAHmj60kS5K7NVhhKpm9J5
```
With this change, I took that message and added it to the output of the
"Cannot find module" message.
Reviewers: bgamari, dfeuer
Reviewed By: bgamari
Subscribers: Phyx, dfeuer, rwbarton, thomie, carter
GHC Trac Issues: #4806
Differential Revision: https://phabricator.haskell.org/D4783
Diffstat (limited to 'testsuite/tests/package')
-rw-r--r-- | testsuite/tests/package/T4806.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/package/T4806.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/package/T4806a.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/package/T4806a.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/package/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/package/package01e.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/package/package06e.stderr | 8 | ||||
-rw-r--r-- | testsuite/tests/package/package07e.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/package/package08e.stderr | 6 |
9 files changed, 30 insertions, 12 deletions
diff --git a/testsuite/tests/package/T4806.hs b/testsuite/tests/package/T4806.hs new file mode 100644 index 0000000000..781cfef1ac --- /dev/null +++ b/testsuite/tests/package/T4806.hs @@ -0,0 +1 @@ +import Data.Map diff --git a/testsuite/tests/package/T4806.stderr b/testsuite/tests/package/T4806.stderr new file mode 100644 index 0000000000..6b332fd32b --- /dev/null +++ b/testsuite/tests/package/T4806.stderr @@ -0,0 +1,6 @@ + +T4806.hs:1:1: error: + Could not load module ‘Data.Map’ + It is a member of the package ‘containers-0.5.11.0’ + which is ignored due to an -ignore-package flag + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/T4806a.hs b/testsuite/tests/package/T4806a.hs new file mode 100644 index 0000000000..781cfef1ac --- /dev/null +++ b/testsuite/tests/package/T4806a.hs @@ -0,0 +1 @@ +import Data.Map diff --git a/testsuite/tests/package/T4806a.stderr b/testsuite/tests/package/T4806a.stderr new file mode 100644 index 0000000000..36cbb59fbe --- /dev/null +++ b/testsuite/tests/package/T4806a.stderr @@ -0,0 +1,7 @@ + +T4806a.hs:1:1: error: + Could not load module ‘Data.Map’ + It is a member of the package ‘containers-0.5.11.0’ + which is unusable because the -ignore-package flag was used to ignore at least one of its dependencies: + deepseq-1.4.4.0 + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/all.T b/testsuite/tests/package/all.T index 129ae8540c..670550e41d 100644 --- a/testsuite/tests/package/all.T +++ b/testsuite/tests/package/all.T @@ -17,3 +17,6 @@ test('package07e', normalise_version('ghc'), compile_fail, [incr_ghc + inc_ghc + test('package08e', normalise_version('ghc'), compile_fail, [incr_ghc + hide_ghc]) test('package09e', normal, compile_fail, ['-package "containers (Data.Map as M, Data.Set as M)"']) test('package10', normal, compile, ['-hide-all-packages -package "ghc (UniqFM as Prelude)" ']) + +test('T4806', normal, compile_fail, ['-ignore-package containers']) +test('T4806a', normal, compile_fail, ['-ignore-package deepseq'])
\ No newline at end of file diff --git a/testsuite/tests/package/package01e.stderr b/testsuite/tests/package/package01e.stderr index e4af6b1227..7ae545fe6f 100644 --- a/testsuite/tests/package/package01e.stderr +++ b/testsuite/tests/package/package01e.stderr @@ -1,13 +1,13 @@ package01e.hs:2:1: error: - Could not find module ‘Data.Map’ + Could not load module ‘Data.Map’ It is a member of the hidden package ‘containers-0.5.11.0’. You can run ‘:set -package containers’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. package01e.hs:3:1: error: - Could not find module ‘Data.IntMap’ + Could not load module ‘Data.IntMap’ It is a member of the hidden package ‘containers-0.5.11.0’. You can run ‘:set -package containers’ to expose it. (Note: this unloads all the modules in the current scope.) diff --git a/testsuite/tests/package/package06e.stderr b/testsuite/tests/package/package06e.stderr index 1bdbb162b0..40673b844c 100644 --- a/testsuite/tests/package/package06e.stderr +++ b/testsuite/tests/package/package06e.stderr @@ -1,14 +1,14 @@ package06e.hs:2:1: error: - Could not find module ‘HsTypes’ - It is a member of the hidden package ‘ghc-8.1’. + Could not load module ‘HsTypes’ + It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. package06e.hs:3:1: error: - Could not find module ‘UniqFM’ - It is a member of the hidden package ‘ghc-8.1’. + Could not load module ‘UniqFM’ + It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/package07e.stderr b/testsuite/tests/package/package07e.stderr index 9bd53da52c..132268cb64 100644 --- a/testsuite/tests/package/package07e.stderr +++ b/testsuite/tests/package/package07e.stderr @@ -5,21 +5,21 @@ package07e.hs:2:1: error: Use -v to see a list of the files searched for. package07e.hs:3:1: error: - Could not find module ‘HsTypes’ + Could not load module ‘HsTypes’ It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. package07e.hs:4:1: error: - Could not find module ‘HsUtils’ + Could not load module ‘HsUtils’ It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. package07e.hs:5:1: error: - Could not find module ‘UniqFM’ + Could not load module ‘UniqFM’ It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) diff --git a/testsuite/tests/package/package08e.stderr b/testsuite/tests/package/package08e.stderr index 0e075ddda9..31b6e762e7 100644 --- a/testsuite/tests/package/package08e.stderr +++ b/testsuite/tests/package/package08e.stderr @@ -5,21 +5,21 @@ package08e.hs:2:1: error: Use -v to see a list of the files searched for. package08e.hs:3:1: error: - Could not find module ‘HsTypes’ + Could not load module ‘HsTypes’ It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. package08e.hs:4:1: error: - Could not find module ‘HsUtils’ + Could not load module ‘HsUtils’ It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v to see a list of the files searched for. package08e.hs:5:1: error: - Could not find module ‘UniqFM’ + Could not load module ‘UniqFM’ It is a member of the hidden package ‘ghc-8.5’. You can run ‘:set -package ghc’ to expose it. (Note: this unloads all the modules in the current scope.) |