[GHC] #16263: GHC accepts illegal constraint in kind

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: TypeInType | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- GHC 8.6 accepts {{{#!hs 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: TypeInType => TypeInType, newcomer * milestone: => 8.8.1 Comment: Luckily, commit 2257a86daa72db382eb927df12a718669d5491f8 (`Taming the Kind Inference Monster`) has already fixed this in GHC HEAD: {{{ $ ~/Software/ghc5/inplace/bin/ghc-stage2 --interactive -XPolyKinds -XDataKinds GHCi, version 8.7.20190128: https://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> import Data.Kind λ> data Q :: Eq a => Type <interactive>:2:1: error: Illegal constraint in a kind: Eq a => * }}} We just need a regression test. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Terrific. But note that is should work for equality constraints like `(a ~ b)`, and I bet it does not. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Why should equality constraints be accepted? In fact, we moved in the opposite direction in https://phabricator.haskell.org/D5397#149402. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Good spot! But there is code in GHC that specifically deals with equality constraints (only) in kinds: see * `Inst.tcInstTyBinder`. * `dc_theta_illegal_constraint` in `TcHsType.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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Thoughts on comment:5, simonpj? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: GHC accepts illegal constraint in kind -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by 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. I'll adjust `TcValidity` to reject this kind up-front, as you suggest. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/128 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * milestone: 8.8.1 => 8.10.1 * differential: => https://gitlab.haskell.org/ghc/ghc/merge_requests/128 Comment: Replying to [comment:7 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/128 -------------------------------------+------------------------------------- Comment (by simonpj):
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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/128 -------------------------------------+------------------------------------- Comment (by mpickering): The test files weren't included in the patch for #16185 so this test still needs to be added separately. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds -------------------------------------+------------------------------------- Reporter: goldfire | Owner: simonpj Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/128 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * owner: (none) => simonpj Comment: Assigning to simonpj to take care of the remaining work in comment:10. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds -------------------------------------+------------------------------------- Reporter: goldfire | Owner: simonpj Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12102, #15872 | Differential Rev(s): Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/128 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #12102, #15872 Comment: Equality constraints in kinds are quite broken currently, as demonstrated in #12102 and #15872. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: simonpj
Type: bug | Status: patch
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.3
Resolution: | Keywords: TypeInType,
| newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #12102, #15872 | Differential Rev(s):
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/128
-------------------------------------+-------------------------------------
Comment (by Marge Bot

#16263: Rework GHC's treatment of constraints in kinds -------------------------------------+------------------------------------- Reporter: goldfire | Owner: simonpj Type: bug | Status: patch Priority: normal | Milestone: 8.10.1 Component: Compiler | Version: 8.6.3 Resolution: | Keywords: TypeInType, | newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12102, #15872 | Differential Rev(s): | https://gitlab.haskell.org/ghc/ghc/merge_requests/128, Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/499 -------------------------------------+------------------------------------- Changes (by RyanGlScott): * differential: 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 Comment: https://gitlab.haskell.org/ghc/ghc/merge_requests/499 adds a regression test. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16263#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16263: Rework GHC's treatment of constraints in kinds
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: simonpj
Type: bug | Status: closed
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.3
Resolution: fixed | Keywords: TypeInType,
| newcomer
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,
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/499
-------------------------------------+-------------------------------------
Changes (by simonpj):
* status: patch => closed
* testcase: => polykinds/T16263
* resolution: => fixed
Comment:
Landed as
{{{
commit 25c3dd39f7d446f66b5c967be81f80cd7facb509
Author: Simon Peyton Jones

#16263: Rework GHC's treatment of constraints in kinds
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: simonpj
Type: bug | Status: closed
Priority: normal | Milestone: 8.10.1
Component: Compiler | Version: 8.6.3
Resolution: fixed | Keywords: TypeInType,
| newcomer
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,
Wiki Page: | https://gitlab.haskell.org/ghc/ghc/merge_requests/499
-------------------------------------+-------------------------------------
Comment (by Marge Bot
participants (1)
-
GHC