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,322
    • Issues 4,322
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 362
    • Merge Requests 362
  • 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
  • #11451

Closed
Open
Opened 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
Assignee
Assign to
8.0.1
Milestone
8.0.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#11451