Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,248
    • Issues 4,248
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17057

Closed
Open
Opened Aug 12, 2019 by sheaf@trac-sheafDeveloper

Partially applied type family causes GHC internal error since GHC 8.8

On GHC 8.8.0.20190721, the following program

{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE GADTs               #-}
{-# LANGUAGE PolyKinds           #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies        #-}
{-# LANGUAGE TypeApplications    #-}

module Bug where

import Data.Kind
  ( Type )
import Data.Proxy
  ( Proxy(Proxy) )


data HList :: [Type] -> Type where

type family Foo (xs :: [Type]) (ys :: [Type]) :: [Type] where

foo :: forall (is :: [Type]). HList is -> HList (Foo is)
foo = case Proxy @is of
        _ -> undefined

causes a GHC internal error:

bug.hs:21:50: error:
    * Expecting one more argument to `Foo is'
      Expected kind `[*]', but `Foo is' has kind `[*] -> [*]'
    * In the first argument of `HList', namely `(Foo is)'
      In the type signature:
        foo :: forall (is :: [Type]). HList is -> HList (Foo is)
   |
21 | foo :: forall (is :: [Type]). HList is -> HList (Foo is)
   |

bug.hs:22:19: error:
    * GHC internal error: `is' is not in scope during type checking, but it passed the renamer
      tcl_env of environment: []
    * In the type `is'
      In the expression: Proxy @is
      In the expression: case Proxy @is of { _ -> undefined }
   |
22 | foo = case Proxy @is of
   |                   ^^

On GHC 8.6.5, the internal error does not occur and as expected we simply get an error for a partially applied type family.

bug.hs:21:50: error:
    * Expecting one more argument to `Foo is'
      Expected kind `[*]', but `Foo is' has kind `[*] -> [*]'
    * In the first argument of `HList', namely `(Foo is)'
      In the type signature:
        foo :: forall (is :: [Type]). HList is -> HList (Foo is)
   |
21 | foo :: forall (is :: [Type]). HList is -> HList (Foo is)
   |

This came up after I had modified a type family by adding an extra argument, and had forgotten to pass in that extra argument somewhere.

Edited Aug 12, 2019 by sheaf
Assignee
Assign to
8.8.2
Milestone
8.8.2 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#17057