#15232 closed bug (fixed)

TypeError is reported as "redundant constraint" starting with GHC 8.2

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

Description

The following program compiles fine on GHC 8.0.2, but GHC 8.2.2 issues a warning, complaining that TypeError is a redundant constraint. This makes it very inconvenient to use TypeError with type classes.

{-# OPTIONS_GHC -Wredundant-constraints -Wall -Werror #-}
import GHC.TypeLits (TypeError, ErrorMessage(..))

class C a where f :: a -> a
instance {-# OVERLAPPING #-} C Int where f _ = 42
instance {-# OVERLAPPABLE #-} TypeError ( 'Text "Only Int is supported" ) => C a where f = undefined

main :: IO ()
main = print $ f (42::Int)

Change History (3)

comment:1 Changed 16 months ago by Ben Gamari <ben@…>

In 5026840f/ghc:

testsuite: Add test for #15232

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15232

Differential Revision: https://phabricator.haskell.org/D4807

comment:2 Changed 16 months ago by Ben Gamari <ben@…>

In d66ca011/ghc:

typecheck: Don't warn about "redundant" TypeError constraints

Summary: This fixes #15232, where we would warn about `TypeError` constraints being redundant.

Test Plan: Validate

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15232

Differential Revision: https://phabricator.haskell.org/D4808

comment:3 Changed 16 months ago by bgamari

Milestone: 8.2.38.6.1
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.