#9323 closed bug (fixed)

Confusing type error behaviour

Reported by: simonpj Owned by:
Priority: normal Milestone: 7.10.1
Component: Compiler (Type checker) Version: 7.8.3
Keywords: Cc: qdunkan@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T9323.hs
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by simonpj)

Compile this example with GHC 7.8.3.

module Foo where

broken :: [Int]
broken = ()

ambiguous :: a -> String
ambiguous _ = show 0

You get

    Couldn't match expected type ‘[Int]’ with actual type ‘()’
    In the expression: ()
    In an equation for ‘broken’: broken = ()

    No instance for (Show a0) arising from a use of ‘show’
    The type variable ‘a0’ is ambiguous

(and a similar ambiguous (Num a0) error).

But if you comment out broken, the program compiles, using the defaulting rules to choose a0 = Integer.

This is obviously wrong.

Reported by Evan Laforge.

Change History (3)

comment:1 Changed 17 months ago by simonpj

  • Description modified (diff)
  • Version changed from 7.8.2 to 7.8.3

Everything is fine in HEAD. (I don't know which of the many changes between 7.8 and HEAD is responsible.)

I'll add a regression test. But I don't propose to fix 7.8.


comment:2 Changed 17 months ago by Simon Peyton Jones <simonpj@…>

comment:3 Changed 13 months ago by thomie

  • Component changed from Compiler to Compiler (Type checker)
  • Milestone set to 7.10.1
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to typecheck/should_fail/T9323.hs
Note: See TracTickets for help on using tickets.