Broken assumptions resolution when defining methods #32

kustosz opened this Issue Aug 31, 2017 · 0 comments


None yet
2 participants

kustosz commented Aug 31, 2017

This is a curious case, probably resulting from broken resolution of CurrentTarget in Luna typechecker. This code:

class Complex:
    real :: Real
    imag :: Real
    def + that:
        Complex (self.real + that.real) (self.imag + that.imag)

yields compile errors whenever addition on complex numbers is used. Errors suggest that the TC is messing reals and complex numbers together. Everything works fine when the + definition is changed to explicit use of method instead of the operator wrapper:

def + that:
    Complex (self.real.+ that.real) (self.imag.+ that.imag)

Interestingly enough, this only happens when the operator used in body is the same as one currently being defined (i.e. using the operator * inside definition of + method works fine. And it breaks when using * in the definition of *, but + works fine there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment