Opened 5 months ago

Closed 5 months ago

#8592 closed bug (fixed)

FunDep error message regression

Reported by: nomeata Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:


This code (provided by Cale Gibbard)

{-# LANGUAGE FunctionalDependencies, FlexibleContexts #-}

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

instance C Integer Integer where
  foo = id

f :: Integer -> String 
f = foo

produced this error message in GHC 7.6:

    Couldn't match type `Integer' with `String'
    When using functional dependencies to combine
      C Integer Integer,
        arising from the dependency `a -> b'
        in the instance declaration at fundep.hs:6:10
      C Integer String, arising from a use of `foo' at fundep.hs:10:5-7
    In the expression: foo
    In an equation for `f': f = foo

but this one with GHC HEAD

    No instance for (C Integer String) arising from a use of ‛foo’
    In the expression: foo
    In an equation for ‛f’: f = foo

which seems to be a regression.

It may be that either message is fine (it seems to be in this case), In that case, this bug is about the test suite not having a test case for where we do want to see the When using functional dependencies to combine message.

Change History (7)

comment:1 Changed 5 months ago by nomeata

Branch wip/T592 contains some refactoring of the FunDeps code that I don’t want to push to master before this issue is cleared, and the code tested.

comment:3 Changed 5 months ago by nfrisby

My 2 cents: the error message mentioning functional dependencies is far more informative than the one just saying there's no instance for C Integer String. So, in my opinion, the change that prompted this ticket is indeed a regression.

comment:4 Changed 5 months ago by nomeata

More examples at (Collecting these links here because I want to ensure they will enter the testsuite.)

comment:5 Changed 5 months ago by nomeata

Bah, I need more sleep. Just because the test suite does not contain any examples of the error message now, it does not mean that it did not have in the past. And indeed – git log -G to the rescue – there are examples like FD3, and commit [69f0da5ddaf90a5fa9eec406ec96a0256428fed9/testsuite] (April 2013, SPJ) updated the output to what it is now, without the “When using functional dependencies to combine” message.

Therefore I conclude that the change of output is deliberate, and this bug is just about finding out whether that kind of error message can still occur (in which case a testcase would be nice), or if it is dead code that should be removed.

comment:6 Changed 5 months ago by Joachim Breitner <mail@…>

In 9d7cbbcf625bc103d9fd086e9fcf99cb5c4b56ea/ghc:

Remove code that generates FunDep error message context

as it seems that this code is now dead (due to
[Dropping derived constraints]) (See #8592)

comment:7 Changed 5 months ago by nomeata

  • Resolution set to fixed
  • Status changed from new to closed

As discussed with SPJ it seems that the such error messages no longer occur. I have removed the code that generates them, closing this bug.

Note: See TracTickets for help on using tickets.