[GHC] #12987: Core lint error with levity polymorphism
#12987: Core lint error with levity polymorphism -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple LevityPolymorphism | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{ $ ghci -ignore-dot-ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Prelude> import GHC.Types Prelude GHC.Types> :set -XTypeInType Prelude GHC.Types> class NUM (a :: TYPE rep) where add :: a -> a -> a Prelude GHC.Types> }}} works, but with `-dcore-lint` I get a core lint error {{{ $ ghci -ignore-dot-ghci GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Prelude> import GHC.Types Prelude GHC.Types> :set -XTypeInType Prelude GHC.Types> :set -dcore-lint Prelude GHC.Types> class NUM (a :: TYPE rep) where add :: a -> a -> a *** Core Lint errors : in result of Tidy Core *** <no location info>: warning: In the type ‘forall a_a17Q. NUM a_a17Q => a_a17Q -> a_a17Q -> a_a17Q’ Ill-kinded argument in type or kind ‘a_a17Q -> a_a17Q’ type or kind ‘a_a17Q -> a_a17Q’ kind: TYPE rep_a17P <no location info>: warning: In the type ‘forall a_a17Q. NUM a_a17Q => a_a17Q -> a_a17Q -> a_a17Q’ Ill-kinded argument in type or kind ‘a_a17Q -> a_a17Q -> a_a17Q’ type or kind ‘a_a17Q -> a_a17Q -> a_a17Q’ kind: TYPE rep_a17P *** Offending Program *** add [InlPrag=INLINE] :: forall a_a17Q. NUM a_a17Q => a_a17Q -> a_a17Q -> a_a17Q [GblId[ClassOp], Arity=1, Caf=NoCafRefs, Str=DmdType <S,U>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=True) Tmpl= \ (@ (rep_a17P :: RuntimeRep)) (@ (a_a17Q :: TYPE rep_a17P)) (tpl_B1 [Occ=Once] :: NUM a_a17Q) -> tpl_B1 `cast` (N:NUM[0] <rep_a17P>_N <a_a17Q>_N :: (NUM a_a17Q :: Constraint) ~R# ((a_a17Q -> a_a17Q -> a_a17Q) :: *))}] add = \ (@ (rep_a17P :: RuntimeRep)) (@ (a_a17Q :: TYPE rep_a17P)) (tpl_B1 :: NUM a_a17Q) -> tpl_B1 `cast` (N:NUM[0] <rep_a17P>_N <a_a17Q>_N :: (NUM a_a17Q :: Constraint) ~R# ((a_a17Q -> a_a17Q -> a_a17Q) :: *)) $trModule1_r18t :: TrName [GblId, Caf=NoCafRefs, Str=DmdType] $trModule1_r18t = TrNameS "interactive"# $trModule2_r18D :: TrName [GblId, Caf=NoCafRefs, Str=DmdType] $trModule2_r18D = TrNameS "Ghci1"# $trModule :: Module [GblId, Caf=NoCafRefs, Str=DmdType] $trModule = Module $trModule1_r18t $trModule2_r18D $tc'C:NUM1_r18E :: TrName [GblId, Caf=NoCafRefs, Str=DmdType] $tc'C:NUM1_r18E = TrNameS "'C:NUM"# $tc'C:NUM :: TyCon [GblId, Caf=NoCafRefs, Str=DmdType] $tc'C:NUM = TyCon 13508714812303496948## 14031386194776682412## $trModule $tc'C:NUM1_r18E $tcNUM1_r18F :: TrName [GblId, Caf=NoCafRefs, Str=DmdType] $tcNUM1_r18F = TrNameS "NUM"# $tcNUM :: TyCon [GblId, Caf=NoCafRefs, Str=DmdType] $tcNUM = TyCon 18330307158587089132## 17437587248867430906## $trModule $tcNUM1_r18F *** End of Offense *** <no location info>: error: Compilation had errors *** Exception: ExitFailure 1 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12987> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12987: Core lint error with levity polymorphism -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism 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): I can reproduce this in GHC 8.0.2, but not in GHC HEAD: {{{ $ inplace/bin/ghc-stage2 --interactive GHCi, version 8.1.20161215: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci λ> import GHC.Types λ> :set -XTypeInType -dcore-lint λ> class NUM (a :: TYPE rep) where add :: a -> a -> a λ> :t add add :: NUM a => a -> a -> a }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12987#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12987: Core lint error with levity polymorphism -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: | LevityPolymorphism 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 Richard Eisenberg <rae@…>): In [changeset:"e7985ed23ddc68b6a2e4af753578dc1d9e8ab4c9/ghc" e7985ed2/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="e7985ed23ddc68b6a2e4af753578dc1d9e8ab4c9" Update levity polymorphism This commit implements the proposal in https://github.com/ghc-proposals/ghc-proposals/pull/29 and https://github.com/ghc-proposals/ghc-proposals/pull/35. Here are some of the pieces of that proposal: * Some of RuntimeRep's constructors have been shortened. * TupleRep and SumRep are now parameterized over a list of RuntimeReps. * This means that two types with the same kind surely have the same representation. Previously, all unboxed tuples had the same kind, and thus the fact above was false. * RepType.typePrimRep and friends now return a *list* of PrimReps. These functions can now work successfully on unboxed tuples. This change is necessary because we allow abstraction over unboxed tuple types and so cannot always handle unboxed tuples specially as we did before. * We sometimes have to create an Id from a PrimRep. I thus split PtrRep * into LiftedRep and UnliftedRep, so that the created Ids have the right strictness. * The RepType.RepType type was removed, as it didn't seem to help with * much. * The RepType.repType function is also removed, in favor of typePrimRep. * I have waffled a good deal on whether or not to keep VoidRep in TyCon.PrimRep. In the end, I decided to keep it there. PrimRep is *not* represented in RuntimeRep, and typePrimRep will never return a list including VoidRep. But it's handy to have in, e.g., ByteCodeGen and friends. I can imagine another design choice where we have a PrimRepV type that is PrimRep with an extra constructor. That seemed to be a heavier design, though, and I'm not sure what the benefit would be. * The last, unused vestiges of # (unliftedTypeKind) have been removed. * There were several pretty-printing bugs that this change exposed; * these are fixed. * We previously checked for levity polymorphism in the types of binders. * But we also must exclude levity polymorphism in function arguments. This is hard to check for, requiring a good deal of care in the desugarer. See Note [Levity polymorphism checking] in DsMonad. * In order to efficiently check for levity polymorphism in functions, it * was necessary to add a new bit of IdInfo. See Note [Levity info] in IdInfo. * It is now safe for unlifted types to be unsaturated in Core. Core Lint * is updated accordingly. * We can only know strictness after zonking, so several checks around * strictness in the type-checker (checkStrictBinds, the check for unlifted variables under a ~ pattern) have been moved to the desugarer. * Along the way, I improved the treatment of unlifted vs. banged * bindings. See Note [Strict binds checks] in DsBinds and #13075. * Now that we print type-checked source, we must be careful to print * ConLikes correctly. This is facilitated by a new HsConLikeOut constructor to HsExpr. Particularly troublesome are unlifted pattern synonyms that get an extra void# argument. * Includes a submodule update for haddock, getting rid of #. * New testcases: typecheck/should_fail/StrictBinds typecheck/should_fail/T12973 typecheck/should_run/StrictPats typecheck/should_run/T12809 typecheck/should_fail/T13105 patsyn/should_fail/UnliftedPSBind typecheck/should_fail/LevPolyBounded typecheck/should_compile/T12987 typecheck/should_compile/T11736 * Fixed tickets: #12809 #12973 #11736 #13075 #12987 * This also adds a test case for #13105. This test case is * "compile_fail" and succeeds, because I want the testsuite to monitor the error message. When #13105 is fixed, the test case will compile cleanly. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12987#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12987: Core lint error with levity polymorphism -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: | LevityPolymorphism Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T12987 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * testcase: => typecheck/should_compile/T12987 * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12987#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC