Property returning This "has incomplete type" #781

Closed
davidhesselbom opened this Issue Jul 29, 2014 · 2 comments

Projects

None yet

2 participants

@davidhesselbom
Contributor

How do I solve the error I get when compiling PointB?

import math

// Builds just fine
PointA: cover {
    x, y: Float
    init: func@ (=x, =y)
    Negative: func -> This { This new(-this x, this y) }
}

// Does not build, "error: field ‘Negative’ has incomplete type"
PointB: cover {
    x, y: Float
    init: func@ (=x, =y)
    Negative: This { get { This new(-this x, -this y) } }
}

// Builds just fine, but obviously doesn't do what I want
PointC: cover {
    x, y: Float
    init: func@ (=x, =y)
    Negative: static This { get { This new(-1, -1) } }
}

// Does not build, since static methods obviously do not have access to instance variables
PointD: cover {
    x, y: Float
    init: func@ (=x, =y)
    Negative: static This { get { This new(-this x, -this y) } }
}
@fasterthanlime
Collaborator

Here's a runnable test case:

import math

// Does not build, "error: field ‘negated’ has incomplete type"
PointB: cover {
    x, y: Float
    init: func@ (=x, =y)
    negated: This { get { This new(-this x, -this y) } }
    _: String { get { "(#{x}, #{y})" } }
}

main: func {
    p1 := PointB new(12, 15)
    p2 := p1 negated
    "p2 = #{p2 _}"
}

It fails because virtual properties still end up in the cover's struct definition for some reason, definitely a C backend bug:

struct _issue781__PointB {
    lang_Numbers__Float x;
    lang_Numbers__Float y;
    issue781__PointB negated;
    lang_String__String* _;
};

@fredreichbier are you around these days? Can you take a look at this maybe? Or @shamanas ?

@fasterthanlime
Collaborator

Runnable test case:

import math

// Does not build, "error: field ‘negated’ has incomplete type"
PointB: cover {
    x, y: Float
    init: func@ (=x, =y)
    negated: This { get { This new(-this x, -this y) } }
    _: String { get { "(#{x}, #{y})" } }
}

main: func {
    p1 := PointB new(12, 15)
    p2 := p1 negated
    "p2 = #{p2 _}" println()
}

Correct output:

p2 = (-12.000000, -15.000000)
@fasterthanlime fasterthanlime added the Bug label Aug 15, 2014
@fasterthanlime fasterthanlime added a commit that referenced this issue Aug 15, 2014
@fasterthanlime fasterthanlime Closes #781 40be3b6
@fasterthanlime fasterthanlime added this to the 0.9.9 milestone Aug 15, 2014
@fasterthanlime fasterthanlime self-assigned this Aug 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment