[GHC] #16384: GHC infers ill-kinded type for typed TH splice with unlifted values

#16384: GHC infers ill-kinded type for typed TH splice with unlifted values -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- As noted in the [https://github.com/ghc-proposals/ghc-proposals/pull/209 Levity Polymorphic Lift proposal], GHC infers an ill-kinded type for typed splices with unlifted values. For example, in GHC 8.6.3 {{{ ghci> :t [|| 1# ||] [|| 1# ||] :: Q (TExp Int#) }}} `TExp Int#` is ill-kinded, so this type makes no sense. And GHC knows it's ill-kinded, because it will actually reject the program if you supply the type yourself. {{{ ghci> [|| 1# ||] :: Q (TExp Int#) <interactive>:12:23: error: • Expecting a lifted type, but ‘Int#’ is unlifted • In the first argument of ‘TExp’, namely ‘Int#’ In the first argument of ‘Q’, namely ‘(TExp Int#)’ In an expression type signature: Q (TExp Int#) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16384 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16384: GHC infers ill-kinded type for typed TH splice with unlifted values -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: 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): Core Lint will complain about it as well: {{{#!hs {-# LANGUAGE MagicHash #-} {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -dcore-lint #-} module Bug where import GHC.Exts wat :: () -> Int# wat _ = $$([|| 1# ||]) }}} {{{ $ /opt/ghc/8.6.3/bin/ghc Bug.hs [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) *** Core Lint errors : in result of hscCompileExpr *** <no location info>: warning: In the expression: unsafeTExpCoerce @ Int# sat_s3Mx Kinds don't match in type application: Type variable: a_a3mR :: * Arg type: Int# :: TYPE 'IntRep Linted Arg kind: TYPE 'IntRep *** Offending Program *** let { sat_s3Mx :: Q Exp [LclId] sat_s3Mx = let { sat_s3Mw :: Lit [LclId] sat_s3Mw = let { sat_s3M1 :: Integer [LclId] sat_s3M1 = S# 1# } in intPrimL sat_s3M1 } in litE sat_s3Mw } in unsafeTExpCoerce @ Int# sat_s3Mx *** End of Offense *** <no location info>: error: Compilation had errors }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16384#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16384: GHC infers ill-kinded type for typed TH splice with unlifted values -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 Resolution: | Keywords: 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 harpocrates): * cc: harpocrates (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16384#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC