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,393
    • Issues 4,393
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 376
    • Merge Requests 376
  • 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
  • #15986

Closed
Open
Opened Dec 02, 2018 by Ryan Scott@RyanGlScottMaintainer

Poor error message source location reporting with unsaturated type family

If you compile this program:

{-# LANGUAGE TypeFamilies #-}
module Bug where

newtype WrapChar f = MkWrapChar (f Char)
type family F a
type family T a
type instance T Int = WrapChar F

Then you'll get this error message:

$ /opt/ghc/8.6.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:7:15: error:
    • The type family ‘F’ should have 1 argument, but has been given none
    • In the type instance declaration for ‘T’
  |
7 | type instance T Int = WrapChar F
  |               ^

The thing is, the location of that caret is rather unfocused. It's pointing at T, but the real culprit is F!

I know that GHC can do better here because other error messages actually get this right. For instance, if you change the T Int instance to this:

type instance T Int = F

Then GHC will actually point to F in the resulting error message:

$ /opt/ghc/8.6.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:7:23: error:
    • Expecting one more argument to ‘F’
      Expected a type, but ‘F’ has kind ‘* -> *’
    • In the type ‘F’
      In the type instance declaration for ‘T’
  |
7 | type instance T Int = F
  |                       ^

If GHC can point to the right place in the source code in this situation, then it ought to get the earlier situation right as well.

Trac metadata
Trac field Value
Version 8.6.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.8.1
Milestone
8.8.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#15986