Skip to content

Runtime exception with multiple type class membership of Unit  #1

@levans

Description

@levans

On behalf of: jkramar@gmail.com

I seem to be encountering a bug when combining two slightly unusual
typeclasses. When I try to evaluate thisShouldWork from ICE I get an
exception with the following stacktrace:

java.lang.UnsupportedOperationException: Attempt to call getOrdinal() 
on class: org.openquark.cal_Cal_Core_Prelude.Unsafe_Coerce 
        at org.openquark.cal.internal.runtime.lecc.RTValue.getOrdinalValue 
(RTValue.java:599) 
        at org.openquark.cal_Cal_Core_Prelude.Output_Unit.f1L 
(Output_Unit.java) 
        at org.openquark.cal_Badness._output___With_Phantom.f3S 
(_output___With_Phantom.java) 
        at org.openquark.cal_Badness.Io__iceruntarget__0__0.f 
(Io__iceruntarget__0__0.java) 
        at org.openquark.cal.internal.runtime.lecc.RTFullApp$General$_0.reduce 
(RTFullApp.java:225) 
        at 
org.openquark.cal.internal.runtime.lecc.RTResultFunction.unsynchronizedEval uate 
(RTResultFunction.java:136) 
        at org.openquark.cal.internal.runtime.lecc.RTResultFunction.evaluate 
(RTResultFunction.java:103) 
        at org.openquark.cal_Cal_Core_Prelude.Id.f(Id.java) 
        at org.openquark.cal.internal.runtime.lecc.RTApplication.reduce 
(RTApplication.java:156) 
        at 
org.openquark.cal.internal.runtime.lecc.RTResultFunction.unsynchronizedEval uate 
(RTResultFunction.java:136) 
        at org.openquark.cal.internal.runtime.lecc.RTResultFunction.evaluate 
(RTResultFunction.java:103) 
        at org.openquark.cal.internal.machine.lecc.Executor.exec 
(Executor.java:173) 
        at org.openquark.cal.ICE$FunctionRunThread.run(ICE.java:7226) 
        at java.lang.Thread.run(Unknown Source) 

Here's the code that triggers it (I've tried to eliminate all code not necessary for reproducing the bug):

module Badness; 
import Cal.Core.Prelude using 
    typeClass = Outputable; 
    function = const; 
    dataConstructor = Unit; 
    typeConstructor = Unit; 
    ; 
class MakeOne t where 
    hereItIs :: t; 
    ; 
unit = (); 
instance MakeOne Unit where 
    hereItIs = unit; 
    ; 
data WithPhantom t a = WithPhantom a::a deriving Outputable; 
defaultMakeWithPhantom :: (MakeOne a, MakeWithPhantom t) => a -> 
WithPhantom t a; 
defaultMakeWithPhantom = const$WithPhantom hereItIs; 
class MakeWithPhantom t where 
    makeWithPhantom :: MakeOne a => a -> WithPhantom t a default 
defaultMakeWithPhantom; 
    ; 
instance MakeWithPhantom Unit where 
    ; 
thisShouldWork :: WithPhantom Unit Unit; 
thisShouldWork = makeWithPhantom Unit; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions