[GHC] #14000: Out of scope errors with type families do not mention scope

GHC ghc-devs at haskell.org
Fri Aug 25 19:26:07 UTC 2017


#14000: Out of scope errors with type families do not mention scope
-------------------------------------+-------------------------------------
        Reporter:  EyalLotem         |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:  8.2.2
       Component:  Compiler          |              Version:  8.0.2
      Resolution:  fixed             |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Poor/confusing    |            Test Case:
  error message                      |  typecheck/should_fail/T14000
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by bgamari):

 * status:  merge => closed


Old description:

> {{{
> {-# LANGUAGE TypeFamilies #-}
> class C a where
>     type T a
>     c :: a -> T a
> main = c noSuchThing
> }}}
>
> yields:
> {{{
> test_bad_error.hs:6:1: error:
>     • Couldn't match expected type ‘T a’ with actual type ‘T a0’
>       NB: ‘T’ is a type function, and may not be injective
>       The type variable ‘a0’ is ambiguous
>     • In the ambiguity check for the inferred type for ‘main’
>       To defer the ambiguity check to use sites, enable
> AllowAmbiguousTypes
>       When checking the inferred type
>         main :: forall a. T a
> }}}
>
> This makes simple out-of-scope error seem very perplexing and is a huge
> regression in error quality.

New description:

 {{{#!hs
 {-# LANGUAGE TypeFamilies #-}
 class C a where
     type T a
     c :: a -> T a
 main = c noSuchThing
 }}}

 yields:
 {{{
 test_bad_error.hs:6:1: error:
     • Couldn't match expected type ‘T a’ with actual type ‘T a0’
       NB: ‘T’ is a type function, and may not be injective
       The type variable ‘a0’ is ambiguous
     • In the ambiguity check for the inferred type for ‘main’
       To defer the ambiguity check to use sites, enable
 AllowAmbiguousTypes
       When checking the inferred type
         main :: forall a. T a
 }}}

 This makes simple out-of-scope error seem very perplexing and is a huge
 regression in error quality.

--

Comment:

 Merged to `ghc-8.2` with a0558a5af9bdba208b629d04d729849166f565fd.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14000#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list