New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property returning This "has incomplete type" #781

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

Comments

Projects
None yet
2 participants
@davidhesselbom
Contributor

davidhesselbom commented Jul 29, 2014

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

This comment has been minimized.

Collaborator

fasterthanlime commented Jul 29, 2014

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

This comment has been minimized.

Collaborator

fasterthanlime commented Aug 15, 2014

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 added a commit that referenced this issue Aug 15, 2014

@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