Opened 9 years ago

Closed 6 years ago

#2715 closed task (fixed)

Equality constraint in superclass not supported

Reported by: rodprice Owned by: chak
Priority: low Milestone: 7.2.1
Component: Compiler (Type checker) Version: 6.10.1
Keywords: Cc: ganesh, sisoyev.andrey@…, sanzhiyan@…, mikhail.vorozhtsov@…, 78emil@…
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Test Case: indexed_types/should_compile/T2715
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The code in "bug.hs" causes a GHC panic; the nearly identical code in "unbug.hs" does not.

Attachments (2)

bug.hs (841 bytes) - added by rodprice 9 years ago.
Causes a GHC panic
unbug.hs (817 bytes) - added by rodprice 9 years ago.
This code compiles fine.

Download all attachments as: .zip

Change History (20)

Changed 9 years ago by rodprice

Attachment: bug.hs added

Causes a GHC panic

Changed 9 years ago by rodprice

Attachment: unbug.hs added

This code compiles fine.

comment:1 Changed 9 years ago by rodprice

Here's the error message:

stm$ ghci bug.hs GHCi, version 6.10.0.20081007: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( bug.hs, interpreted ) ghc: panic! (the 'impossible' happened)

(GHC version 6.10.0.20081007 for i386-unknown-linux):

applyTypeToArgs

main:Main.:DIIDomain{v rmQ} [gid]

@ main:Main.Interval{tc rfz} @ main:Main.Interval{tc rfz} $dIDomain{v an6} [lid] $dIDomain{v an7} [lid] @ (main:Main.Value{tc rfv} main:Main.Interval{tc rfz})

(main:Main.Value{tc rfv} main:Main.Interval{tc rfz}

~

main:Main.Value{tc rfv} main:Main.Interval{tc rfz}, main:Main.IDomain{tc rfr} main:Main.Interval{tc rfz}, main:Main.IDomain{tc rfr} main:Main.Interval{tc rfz}) =>

(main:Main.Domain{tc rfx}

main:Main.Interval{tc rfz} (main:Main.Value{tc rfv} main:Main.Interval{tc rfz})

-> main:Main.Domain{tc rfx}

main:Main.Interval{tc rfz} (main:Main.Value{tc rfv} main:Main.Interval{tc rfz})

-> ghc-prim:GHC.Bool.Bool{(w) tc 3c})

-> main:Main.Interval{tc rfz}

main:Main.:TIIDomain{tc rmP} main:Main.Interval{tc rfz}

comment:2 Changed 9 years ago by simonpj

difficulty: Unknown

Ah, you are using an equality predicate in the superclass context

class (Value d1 ~ Value d2) => IIDomain d1 d2 where

This specifically does not work in 6.10; it's the major unfinished piece in the type-family story.

Really GHC 6.10 should simply reject such programs. As it stands, it has a half-baked go at it.

Simon

comment:3 Changed 9 years ago by simonmar

Component: CompilerCompiler (Type checker)
Milestone: 6.12 branch
Summary: GHC panicEquality constraint in superclass causes panic: applyTypeToArgs

Adding more descriptive description.

comment:4 Changed 9 years ago by igloo

See also: #2686

comment:5 Changed 9 years ago by simonpj

Owner: set to chak

comment:6 Changed 9 years ago by chak

Summary: Equality constraint in superclass causes panic: applyTypeToArgsEquality constraint in superclass not supported

There is no panic anymore. Programs with super class equalities are outright rejected with an error message explaining that superclass equalities are a currently unsupported feature.

comment:7 Changed 8 years ago by porges

Just wondering if this is still slated to be in 6.12... :)

comment:8 Changed 8 years ago by simonpj

Yes, that's still the plan. But there's still a fair bit of upheaval going on in the type inference for equalities, so don't hold your breath.

Simon

comment:9 Changed 8 years ago by ganesh

Cc: ganesh added

comment:10 in reply to:  description Changed 8 years ago by Andrey.Sisoyev

Cc: sisoyev.andrey@… added
Type: bugtask
Type of failure: None/Unknown

Didn't notice it in release info (for GHC 6.12.1). How is the progress? =)

comment:11 Changed 8 years ago by Saizan

Cc: sanzhiyan@… added

comment:12 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:13 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:14 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:15 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:16 Changed 7 years ago by mikhail.vorozhtsov

Cc: mikhail.vorozhtsov@… added

comment:17 Changed 7 years ago by baramoglo

Cc: 78emil@… added

comment:18 Changed 6 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: indexed_types/should_compile/T2715

Hurrah! We now have superclass equalities. I've added this example as a test.

commit 940d1309e58382c889c2665227863fd790bdb21c
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Wed Jun 22 17:37:47 2011 +0100

    Add equality superclasses
    
    Hurrah.  At last we can write
    
       class (F a ~ b) => C a b where { ... }
    
    This fruit of the fact that equalities are now values,
    and all evidence is handled uniformly.
    
    The main tricky point is that when translating to Core
    an evidence variable 'v' is represented either as
      either   Var v
      or       Coercion (CoVar v)
    depending on whether or not v is an equality.  This leads
    to a few annoying calls to 'varToCoreExpr'.

 compiler/basicTypes/MkId.lhs      |    4 +-
 compiler/deSugar/DsExpr.lhs       |   18 +++++++-
 compiler/iface/BuildTyCl.lhs      |   50 ++++++++++------------
 compiler/typecheck/TcInstDcls.lhs |   85 +++++++++++++++++-------------------
 compiler/typecheck/TcMType.lhs    |    9 +----
 compiler/types/Class.lhs          |   21 ++++------
 6 files changed, 92 insertions(+), 95 deletions(-)
Note: See TracTickets for help on using tickets.