diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-11-05 00:47:32 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-12 21:22:03 -0500 |
commit | dfc4093ccb7c4b7402830ab7c715b55d90980af1 (patch) | |
tree | 7cd92eafd556c01b35d4298597f364dfbabbe25b /testsuite | |
parent | ca90ffa321a31842a32be1b5b6e26743cd677ec5 (diff) | |
download | haskell-dfc4093ccb7c4b7402830ab7c715b55d90980af1.tar.gz |
Implement -Wforall-identifier (#20609)
In accordance with GHC Proposal #281 "Visible forall in types of terms":
For three releases before this change takes place, include a new
warning -Wforall-identifier in -Wdefault. This warning will be triggered
at definition sites (but not use sites) of forall as an identifier.
Updates the haddock submodule.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/ghci/prog017/TopLevel.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog017/prog017.script | 2 | ||||
-rw-r--r-- | testsuite/tests/ghci/prog017/prog017.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609.hs | 23 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609.stderr | 49 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609a.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609a.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609b.hs | 13 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609b.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609c.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609c.stderr | 14 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609d.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/T20609d.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/rename/should_compile/all.T | 5 |
15 files changed, 163 insertions, 5 deletions
diff --git a/testsuite/tests/ghci/prog017/TopLevel.hs b/testsuite/tests/ghci/prog017/TopLevel.hs index c2e562b1f9..6e9d38812a 100644 --- a/testsuite/tests/ghci/prog017/TopLevel.hs +++ b/testsuite/tests/ghci/prog017/TopLevel.hs @@ -72,8 +72,8 @@ import Level2.Level2 (➾➔) = undefined :: () -- ... U+2794 -- mathematicalOperators -(∀) = undefined :: () -- U+2200 -(∀⋙) = undefined :: () -- ... U+22D9 +(∁) = undefined :: () -- U+2201 (skip U+2200 because it's the keyword ∀) +(∁⋙) = undefined :: () -- ... U+22D9 -- miscellaneousMathematicalSymbolsAR (⟑) = undefined :: () -- U+27D1 diff --git a/testsuite/tests/ghci/prog017/prog017.script b/testsuite/tests/ghci/prog017/prog017.script index 302233869b..7144d087fd 100644 --- a/testsuite/tests/ghci/prog017/prog017.script +++ b/testsuite/tests/ghci/prog017/prog017.script @@ -61,7 +61,7 @@ :complete repl "➾" -- mathematicalOperators -:complete repl "∀" +:complete repl "∁" -- miscellaneousMathematicalSymbolsAR :complete repl "⟑" diff --git a/testsuite/tests/ghci/prog017/prog017.stdout b/testsuite/tests/ghci/prog017/prog017.stdout index 903660d369..57b1ba0d6c 100644 --- a/testsuite/tests/ghci/prog017/prog017.stdout +++ b/testsuite/tests/ghci/prog017/prog017.stdout @@ -68,8 +68,8 @@ "\10174" "\10174\10132" 2 2 "" -"\8704" -"\8704\8921" +"\8705" +"\8705\8921" 2 2 "" "\10193" "\10193\10193" diff --git a/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr b/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr index 5852074450..88c7e7c771 100644 --- a/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr +++ b/testsuite/tests/rename/should_compile/ExplicitForAllRules1.stderr @@ -1,4 +1,11 @@ +ExplicitForAllRules1.hs:46:31: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + ExplicitForAllRules1.hs:49:31: warning: [-Wunused-foralls (in -Wextra)] Unused quantified type variable ‘b’ In the rewrite rule "example7" diff --git a/testsuite/tests/rename/should_compile/T20609.hs b/testsuite/tests/rename/should_compile/T20609.hs new file mode 100644 index 0000000000..7e8955f29f --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609.hs @@ -0,0 +1,23 @@ +module T20609 where + +-- Triggers the warning (definition/binding sites): +-- ------------------------------------------------ + +forall x = () + +(∀) x = () + +fparam forall = () + +asPattern forall@Nothing = () + +localLet = let forall = () in forall + +{-# RULES "rule" forall forall. id forall = forall #-} + +{-# RULES "rule_sig" forall a. forall (forall :: a). id forall = forall #-} + +-- Does not trigger the warning (use sites): +-- ----------------------------------------- + +other = forall diff --git a/testsuite/tests/rename/should_compile/T20609.stderr b/testsuite/tests/rename/should_compile/T20609.stderr new file mode 100644 index 0000000000..a9958e2b85 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609.stderr @@ -0,0 +1,49 @@ + +T20609.hs:6:1: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609.hs:8:1: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘∀’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609.hs:10:8: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609.hs:12:11: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609.hs:14:16: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609.hs:16:25: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609.hs:18:40: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. diff --git a/testsuite/tests/rename/should_compile/T20609a.hs b/testsuite/tests/rename/should_compile/T20609a.hs new file mode 100644 index 0000000000..0cf753760f --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609a.hs @@ -0,0 +1,12 @@ +module T20609a where + +-- Triggers the warning (definition/binding sites): +-- ------------------------------------------------ + +data MyRecord a = R { forall :: a } + +-- Does not trigger the warning (use sites): +-- ----------------------------------------- + +x = forall (R { forall = () }) +f (R { forall = r }) = r diff --git a/testsuite/tests/rename/should_compile/T20609a.stderr b/testsuite/tests/rename/should_compile/T20609a.stderr new file mode 100644 index 0000000000..d828a1b269 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609a.stderr @@ -0,0 +1,7 @@ + +T20609a.hs:6:23: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. diff --git a/testsuite/tests/rename/should_compile/T20609b.hs b/testsuite/tests/rename/should_compile/T20609b.hs new file mode 100644 index 0000000000..2e08bdcee2 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609b.hs @@ -0,0 +1,13 @@ +module T20609b where + +-- Triggers the warning (definition/binding sites): +-- ------------------------------------------------ + +class MyClass c where + forall :: c -> () + +-- Does not trigger the warning (use sites): +-- ----------------------------------------- + +instance MyClass () where + forall = id diff --git a/testsuite/tests/rename/should_compile/T20609b.stderr b/testsuite/tests/rename/should_compile/T20609b.stderr new file mode 100644 index 0000000000..c356dde8b0 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609b.stderr @@ -0,0 +1,7 @@ + +T20609b.hs:7:3: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. diff --git a/testsuite/tests/rename/should_compile/T20609c.hs b/testsuite/tests/rename/should_compile/T20609c.hs new file mode 100644 index 0000000000..2e36f8c7e1 --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609c.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE PatternSynonyms #-} + +module T20609c where + +pattern Pat forall = forall + +pattern RPat { forall } = forall + diff --git a/testsuite/tests/rename/should_compile/T20609c.stderr b/testsuite/tests/rename/should_compile/T20609c.stderr new file mode 100644 index 0000000000..c22ead3d0b --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609c.stderr @@ -0,0 +1,14 @@ + +T20609c.hs:5:22: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. + +T20609c.hs:7:27: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. diff --git a/testsuite/tests/rename/should_compile/T20609d.hs b/testsuite/tests/rename/should_compile/T20609d.hs new file mode 100644 index 0000000000..bed945bcfa --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609d.hs @@ -0,0 +1,6 @@ +module T20609d where + +import Data.Word (Word8) + +foreign import ccall unsafe "forall" + forall :: IO Word8 diff --git a/testsuite/tests/rename/should_compile/T20609d.stderr b/testsuite/tests/rename/should_compile/T20609d.stderr new file mode 100644 index 0000000000..8060b3298f --- /dev/null +++ b/testsuite/tests/rename/should_compile/T20609d.stderr @@ -0,0 +1,7 @@ + +T20609d.hs:6:3: warning: [-Wforall-identifier (in -Wdefault)] + The use of ‘forall’ as an identifier + will become an error in a future GHC release. + Suggested fix: + Consider using another name, such as + ‘forAll’, ‘for_all’, or ‘forall_’. diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T index 2148470c66..8e55b3705a 100644 --- a/testsuite/tests/rename/should_compile/all.T +++ b/testsuite/tests/rename/should_compile/all.T @@ -177,3 +177,8 @@ test('T18302', expect_broken(18302), compile, ['']) test('T17853', [], multimod_compile, ['T17853', '-v0']) test('T19966', expect_broken(19966), compile, ['-fdefer-out-of-scope-variables']) test('T20472', normal, compile, ['']) +test('T20609', normal, compile, ['']) +test('T20609a', normal, compile, ['']) +test('T20609b', normal, compile, ['']) +test('T20609c', normal, compile, ['']) +test('T20609d', normal, compile, ['']) |