Opened 3 years ago

Closed 3 years ago

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

Description: modified (diff)

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 3 years ago by Simon Peyton Jones <simonpj@…>

comment:3 Changed 3 years ago by thomie

Component: CompilerCompiler (Type checker)
Milestone: 7.10.1
Resolution: fixed
Status: newclosed
Test Case: typecheck/should_fail/T9323.hs
Note: See TracTickets for help on using tickets.