[GHC] #14086: Empty case does not detect kinds
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: low | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs {-# language TypeInType, EmptyCase #-} module Silly where import Data.Kind f :: Type -> Int f x = case x of }}} GHC warns {{{ Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: _ :: * }}} In fact, `Type` is only a type because of `TypeInType`. It has no actual values, so the empty case is exhaustive. To be honest, I kind of wish GHC would give me a warning for doing something so silly as to even give a function an argument of type `Type`, but I imagine that might be hard. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: low | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: RyanGlScott (added) Comment: I'm somewhat surprised this doesn't work, given that `Type` expands to `TYPE LiftedRep`, and `TYPE` is itself a datatype with no constructors. Granted, it is a somewhat magical datatype, but perhaps that just means we need to adjust the magicks appropriately for the `EmptyCase` pattern-match exhaustivity checker's purposes. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: low | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * keywords: => TypeInType -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: patch Priority: low | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3819 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3819 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: patch Priority: low | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3819 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ryan Scott <ryan.gl.scott@…>): In [changeset:"a267580e4ab37115dcc33f3b8a9af67b9364da12/ghc" a267580/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a267580e4ab37115dcc33f3b8a9af67b9364da12" Don't warn when empty casing on Type Summary: `Type` (a.k.a. `TYPE LiftedRep`) can be used at the type level thanks to `TypeInType`. However, expressions like ```lang=haskell f :: Type -> Int f x = case x of {} ``` were falsely claiming that the empty case on the value of type `Type` was non-exhaustive. The reason is a bit silly: `TYPE` is technically not an empty datatype in GHC's eyes, since it's a builtin, primitive type. To convince the pattern coverage checker otherwise, this adds a special case for `TYPE`. Test Plan: make test TEST=T14086 Reviewers: gkaracha, austin, bgamari, goldfire Reviewed By: goldfire Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #14086 Differential Revision: https://phabricator.haskell.org/D3819 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: closed Priority: low | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: error/warning at compile-time | pmcheck/should_compile/T14086 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3819 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * testcase: => pmcheck/should_compile/T14086 * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14086: Empty case does not detect kinds -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: closed Priority: low | Milestone: 8.4.1 Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: fixed | Keywords: TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: error/warning at compile-time | pmcheck/should_compile/T14086 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3819 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ryan Scott <ryan.gl.scott@…>): In [changeset:"4f1f9868ae79b5730c6aa14b05394d3f1d10a857/ghc" 4f1f9868/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="4f1f9868ae79b5730c6aa14b05394d3f1d10a857" Change isClosedAlgType to be TYPE-aware, and rename it to pmIsClosedType Summary: In a267580e4ab37115dcc33f3b8a9af67b9364da12, I somewhat awkwardly inserted a special case for `TYPE` in the `EmptyCase` coverage checker. Instead of placing it there, @mpickering noted that `isClosedAlgType` would be a better fit for it. I do just that in this patch. I also renamed `isClosedAlgType` to `pmIsClosedType`, reflecting the fact that `TYPE` technically isn't an algebraic type (it's a primitive one), and that its behavior is pattern-match coverage checking-oriented. I also moved it to `Check`, which is a better home for this function than `Type`. Luckily, the only call sites for `isClosedAlgType` were in the pattern-match coverage checker anyways, so this change is simple enough. Test Plan: ./validate Reviewers: mpickering, austin, goldfire, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie, mpickering GHC Trac Issues: #14086 Differential Revision: https://phabricator.haskell.org/D3830 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14086#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC