Ticket #2985 (closed merge: fixed)

Opened 4 years ago

Last modified 4 years ago

Bogus superclass dictionary with equality constraints

Reported by: simonpj Owned by: igloo
Priority: normal Milestone: 6.10.2
Component: Compiler Version: 6.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: indexed-types/should_run/T2985 Blocked By:
Blocking: Related Tickets:

Description

{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
{-# OPTIONS -fglasgow-exts -Wnot #-}

module Main where

instance (Num a, Num b, a ~ b) => Num (a,b) where
     x * _ = x 

test1 = (1,1) * (2,2)

main = print test1

Running this program produces <<loop>>. Reason is that the Num (a,b) dictionary gets an Eq superclass dictionary that is essentially bottom. I'm not sure why, but it's a bad bug.

See  http://article.gmane.org/gmane.comp.lang.haskell.general/16796

Simon

Change History

Changed 4 years ago by simonpj

  • owner set to igloo
  • testcase set to indexed-types/should_run/T2985
  • type changed from bug to merge

Excellent bug. Fixed by

Fri Jan 30 07:27:38 PST 2009  simonpj@microsoft.com
  * Fix Trac #2985: generating superclasses and recursive dictionaries

  The Note [Recursive instances and superclases] explains the subtle
  issues to do with generating the bindings for superclasses when
  we compile an instance declaration, at least if we want to do the
  clever "recursive superclass" idea from the SYB3 paper.

  The old implementation of tcSimplifySuperClasses stumbled when
  type equalities entered the picture (details in the Note); this
  patch fixes the problem using a slightly hacky trick.  When we
  re-engineer the constraint solver we'll want to keep an eye on
  this.

  Probably worth merging to the 6.10 branch.

Worth merging.

Simon

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged.

Note: See TracTickets for help on using tickets.