镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Incorrect handling of Self type in abstract parent #92

Open

Description

@bendmorris
  • 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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions