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,843
    • Issues 4,843
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 453
    • Merge requests 453
  • 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
  • #16394

Closed
Open
Created Mar 05, 2019 by Day1721@trac-Day1721

GHC internal error while typechecking of instance definition

Hello. \\ This code won't typecheck because of GHC internal error.

{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds #-}

class C a where
    type T (n :: a)

--       v--DIFF--v
instance C a => C b => C (a, b) where
    type T '(n, m) = (T n, T m)

with error message:

Bug.hs:7:10: error:
    • GHC internal error: ‘T’ is not in scope during type checking, but it passed the renamer
      tcl_env of environment: [a1LS :-> Type variable ‘a’ = a :: *,
                               a1LT :-> Type variable ‘b’ = b :: *]
    • In the type instance declaration for ‘T’
      In the instance declaration for ‘C b => C (a, b)’
  |
7 |     type T (n, m) = (T n, T m)
  |          ^
Failed, no modules loaded.

but this works fine:

{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds #-}

class C a where
    type T (n :: a)

--       v--DIFF--v
instance (C a, C b) => C (a, b) where
    type T '(n, m) = (T n, T m)

Not sure is a bug, but either way it would be better to make more understandable error message

Trac metadata
Trac field Value
Version 8.6.3
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking