#15355 closed bug (worksforme)

Functional dependencies can get GHC to print "UnkSkol"

Reported by: goldfire Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.4.3
Keywords: FunctionalDependencies Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

When I say

class C a b | a -> b where
  foo :: a -> b

instance C Int Bool where
  foo = (>0)

blah :: C Int Double => Int -> _a
blah = foo

I get

    • Couldn't match type ‘Double’ with ‘Bool’
        arising from a functional dependency between constraints:
          ‘C Int Bool’ arising from a use of ‘foo’ at Scratch.hs:51:8-10
          ‘C Int Double’ arising from UnkSkol at Scratch.hs:51:1-10
    • In the expression: foo
      In an equation for ‘blah’: blah = foo

There are actually two problems:

  1. If we replace _a with Double, GHC accepts the program. I'm not sure it should. But that's a larger problem than...
  1. ... when it prints the error, it says UnkSkol. It probably shouldn't.

This ticket is about the second problem, because the first one require more fundep love than is usually on offer around here.

Erroring here is reasonable enoug

Change History (2)

comment:1 Changed 14 months ago by simonpj

Re (1), see Trac #12466 for a long discussion, and Note [Given errors] in TcErrors. Bottom line, we suppress some Given errors, which represent unreachable code, as here.

Re (2) HEAD seems better

T15355.hs:12:8: error:
    * Couldn't match type `Double' with `Bool'
        arising from a functional dependency between constraints:
          `C Int _a' arising from a use of `foo' at T15355.hs:12:8-10
          `C Int Double'
            arising from the type signature for:
                           blah :: forall _a. C Int Double => Int -> _a
            at T15355.hs:11:1-33
    * In the expression: foo
      In an equation for `blah': blah = foo
   |
12 | blah = foo

   |        ^^^

comment:2 Changed 14 months ago by goldfire

Resolution: worksforme
Status: newclosed

I'm satisfied with that.

Note: See TracTickets for help on using tickets.