Skip to content
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

Incorrect handling of Self type in abstract parent #92

Open
bendmorris opened this issue Dec 26, 2018 · 0 comments
Open

Incorrect handling of Self type in abstract parent #92

bendmorris opened this issue Dec 26, 2018 · 0 comments
Labels
bug Something isn't working

Comments

@bendmorris
Copy link
Member

  • Kit version: dev
  • OS/Platform: all

Describe the problem. What did you see? What did you expect to see?

  • A method which returns Self, when fallen through from an abstract, should return the abstract type, not the parent type.

If this is a code issue, provide a minimal code example:

struct Parent {
    public var x: Int;
    public var y: Int;

    public function copy(): Self {
        return struct Self {x: this.x, y: this.y};
    }
}

abstract Child: Parent;

function main() {
    var x: Child = struct Child {x: 1, y: 1};
    var y: Child = x.copy();
}
----------------------------------------
Error: ./test.kit:14: A variable's initial value must match the variable's type:

  @./test.kit:14:20-25
      14        var y: Child = x.copy();
                               ^^^^^^

    Expected type:  test.Child
      Actual type:  test.Parent
@bendmorris bendmorris added the bug Something isn't working label Dec 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant