Skip to content

Deducing type error when the method having generic parameter #551

@LiaoPeng

Description

@LiaoPeng

The source code.

import "allocator/arena";
import { Action , getMethod, Method, Action1, getMethod1 } from "./name";

declare function sayHello(): void;

sayHello();

export function add(x: i32, y: i32): i32 {
  return x + y;
}

var mth: Method = getMethod("name");
Action.attach(mth, "");


var mth1 = getMethod1("name");
Action1.attachWithoutData(mth1);
Action1.attach(mth1, "");

The compiled result:

ERROR TS2304: Cannot find name 'Method1'.

   static attach<T>(mth: Method1, data: T):void  {
                         ~~~~~~~
 in name.ts(29,24)


ERROR: Compile error
    at exports.main (https://assemblyscript.github.io/assemblyscript/dist/asc.js:1:457291)
    at Object.eval [as main] (eval at d (https://webassembly.studio/dist/main.bundle.js:1:32473), <anonymous>:20:12)
    at r.eval [as promiseMaker] (eval at gulp (https://webassembly.studio/dist/main.bundle.js:1:34093), <anonymous>:7:7)
    at o.makePromise (https://webassembly.studio/dist/main.bundle.js:1:31658)
    at s.runInstance (https://webassembly.studio/dist/main.bundle.js:1:31954)

[info]: Task build is completed
Saving Project ...
Saved Project OK

The below code compiled successful.

var mth: Method = getMethod("name");
Action.attach(mth, "");

I expected the below code also compiled successful.

var mth1 = getMethod1("name");
Action1.attach(mth1, "");

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions