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

Transfer higher level data types like objects to extended class objects (host binding and inheritance) #2867

Open
QuisMagni opened this issue Sep 3, 2024 · 0 comments
Labels

Comments

@QuisMagni
Copy link

Bug description

I would like to pass data from host to as using host bindings. On the as side the target class is extending another class.

Steps to reproduce

Target class:

export class Foo {
    a: i32 = 0
}

export class Baa extends Foo {
    b: i32 = 0
}

index.ts (AS)

export function test(test: Baa): void {
    console.log('test')
}

Calling from host side:

...
 wasm.test({a: 0, b: 1})
...

I get a runtime error like that:

Uncaught (in promise) TypeError: internref expected at __lowerInternref (release.js?t=1725378963979:80:11) at Object.test (release.js?t=1725378963979:37:14) ....
Generated glue code is not looking as expected:

declare namespace __AdaptedExports {
  /** Exported memory */
  export const memory: WebAssembly.Memory;
  /**
   * assembly/index/test
   * @param test `assembly/Baa`
   */
  export function test(test: __Internref16): void;
}
/** assembly/Baa */
declare class __Internref16 extends Number {
  private __nominal16: symbol;
  private __nominal17: symbol;
  private __nominal0: symbol;
}
/** Instantiates the compiled WebAssembly module with the given imports. */
export declare function instantiate(module: WebAssembly.Module, imports: {
  env: unknown,
}): Promise<typeof __AdaptedExports>;

Removing inheritance from target class is solving the problem:

export class Baa { a: i32 = 0 b: i32 = 0 }

Is inheritance not supported for host bindings?

AssemblyScript version

0.27.29

@QuisMagni QuisMagni added the bug label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant