ooc-lang / rock

:ocean: self-hosted ooc compiler that generates c99
http://ooc-lang.org/
MIT License
401 stars 40 forks source link

Safe-navigation operator fails when operand is a property #968

Open thomasfanell opened 8 years ago

thomasfanell commented 8 years ago

Here is a mock-up that should illustrate what I mean:

Polynomial: class {
    m_derivative: Polynomial
    derivative ::= this m_derivative
    init: func
}

somePolynomial := Polynomial new()
thirdDerivative: Polynomial

// error: 'source_Main__Polynomial' has no member named 'derivative'
thirdDerivative = somePolynomial $ derivative $ derivative $ derivative

// This works as expected
thirdDerivative = somePolynomial $ m_derivative $ m_derivative $ m_derivative
alexnask commented 8 years ago

What appears to be happening is that only the outermost property access is translated to a call.
Probably a VariableAccess bug, SafeNavigation seems to be completely fine to me (all it does is make a huge ternary with accesses and checks to NULL).

On it.