:instances reports the wrong result when using TypeErrors
Summary
It seems like :instances
doesn't properly handle type errors and rule out instances.
Steps to reproduce
Given a file with this content:
{-# LANGUAGE TypeFamilies, FlexibleInstances, DataKinds, UndecidableInstances #-}
import GHC.TypeLits
data C = A | B
class Err (a :: C)
instance (TypeError ('Text "uh-oh")) => Err a
If you load it into a GHCi repl and run :instances "test"
you'll get this output
GHCi, version 8.11.0.20200522: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/xavier/.ghci
[1 of 1] Compiling Main ( ../Bug2.hs, interpreted )
Ok, one module loaded.
>:set -XDataKinds
>:instances 'A
instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10
Expected behavior
I would expect the output to be the following:
>:instances 'A
It seems like it's not ruling out an instance when it raises a TypeError
.
Environment
- GHC version used: GHC HEAD
Optional:
- Operating System: OS X
- System Architecture: