Incorrect FlatCurry code for dictionary transformations with hidden TC methods
Consider a module that partially exports a type class:
module Module (MyClass(myMethod)) where
class MyClass a where
myMethod :: a -> String
myMethod _ = "default implementation 1"
myHiddenMethod :: a -> String
myHiddenMethod _ = "default implementation 2"
and as module importing and using this typeclass:
module Fail where
import Module
instance MyClass Int where
myMethod _ = "Some output"
main :: IO ()
main = do
putStrLn $ myMethod (5 :: Int)
Then, the flatcurry output is
Fail2._inst#Module2.MyClass#Prelude.Int# v1 = fcase v1 of
Prelude.() -> Module2._Dict#MyClass Fail2._impl#myMethod#Module2.MyClass#Prelude.Int#
instead of
Fail2._inst#Module2.MyClass#Prelude.Int# v1 = fcase v1 of
Prelude.() -> Module2._Dict#MyClass Fail2._impl#myMethod#Module2.MyClass#Prelude.Int#
Fail2._impl#myOtherMethod#Module2.MyClass#Prelude.Int#
That is, in the dictionary transformation, the hidden TC method is missing, and in the flatcurry code, the method is not applied to the dictionary.
Furthermore, when using the following instance declaration instead, running main
yields a runtime error (*** No value found!
), although one would expect a compiler warning stating that myHiddenMethod
is undefined.
instance MyClass Int where
myMethod = myHiddenMethod
This is related to issue #130 (closed).
Edited by Lasse Züngel