Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,842
    • Issues 4,842
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 457
    • Merge requests 457
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19495

Closed
Open
Created Mar 05, 2021 by Sebastian Graf@sgraf812Developer

Tc trace of checkValidType panics in tcTypeKind for T16391b

In !2218 (comment 335959), I triggered a panic in tcTypeKind. I thought that my branch was responsible, but then figured out that without -ddump-tc-trace, there was no panic. Then I tried -ddump-tc-trace on T16391b:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module T16391b where

import GHC.Exts

type family T (r :: RuntimeRep) :: TYPE r

foo :: T r
foo = foo

And sure enough, that panics on HEAD:

checkValidTypeghc: panic! (the 'impossible' happened)
  (GHC version 9.1.20210305:
        tcTypeKind
  forall (r :: RuntimeRep). T r
  [r_aw2[sk:2]]
  T r_aw2[sk:2] :: TYPE r_aw2[sk:2]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/GHC/Utils/Panic.hs:181:37 in ghc:GHC.Utils.Panic
        pprPanic, called at compiler/GHC/Core/Type.hs:2660:18 in ghc:GHC.Core.Type

... when checkValidType (I think) ultimately would have printed the following expected error:

T16391b.hs:10:8: error:
    • Quantified type's kind mentions quantified type variable
        type: ‘T 'LiftedRep’
      where the body of the forall has this kind: ‘TYPE r’
    • In the type signature: foo :: T r
   |
10 | foo :: T r
   |        ^^^

It's a matter of printing the error message before calling tcTypeKind:

checkValidType ctxt ty
  = do { traceTc "checkValidType" (ppr ty <+> text "::" <+> ppr (tcTypeKind ty))
       ; rankn_flag  <- xoptM LangExt.RankNTypes
...
       ; checkNoErrs $
         do { check_type ve ty
            ; checkUserTypeError ty
            ; traceTc "done ct" (ppr ty) }
...
       ; traceTc "checkValidType done" (ppr ty <+> text "::" <+> ppr (tcTypeKind ty)) }

I suggest we simply delete the <+> text "::" <+> ppr (tcTypeKind ty) of the first traceTc.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking