Opened 3 years ago

Closed 3 years ago

#12151 closed bug (fixed)

GHC 8 allows ambiguous type without AllowAmbiguousTypes

Reported by: thomie Owned by:
Priority: normal Milestone: 8.0.2
Component: Compiler (Type checker) Version: 8.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: typecheck/should_fail/T12151
Blocked By: Blocking:
Related Tickets: #7437 Differential Rev(s):
Wiki Page:


This module compiles with GHC 8:

{-# LANGUAGE DefaultSignatures #-}
-- {-# LANGUAGE AllowAmbiguousTypes #-} -- Not required with GHC 8.0.1.

module T12151 where

class Put a where
    put :: a

    default put :: t  -- This should be `a` instead of `t`
    put = undefined

GHC 7.10 required AllowAmbiguousTypes, to defer the ambiguity check to use sites.

(Example extracted from the description of #7437)

Change History (3)

comment:1 Changed 3 years ago by Simon Peyton Jones <simonpj@…>

In 85aa6ef0/ghc:

Check generic-default method for ambiguity

Fixes Trac #7497 and #12151.   In some earlier upheaval I introduced
a bug in the ambiguity check for genreric-default method.

This patch fixes it.  But in fixing it I realised that the
sourc-location of any such error message was bogus, so I fixed
that too, which involved a slightly wider change; see the
comments with TcMethInfo.

comment:2 Changed 3 years ago by simonpj

Milestone: 8.0.2
Status: newmerge
Test Case: typecheck/should_fail/T12151

Could merge, but only if it goes easily

comment:3 Changed 3 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.