Ticket #2715 (closed task: fixed)

Opened 3 years ago

Last modified 8 months ago

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

bug.hs Download (0.8 KB) - added by rodprice 3 years ago.
Causes a GHC panic
unbug.hs Download (0.8 KB) - added by rodprice 3 years ago.
This code compiles fine.

Change History

Changed 3 years ago by rodprice

Causes a GHC panic

Changed 3 years ago by rodprice

This code compiles fine.

  Changed 3 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}

  Changed 3 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

  Changed 3 years ago by simonmar

  • summary changed from GHC panic to Equality constraint in superclass causes panic: applyTypeToArgs
  • component changed from Compiler to Compiler (Type checker)
  • milestone set to 6.12 branch

Adding more descriptive description.

  Changed 3 years ago by igloo

See also: #2686

  Changed 3 years ago by simonpj

  • owner set to chak

  Changed 3 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.

  Changed 3 years ago by porges

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

  Changed 3 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

  Changed 3 years ago by ganesh

  • cc ganesh added

in reply to: ↑ description   Changed 2 years ago by Andrey.Sisoyev

  • cc sisoyev.andrey@… added
  • failure set to None/Unknown
  • type changed from bug to task

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

  Changed 23 months ago by Saizan

  • cc sanzhiyan@… added

  Changed 22 months ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

  Changed 20 months ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

  Changed 14 months ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

  Changed 12 months ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

  Changed 10 months ago by mikhail.vorozhtsov

  • cc mikhail.vorozhtsov@… added

  Changed 10 months ago by baramoglo

  • cc 78emil@… added

  Changed 8 months ago by simonpj

  • status changed from new to closed
  • testcase set to indexed_types/should_compile/T2715
  • resolution set to fixed

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.