Issues with multiple instances of the same class in class contexts
The 2018-12-01 itask compiler has several possibly related issues when a class dictionary contains instances of the same class, as in the example below.
- In
build_context_fields
of checktypes, fields are generated using only the names of the classes, causing duplicate symbols. When not using the optimising linker, this triggers a multiple definition error for the example below (Clean System Files/test.o:(.data.m7+0x8): multiple definition of `e__test__dconvertable_I_Pconvert'
) - Overloading is not correctly resolved for some members of the context. This can be seen in the function
f
below. If it has the typea -> Int | convertable a
all is well, with result typeString
the overloading cannot be resolved (internal overloading of "convert" could not be solved
)
Implementation module:
implementation module test
import StdEnv
class convert a b :: a -> b
class convertable a | convert a Int & convert a String
instance convert Int Int where convert i = i
instance convert Int String where convert i = toString i
f :: a -> Int | convertable a
f i = convert i
Start = f 10
Definition module:
definition module test
class convert a b :: a -> b
class convertable a | convert a Int & convert a String
instance convert Int Int
instance convert Int String
f :: a -> Int | convertable a