Skip to content

Missing docs: override doesn't do anything in @unmanaged classes #2973

@geraintluff

Description

@geraintluff

Bug description

If I have two classes, with an overridden method:

class A {
  foo() : i32 {
    return 1;
  }
}
class B extends A {
  override foo() : i32 {
    return 2;
  }
}

let bAsA : A = new B();
console.log(`foo = ${bAsA.foo()}`);

This logs foo = 2 as expected, because it looks up the correct method via the object's header.

However, if you mark both classes as @unmanaged, it logs foo = 1:

@unmanaged
class A {...}
@unmanaged
class B extends A {...}

This actual behaviour makes sense to me, since there aren't any fields in the C-style struct for the function pointers to be stored.

However, I think we should document this, and the compiler should also complain a bit when override is used in an @unmanaged class, to make it more obvious that it doesn't work.

Steps to reproduce

Run the code-examples above.

AssemblyScript version

v0.28.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions