[Git][ghc/ghc][wip/T22141] Introduce -Wdata-kinds-tc warning
Ryan Scott (@RyanGlScott)
gitlab at gitlab.haskell.org
Sat Sep 30 23:40:15 UTC 2023
Ryan Scott pushed to branch wip/T22141 at Glasgow Haskell Compiler / GHC
Commits:
e721af5d by Ryan Scott at 2023-09-30T19:39:58-04:00
Introduce -Wdata-kinds-tc warning
- - - - -
8 changed files:
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- docs/users_guide/using-warnings.rst
- testsuite/tests/typecheck/should_compile/T22141a.stderr
- testsuite/tests/typecheck/should_compile/T22141b.stderr
- testsuite/tests/typecheck/should_compile/T22141c.stderr
- testsuite/tests/typecheck/should_compile/T22141d.stderr
- testsuite/tests/typecheck/should_compile/T22141e.stderr
Changes:
=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -695,6 +695,7 @@ data WarningFlag =
| Opt_WarnIncompleteRecordSelectors -- Since 9.10
| Opt_WarnBadlyStagedTypes -- Since 9.10
| Opt_WarnInconsistentFlags -- Since 9.8
+ | Opt_WarnDataKindsTC -- Since 9.10
deriving (Eq, Ord, Show, Enum)
-- | Return the names of a WarningFlag
@@ -808,6 +809,7 @@ warnFlagNames wflag = case wflag of
Opt_WarnIncompleteRecordSelectors -> "incomplete-record-selectors" :| []
Opt_WarnBadlyStagedTypes -> "badly-staged-types" :| []
Opt_WarnInconsistentFlags -> "inconsistent-flags" :| []
+ Opt_WarnDataKindsTC -> "data-kinds-tc" :| []
-- -----------------------------------------------------------------------------
-- Standard sets of warning options
@@ -948,7 +950,8 @@ standardWarnings -- see Note [Documenting warning flags]
Opt_WarnLoopySuperclassSolve,
Opt_WarnBadlyStagedTypes,
Opt_WarnTypeEqualityRequiresOperators,
- Opt_WarnInconsistentFlags
+ Opt_WarnInconsistentFlags,
+ Opt_WarnDataKindsTC
]
-- | Things you get with -W
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -2423,7 +2423,7 @@ instance Diagnostic TcRnMessage where
-- in GHC.Tc.Validity.
-> case thing of
Left _ -> ErrorWithoutFlag
- Right _ -> WarningWithoutFlag
+ Right _ -> WarningWithFlag Opt_WarnDataKindsTC
TcRnTypeSynonymCycle{}
-> ErrorWithoutFlag
TcRnZonkerMessage msg
=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -2563,6 +2563,26 @@ of ``-W(no-)*``.
issued. Another example is :ghc-flag:`-dynamic` is ignored when :ghc-flag:`-dynamic-too`
is passed.
+.. ghc-flag:: -Wdata-kinds-tc
+ :shortdesc: warn when an illegal use of a type or kind without
+ :extension:`DataKinds` is caught by the typechecker
+ :type: dynamic
+ :reverse: -Wno-data-kinds-tc
+
+ :since: 9.10.1
+
+ Introduced in GHC 9.10.1, this warns when an illegal use of a type or kind
+ (without having enabled the :extension:`DataKinds` extension) is caught in
+ the typechecker (hence the ``-tc`` suffix). These warnings complement the
+ existing :extensions:`DataKinds` checks (that have existed since
+ :extension:`DataKinds` was first introduced), which result in errors
+ instead of warnings.
+
+ This warning is scheduled to be changed to an error in a future GHC
+ version, at which point the :ghc-flag:`-Wdata-kinds-tc` flag will be
+ removed. Users can enable the :extension:`DataKinds` extension to avoid
+ issues (thus silencing the warning).
+
If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice.
It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's
sanity, not yours.)
=====================================
testsuite/tests/typecheck/should_compile/T22141a.stderr
=====================================
@@ -1,5 +1,5 @@
-T22141a.hs:8:1: warning: [GHC-68567]
+T22141a.hs:8:1: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘GHC.Num.Natural.Natural’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In the expansion of type synonym ‘Nat’
=====================================
testsuite/tests/typecheck/should_compile/T22141b.stderr
=====================================
@@ -1,5 +1,5 @@
-T22141b.hs:10:1: warning: [GHC-68567]
+T22141b.hs:10:1: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘GHC.Num.Natural.Natural’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In the expansion of type synonym ‘Nat’
=====================================
testsuite/tests/typecheck/should_compile/T22141c.stderr
=====================================
@@ -1,31 +1,31 @@
-T22141c.hs:10:11: warning: [GHC-68567]
+T22141c.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘(# *, * #)’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In the expansion of type synonym ‘T’
In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141c.hs:10:11: warning: [GHC-68567]
+T22141c.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘'[]’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141c.hs:10:11: warning: [GHC-68567]
+T22141c.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘'[GHC.Types.LiftedRep]’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141c.hs:10:11: warning: [GHC-68567]
+T22141c.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘[GHC.Types.LiftedRep,
GHC.Types.LiftedRep]’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141c.hs:10:11: warning: [GHC-68567]
+T22141c.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘Proxy T’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
=====================================
testsuite/tests/typecheck/should_compile/T22141d.stderr
=====================================
@@ -1,31 +1,31 @@
-T22141d.hs:10:11: warning: [GHC-68567]
+T22141d.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘(# * | * #)’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In the expansion of type synonym ‘T’
In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141d.hs:10:11: warning: [GHC-68567]
+T22141d.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘'[]’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141d.hs:10:11: warning: [GHC-68567]
+T22141d.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘'[GHC.Types.LiftedRep]’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141d.hs:10:11: warning: [GHC-68567]
+T22141d.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘[GHC.Types.LiftedRep,
GHC.Types.LiftedRep]’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141d.hs:10:11: warning: [GHC-68567]
+T22141d.hs:10:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘Proxy T’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
=====================================
testsuite/tests/typecheck/should_compile/T22141e.stderr
=====================================
@@ -1,18 +1,18 @@
-T22141e.hs:8:11: warning: [GHC-68567]
+T22141e.hs:8:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘42’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In the expansion of type synonym ‘T’
In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141e.hs:8:11: warning: [GHC-68567]
+T22141e.hs:8:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘GHC.Num.Natural.Natural’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
Suggested fix: Perhaps you intended to use DataKinds
-T22141e.hs:8:11: warning: [GHC-68567]
+T22141e.hs:8:11: warning: [GHC-68567] [-Wdata-kinds-tc (in -Wdefault)]
• An occurrence of ‘Proxy T’ in a kind requires DataKinds.
Future versions of GHC will turn this warning into an error.
• In a standalone kind signature for ‘D’: Proxy T -> Type
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e721af5d5641f8588c3e4e72208b63f574b791fc
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e721af5d5641f8588c3e4e72208b63f574b791fc
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230930/805e68b6/attachment-0001.html>
More information about the ghc-commits
mailing list