Opened 8 years ago

Closed 6 years ago

Last modified 6 years ago

#3023 closed bug (fixed)

Wrong inferred type shown

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.10.1
Keywords: Cc: lennart@…, michal.terepeta@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: indexed-types/should_compile/T3023
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When the warning for missing type signatures is turned on the displayed type is sometimes totally bogus.

{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}
module Bug where

class C a b | a -> b, b -> a where
    f :: a -> b

instance C Int Bool where
    f = undefined
instance (C a c, C b d) => C (a -> b) (c -> d) where
    f = undefined

foo :: Int -> Int
foo = undefined

bar = f foo

GHC says:

    Warning: Definition but no type signature for `bar'
             Inferred type: bar :: c -> d

The type for bar is, of course, Bool->Bool, and nothing else.

-- Lennart

Change History (3)

comment:1 Changed 8 years ago by simonpj

Component: CompilerCompiler (Type checker)
difficulty: Unknown
Milestone: _|_

Hmm good point. It happens because bar is monomorphic, so we don't solve its constraints until the end (by which time a call to bar might have fixed its type). But since we don't solve its constraints we don't propagate its fundeps either.

It's not life threatening, so I'm going to leave this open for now, pending that Glorious Day when we finally have type functions etc fully implemented.


comment:2 Changed 6 years ago by michalt

Cc: michal.terepeta@… added
Resolution: fixed
Status: newclosed
Type of failure: None/Unknown

Seems to be fixed in HEAD:

[1 of 1] Compiling Bug              ( Test.hs, Test.o )

    Warning: Top-level binding with no type signature:
               bar :: Bool -> Bool

This is with:

The Glorious Glasgow Haskell Compilation System, version 7.1.20101008

comment:3 Changed 6 years ago by simonpj

Test Case: indexed-types/should_compile/T3023

Ah yes, I did fix this as part of a recent patch. Thanks for closing it. I'll add a regression test


Note: See TracTickets for help on using tickets.