<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: 0.875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px;
}
body {
font-family: var(--default-regular-font, "GitLab Sans"),-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px; font-family: var(--default-regular-font, "GitLab Sans"),-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">
<h3 style="margin-top: 20px; margin-bottom: 10px;">
Ryan Scott pushed to branch wip/T22141 at <a href="https://gitlab.haskell.org/ghc/ghc">Glasgow Haskell Compiler / GHC</a>
</h3>
<h4 style="margin-top: 10px; margin-bottom: 10px;">
Commits:
</h4>
<ul>
<li>
<strong style="font-weight: bold;"><a href="https://gitlab.haskell.org/ghc/ghc/-/commit/2616c71dfbc014e94ce1fe19a57f707bc8641d2f">2616c71d</a></strong>
<div>
<span> by Ryan Scott </span> <i> at 2023-10-13T08:39:32-04:00 </i>
</div>
<pre class="commit-message" style='white-space: pre-wrap; display: block; font-size: 14px; color: #333238; position: relative; font-family: var(--default-mono-font, "GitLab Mono"),"JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; border-radius: 2px; margin: 0; padding: 8px 12px; border: 1px solid #dcdcde;'>More robust checking for DataKinds
As observed in #22141, GHC was not doing its due diligence in catching code
that should require `DataKinds` in order to use. Most notably, it was allowing
the use of arbitrary data types in kind contexts without `DataKinds`, e.g.,
```hs
data Vector :: Nat -> Type -> Type where
```
This patch revamps how GHC tracks `DataKinds`. The full specification is
written out in the `DataKinds` section of the GHC User's Guide, and the
implementation thereof is described in `Note [Checking for DataKinds]` in
`GHC.Tc.Validity`. In brief:
* We catch _type_-level `DataKinds` violations in the renamer. See
`checkDataKinds` in `GHC.Rename.HsType` and `check_data_kinds` in
`GHC.Rename.Pat`.
* We catch _kind_-level `DataKinds` violations in the typechecker, as this
allows us to catch things that appear beneath type synonyms. (We do *not*
want to do this in type-level contexts, as it is perfectly fine for a type
synonym to mention something that requires DataKinds while still using the
type synonym in a module that doesn't enable DataKinds.) See `checkValidType`
in `GHC.Tc.Validity`.
* There is now a single `TcRnDataKindsError` that classifies all manner of
`DataKinds` violations, both in the renamer and the typechecker. The
`NoDataKindsDC` error has been removed, as it has been subsumed by
`TcRnDataKindsError`.
* I have added `CONSTRAINT` is `isKindTyCon`, which is what checks for illicit
uses of data types at the kind level without `DataKinds`. Previously,
`isKindTyCon` checked for `Constraint` but not `CONSTRAINT`. This is
inconsistent, given that both `Type` and `TYPE` were checked by `isKindTyCon`.
Moreover, it thwarted the implementation of the `DataKinds` check in
`checkValidType`, since we would expand `Constraint` (which was OK without
`DataKinds`) to `CONSTRAINT` (which was _not_ OK without `DataKinds`) and
reject it. Now both are allowed.
* I have added a flurry of additional test cases that test various corners of
`DataKinds` checking.
Fixes #22141.
</pre>
</li>
</ul>
<h4 style="margin-top: 10px; margin-bottom: 10px;">
30 changed files:
</h4>
<ul>
<li class="file-stats">
<a href="#4aad0050db1a8a20db8bbca149111de99cb299c9">
compiler/GHC/Core/TyCon.hs
</a>
</li>
<li class="file-stats">
<a href="#2e5692f568fd7b67a6b172e2a60469da8392508c">
compiler/GHC/Driver/Flags.hs
</a>
</li>
<li class="file-stats">
<a href="#774d88050336ef660c7a219fb06c480c2fc639bc">
compiler/GHC/Driver/Session.hs
</a>
</li>
<li class="file-stats">
<a href="#892acbb198a9095c917740d3c1297b56df4e3b7e">
compiler/GHC/Rename/HsType.hs
</a>
</li>
<li class="file-stats">
<a href="#cfa41b5649933e5b12f7796e9d49b9dd6a0bc59f">
compiler/GHC/Rename/Pat.hs
</a>
</li>
<li class="file-stats">
<a href="#1dd9c7a6bbc222c976a6ec1c4b772232ae60f7e5">
compiler/GHC/Tc/Errors/Ppr.hs
</a>
</li>
<li class="file-stats">
<a href="#cdba811872892f235fe7059df1a6c538fba60816">
compiler/GHC/Tc/Errors/Types.hs
</a>
</li>
<li class="file-stats">
<a href="#6b3cd9d1473c3d051b8e6eb1d32fd53ca0c18c62">
compiler/GHC/Tc/Errors/Types/PromotionErr.hs
</a>
</li>
<li class="file-stats">
<a href="#9355bef855426caf5f526925edf351b20f9a86c4">
compiler/GHC/Tc/Gen/HsType.hs
</a>
</li>
<li class="file-stats">
<a href="#1db07ed8cd9bab6b217a8f5a140176d3cb8672fd">
compiler/GHC/Tc/Validity.hs
</a>
</li>
<li class="file-stats">
<a href="#e2c828ee9e003df518a07b05beaa6971e5c62eb0">
compiler/GHC/Types/Error/Codes.hs
</a>
</li>
<li class="file-stats">
<a href="#523e258f899a29c551e69a88115587d32ba73db1">
docs/users_guide/9.10.1-notes.rst
</a>
</li>
<li class="file-stats">
<a href="#acb4a75038c300e3a7e380e6baf0ae2be208862d">
docs/users_guide/exts/data_kinds.rst
</a>
</li>
<li class="file-stats">
<a href="#e16ae6db99f98868d3603a0c7df0bb6a793a330d">
docs/users_guide/using-warnings.rst
</a>
</li>
<li class="file-stats">
<a href="#b124f8e48574c8e6d122faa72abd0bd74953b502">
testsuite/tests/polykinds/T7433.stderr
</a>
</li>
<li class="file-stats">
<a href="#5fb62a0a0873020c35f22c55cb9bbabbec7f1892">
testsuite/tests/rename/should_fail/T22478e.hs
</a>
</li>
<li class="file-stats">
<a href="#34ec0e2feed75b3250a8bac12e8b4d878017cf72">
testsuite/tests/rename/should_fail/T22478e.stderr
</a>
</li>
<li class="file-stats">
<a href="#ee1f4159d61f3974e4462fc0122cb11c9a7df740">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141a.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#1fb853bf65ae439456caac5855dcd7acad1c37f4">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141a.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#92cbad71c05359d0b095b85f69e9fb5665bf1fe9">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141b.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#2612b8e3e5c1895ac104b9d2e905b7797e54b12f">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141b.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#094194b428de9b9a0150160c851acef16d8e36f3">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141c.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#506563d76c157fe8cc609e3c64428cc0d2725a73">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141c.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#3b196d26379bda4e9386f683221a8165883a4931">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141d.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#be9570b83069021de5e7ed84bd0fcd7927b6bce2">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141d.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#b75c75c918d491ac4a4e9041f493f912bb4a0060">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141e.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#5b67d9955a05ab74641a2b6dbf2eac904be1b6c9">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141e.stderr
</span>
</a>
</li>
<li class="file-stats">
<a href="#6a0ec1884cbd9c5e78302bbbd5062568f2b625e6">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141e_Aux.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#2167ea2577688cd5a80dfb79e38d2194a8072955">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141f.hs
</span>
</a>
</li>
<li class="file-stats">
<a href="#5ead39f22689ebc3c4bf35b074ba39825af025ce">
<span class="new-file">
+
testsuite/tests/typecheck/should_compile/T22141g.hs
</span>
</a>
</li>
</ul>
<h5 style="margin-top: 10px; margin-bottom: 10px; font-size: 0.875rem;">
The diff was not included because it is too large.
</h5>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #737278;">
—
<br>
<a href="https://gitlab.haskell.org/ghc/ghc/-/commit/2616c71dfbc014e94ce1fe19a57f707bc8641d2f">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.haskell.org">gitlab.haskell.org</a>. <a href="https://gitlab.haskell.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.haskell.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.haskell.org/ghc/ghc/-/commit/2616c71dfbc014e94ce1fe19a57f707bc8641d2f"}}</script>
</p>
</div>
</body>
</html>