Opened 5 years ago

Closed 3 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 Difficulty: Unknown
Test Case: indexed_types/should_compile/T2715 Blocked By:
Blocking: Related Tickets:

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 5 years ago.
Causes a GHC panic
unbug.hs (817 bytes) - added by rodprice 5 years ago.
This code compiles fine.

Download all attachments as: .zip

Change History (20)

Changed 5 years ago by rodprice

Causes a GHC panic

Changed 5 years ago by rodprice

This code compiles fine.

comment:1 Changed 5 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 5 years ago by simonpj

  • Difficulty set to 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 5 years ago by simonmar

  • Component changed from Compiler to Compiler (Type checker)
  • Milestone set to 6.12 branch
  • Summary changed from GHC panic to Equality constraint in superclass causes panic: applyTypeToArgs

Adding more descriptive description.

comment:4 Changed 5 years ago by igloo

See also: #2686

comment:5 Changed 5 years ago by simonpj

  • Owner set to chak

comment:6 Changed 5 years ago by chak

  • Summary changed from Equality constraint in superclass causes panic: applyTypeToArgs to Equality 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 5 years ago by porges

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

comment:8 Changed 5 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 5 years ago by ganesh

  • Cc ganesh added

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

  • Cc sisoyev.andrey@… added
  • Type changed from bug to task
  • Type of failure set to None/Unknown

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

comment:11 Changed 4 years ago by Saizan

  • Cc sanzhiyan@… added

comment:12 Changed 4 years ago by igloo

  • Milestone changed from 6.12 branch to 6.12.3

comment:13 Changed 4 years ago by igloo

  • Milestone changed from 6.12.3 to 6.14.1
  • Priority changed from normal to low

comment:14 Changed 3 years ago by igloo

  • Milestone changed from 7.0.1 to 7.0.2

comment:15 Changed 3 years ago by igloo

  • Milestone changed from 7.0.2 to 7.2.1

comment:16 Changed 3 years ago by mikhail.vorozhtsov

  • Cc mikhail.vorozhtsov@… added

comment:17 Changed 3 years ago by baramoglo

  • Cc 78emil@… added

comment:18 Changed 3 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to 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.