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,831
    • Issues 4,831
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 449
    • Merge requests 449
  • 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
  • #11451

Closed
Open
Created Jan 18, 2016 by Simon Peyton Jones@simonpjDeveloper

Inconsistent warnings for unused binders in type and instance declarations

Consider compiling this with -Wunused-matches:

class C a where
  op :: a -> a
instance C (Maybe a) where
  op x = x

We get no warnings, even though a is patently unused.

But suppose we add an associated type

class C a where
  type T a
  op :: a -> a
instance C (Maybe a) where
  type T (Maybe a) = Int  -- Warning on this line
  op x = x

Now we get a warning for an unused binding for a on the type instance.

Edward complained about this inconsistent behaviour in this email thread.

My thoughts:

  • Currently GHC does not warn about type variables bound in the instance head but unused in the where part. Fixing that might be a good idea, but would be a new feature.
  • However, given that we don't warn about them, we should definitely not warn about instance type variables being unused in an associated type. But we could warn about ones specific to the associated type itself. Eg
class C2 a where
  type T2 a b
instance C2 (Maybe a) where
  type T2 (Maybe a) x = Int    -- Line XXX

Here, on line XXX, we might reasonably warn about the unused x, but not about the unused a.

Trac metadata
Trac field Value
Version 7.10.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ekmett
Operating system
Architecture
Edited Mar 10, 2019 by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking