#16263 closed bug (fixed)
Rework GHC's treatment of constraints in kinds
Reported by: | goldfire | Owned by: | simonpj |
---|---|---|---|
Priority: | normal | Milestone: | 8.10.1 |
Component: | Compiler | Version: | 8.6.3 |
Keywords: | TypeInType, newcomer | Cc: | |
Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
Type of failure: | None/Unknown | Test Case: | polykinds/T16263 |
Blocked By: | Blocking: | ||
Related Tickets: | #12102, #15872 | Differential Rev(s): | https://gitlab.haskell.org/ghc/ghc/merge_requests/128, https://gitlab.haskell.org/ghc/ghc/merge_requests/499 |
Wiki Page: |
Description
GHC 8.6 accepts
data Q :: Eq a => Type
It shouldn't, as we can't have Eq a
as a constraint in kinds. Note that writing a constructor for Q
is rejected.
Change History (16)
comment:1 Changed 8 months ago by
Keywords: | newcomer added |
---|---|
Milestone: | → 8.8.1 |
comment:2 Changed 8 months ago by
Terrific. But note that is should work for equality constraints like (a ~ b)
, and I bet it does not.
comment:3 Changed 8 months ago by
Why should equality constraints be accepted? In fact, we moved in the opposite direction in https://phabricator.haskell.org/D5397#149402.
comment:4 Changed 8 months ago by
Good spot!
But there is code in GHC that specifically deals with equality constraints (only) in kinds: see
Inst.tcInstTyBinder
.dc_theta_illegal_constraint
inTcHsType.tcTyVar
(which deals with promoting data constructors)
I talked with Richard about this last night. I think we agreed that we can systematically and consistently support equality constraints in types. If so, we should un-do the commit you reference.
comment:5 Changed 8 months ago by
OK, and that's all well and good, but surely that ought to be the subject of a separate ticket? This one is just about GHC blindly accepting a (non-equality) constraint in a kind, which is something that we ought to just reject.
comment:7 follow-up: 8 Changed 7 months ago by
Thanks for the ping. Fixing this will fit right into my work on #16185 (see wip/T16185
) where I have already written new Notes on constraints in kinds.
I'll adjust TcValidity
to reject this kind up-front, as you suggest.
comment:8 Changed 7 months ago by
Differential Rev(s): | → https://gitlab.haskell.org/ghc/ghc/merge_requests/128 |
---|---|
Milestone: | 8.8.1 → 8.10.1 |
Status: | new → patch |
Summary: | GHC accepts illegal constraint in kind → Rework GHC's treatment of constraints in kinds |
Replying to simonpj:
Thanks for the ping. Fixing this will fit right into my work on #16185 (see
wip/T16185
) where I have already written new Notes on constraints in kinds.
OK, I didn't realize that you were directly working on fixing this. In that case, I'll retitle this ticket to reflect your more ambitious goals.
I'll adjust
TcValidity
to reject this kind up-front, as you suggest.
By "this kind", I assume you mean Eq a => Type
from the original example? If so, yes, rejecting that (and adding a test case for it) would be wonderful.
comment:9 Changed 7 months ago by
By "this kind", I assume you mean Eq a => Type from the original example? If so, yes, rejecting that (and adding a test case for it) would be wonderful.
Yes, exactly.
comment:10 Changed 7 months ago by
The test files weren't included in the patch for #16185 so this test still needs to be added separately.
comment:11 Changed 7 months ago by
Owner: | set to simonpj |
---|
Assigning to simonpj to take care of the remaining work in comment:10.
comment:12 Changed 7 months ago by
Related Tickets: | → #12102, #15872 |
---|
comment:14 Changed 7 months ago by
Differential Rev(s): | https://gitlab.haskell.org/ghc/ghc/merge_requests/128 → https://gitlab.haskell.org/ghc/ghc/merge_requests/128, https://gitlab.haskell.org/ghc/ghc/merge_requests/499 |
---|
https://gitlab.haskell.org/ghc/ghc/merge_requests/499 adds a regression test.
comment:15 Changed 7 months ago by
Resolution: | → fixed |
---|---|
Status: | patch → closed |
Test Case: | → polykinds/T16263 |
Landed as
commit 25c3dd39f7d446f66b5c967be81f80cd7facb509 Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Wed Mar 6 10:17:12 2019 +0000 Test Trac #16263 testsuite/tests/polykinds/T16263.hs | 7 +++++++ testsuite/tests/polykinds/T16263.stderr | 2 ++ testsuite/tests/polykinds/all.T | 1 + 3 files changed, 10 insertions(+)
Luckily, commit 2257a86daa72db382eb927df12a718669d5491f8 (
Taming the Kind Inference Monster
) has already fixed this in GHC HEAD:We just need a regression test.