diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-12-29 15:16:24 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-02-08 10:17:55 -0500 |
commit | 4435a8e0b74337fe5faddb9c46691f0f5bf9e653 (patch) | |
tree | 1d8ac7f540770c017f5e26f51d2788666203fbed /testsuite/tests/rename/should_compile | |
parent | aede171a59f9b7b8022548c385a1cb8c4589f905 (diff) | |
download | haskell-4435a8e0b74337fe5faddb9c46691f0f5bf9e653.tar.gz |
Introduce -Wcompat-unqualified-imports
This implements the warning proposed in option (B) of the
Data.List.singleton CLC [discussion][].
This warning, which is included in `-Wcompat` is intended to help users
identify imports of modules that will change incompatibly in future GHC
releases. This currently only includes `Data.List` due to the expected
specialisation and addition of `Data.List.singleton`.
Fixes #17244.
[discussion]: https://groups.google.com/d/msg/haskell-core-libraries/q3zHLmzBa5E/PmlAs_kYAQAJ
Diffstat (limited to 'testsuite/tests/rename/should_compile')
7 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/tests/rename/should_compile/T17244A.hs b/testsuite/tests/rename/should_compile/T17244A.hs new file mode 100644 index 0000000000..290120affd --- /dev/null +++ b/testsuite/tests/rename/should_compile/T17244A.hs @@ -0,0 +1,9 @@ +{-# OPTIONS_GHC -Wcompat-unqualified-imports #-} + +module T17244A (hello) where + +-- This should warn with -Wcompat-unqualified-imports. +import Data.List + +hello :: [Int] -> Int +hello = sum diff --git a/testsuite/tests/rename/should_compile/T17244A.stderr b/testsuite/tests/rename/should_compile/T17244A.stderr new file mode 100644 index 0000000000..621e9439f1 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T17244A.stderr @@ -0,0 +1,5 @@ + +T17244A.hs:6:8: warning: [-Wcompat-unqualified-imports (in -Wcompat)] + To ensure compatibility with future core libraries changes + imports to Data.List should be + either qualified or have an explicit import list. diff --git a/testsuite/tests/rename/should_compile/T17244B.hs b/testsuite/tests/rename/should_compile/T17244B.hs new file mode 100644 index 0000000000..61cbde3bee --- /dev/null +++ b/testsuite/tests/rename/should_compile/T17244B.hs @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wcompat-unqualified-imports #-} + +module T17244B (hello) where + +-- This should not warn with -Wcompat-unqualified-imports. +import qualified Data.List as List + +hello :: [Int] -> Int +hello = List.sum + diff --git a/testsuite/tests/rename/should_compile/T17244B.stderr b/testsuite/tests/rename/should_compile/T17244B.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T17244B.stderr diff --git a/testsuite/tests/rename/should_compile/T17244C.hs b/testsuite/tests/rename/should_compile/T17244C.hs new file mode 100644 index 0000000000..3da92dddd6 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T17244C.hs @@ -0,0 +1,10 @@ +{-# OPTIONS_GHC -Wcompat-unqualified-imports #-} + +module T17244C (hello) where + +-- This should not warn with -Wcompat-unqualified-imports. +import Data.List (sum) + +hello :: [Int] -> Int +hello = sum + diff --git a/testsuite/tests/rename/should_compile/T17244C.stderr b/testsuite/tests/rename/should_compile/T17244C.stderr new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T17244C.stderr diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index 51684f1eb3..b461d09076 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -169,3 +169,6 @@ test('T15798b', normal, compile, ['']) test('T15798c', normal, compile, ['']) test('T16116a', normal, compile, ['']) test('T15957', normal, compile, ['-Werror -Wredundant-record-wildcards -Wunused-record-wildcards']) +test('T17244A', normal, compile, ['-Wno-error=compat-unqualified-imports']) +test('T17244B', normal, compile, ['']) +test('T17244C', normal, compile, ['']) |