Opened 3 years ago

Closed 3 years ago

#6123 closed bug (fixed)

occurs check should not apply to type families

Reported by: dmwit Owned by: simonpj
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 7.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: indexed-types/should_fail/T6123
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

This code:

{-# LANGUAGE TypeFamilies #-}
type family Id a
cid :: a ~ Id a => a -> a
cid x = x
cundefined = cid undefined

gives this error:

test.hs:5:14:
    Occurs check: cannot construct the infinite type: a0 = Id a0
    In the expression: cid undefined
    In an equation for `cundefined': cundefined = cid undefined

whereas I think it should be possible to infer the type cundefined :: a ~ Id a => a. Equations with a variable on one side and a type family at the head of the other side should become constraints rather than being subject to the occurs check.

Change History (3)

comment:1 Changed 3 years ago by simonpj

  • difficulty set to Unknown
  • Owner set to simonpj

comment:2 Changed 3 years ago by simonpj@…

commit 05289c2ac1203a5d5bbe8236d0239946b5093116

Author: Simon Peyton Jones <[email protected]>
Date:   Fri May 25 11:45:53 2012 +0100

    Improve occurs-check error reporting (fix Trac #6123)
    
    We were wrongly reporting (a ~ F a) as an occurs-check error
    when F is a type function.

 compiler/typecheck/TcCanonical.lhs |  112 ++++++++++++++++++-----------------
 compiler/typecheck/TcErrors.lhs    |   41 ++++++--------
 compiler/typecheck/TcInteract.lhs  |    5 ++
 3 files changed, 80 insertions(+), 78 deletions(-)

comment:3 Changed 3 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to indexed-types/should_fail/T6123
Note: See TracTickets for help on using tickets.