Opened 6 years ago

Closed 4 years ago

Last modified 4 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 Revisions:

Description

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 6 years ago by simonpj

  • Component changed from Compiler to Compiler (Type checker)
  • difficulty set to Unknown
  • Milestone set to _|_

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.

Simon

comment:2 Changed 4 years ago by michalt

  • Cc michal.terepeta@… added
  • Resolution set to fixed
  • Status changed from new to closed
  • Type of failure set to None/Unknown

Seems to be fixed in HEAD:

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

Test.hs:15:1:
    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 4 years ago by simonpj

  • Test Case set to 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

Simon

Note: See TracTickets for help on using tickets.