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,391
    • Issues 4,391
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19649

Closed
Open
Opened Apr 05, 2021 by Ryan Scott@RyanGlScottMaintainer

HsOuterImplicits for associated type family instances are incorrect

While working on #13512, I noticed a buglet in the way that GHC implicitly quantifies type variables in associated type family instances. If you compile the following program with -ddump-rn-ast on HEAD:

{-# LANGUAGE TypeFamilies #-}
module Bug where

class C a where
  type T a b

instance C [a] where
  type T [a] b = Either a b

This is what the T instance's AST will look like:

       (ClsInstD
        ...
        (ClsInstDecl
         ...
         (L
          ...
          (HsSig
           (NoExtField)
           (HsOuterImplicit
            [{Name: a_agi}])
           ...
         [(L
           ...
           (TyFamInstDecl
            ...
            (FamEqn
             ...
             (L
              ...
              {Name: Bug.T})
             (HsOuterImplicit
              [{Name: a_agi}
              ,{Name: b_agj}])
             ...)))]))))

The suspicious part is the second HsOuterImplicit for the T TyFamInstDecl. It claims that it implicitly quantifies both a and b, but this isn't true—the a should already be in scope due to the first HsOuterImplicit for the instance head. I would expect the second HsOuterImplicit to only implicitly quantify b.

I'm not aware of any user-observable behavior that results from this bug, but it does cause issues when implementing a fix for #13512. This bug can be fixed independently of #13512, so I decided to open a separate issue for it.

Assignee
Assign to
9.4.1
Milestone
9.4.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#19649