Skip to content
GitLab
Projects Groups Snippets
  • /
  • 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 5,254
    • Issues 5,254
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 562
    • Merge requests 562
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17053
Closed
Open
Issue created Aug 10, 2019 by InThisStyle10s6p@trac-InThisStyle10s6p

`-Wredundant-constraints` depends on the ordering of constraints with overlapping superclasses

Summary

The -Wredundant-constraints flag does not result in a warning when it should, due to the ordering of constraints.

Steps to reproduce

In the following code

{-# OPTIONS_GHC -Wredundant-constraints #-}
{-# OPTIONS_GHC -Werror #-}

module Test where

class A a where
  a :: a -> a

class A a => B a where
  b :: a

class A a => C a where

noWarning :: (C a, B a) => a
noWarning = a b

warning :: (B a, C a) => a
warning = a b

I get only the error

Test.hs:17:1: error: [-Wredundant-constraints, -Werror=redundant-constraints]
    • Redundant constraint: C a
    • In the type signature for:
           warning :: forall a. (B a, C a) => a
   |
17 | warning :: (B a, C a) => a
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected behavior

There should be two errors, one for warning and one for noWarning. This would be in line with the behaviour of GHC with the constraints (Eq a, Ord a) and (Ord a, Eq a), both of which result in warnings in similar situations.

Environment

  • GHC version used: 8.6.5
Edited Aug 11, 2019 by InThisStyle10s6p
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking