Opened 5 years ago

Closed 5 years ago

#7541 closed bug (fixed)

Unavoidable duplicate constraint warning

Reported by: blamario Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: typecheck/should_compile/T7541
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The "duplicate constraint" warning can be triggered in a context where it's impossible to remove it, because the constraints come with a type synonym.

The following standalone little module reproduces the problem:

{-# LANGUAGE FlexibleContexts, Rank2Types #-}

module Test where

type Constrained x y r = (Eq x, Eq y) => x -> y -> r
f :: Constrained String String ()
f = undefined

The warning is

Test.hs:7:6: Warning:
    Duplicate constraint(s): Eq String
    In the type signature for `f': f :: Constrained String String ()

The warning is present in 7.4.1 and 7.6.1, and presumably in the versions between as well.

Change History (2)

comment:1 Changed 5 years ago by simonpj@…

commit 5a6a223f855538112ec9d089425e34853fb3542b

Author: Simon Peyton Jones <>
Date:   Wed Jan 2 11:57:00 2013 +0000

    Add flag -fwarn-duplicate-constraints
    This fixes Trac #7541, and is on by default.
    Use -fno-warn-duplicate-constraints to switch it off.

 compiler/main/DynFlags.hs      |    5 ++++-
 compiler/typecheck/TcMType.lhs |    9 +++++----
 docs/users_guide/flags.xml     |    7 +++++++
 docs/users_guide/using.xml     |   19 +++++++++++++++++++
 4 files changed, 35 insertions(+), 5 deletions(-)

comment:2 Changed 5 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed
Test Case: typecheck/should_compile/T7541

OK I've added a flag to suppress duplicate constraint warnings.

Note: See TracTickets for help on using tickets.