Closed
Description
This code cannot compile. It seems like generic infer error.
In subscribe<T>
, T is AAAAAA
; In fieldparam.reduce
, T is string
. But compiler cannot distinguish them.
function subscribe<T>(): void {
let a = new TestClass2(new Array<string>(10));
}
class TestClass2 {
constructor(fieldparam: Array<string>) {
function reducefunc(total: i32, curr: string, index: i32, array: Array<string>): i32 {
return 0;
}
fieldparam.reduce(reducefunc, 0);
}
}
class AAAAAA {}
subscribe<AAAAAA>();
ERROR TS2322: Type '(i32, ~lib/string/String, i32, ~lib/array/Array<~lib/string/String>) => i32' is not assignable to type '(i32, assembly/index/AAAAAA, i32, ~lib/array/Array<assembly/index/AAAAAA>) => i32'.
fieldparam.reduce(reducefunc, 0);
~~~~~~~~~~
in assembly/index.ts(10,27)
ERROR TS2322: Type '~lib/array/Array<~lib/string/String>' is not assignable to type '~lib/array/Array<assembly/index/AAAAAA>'.
acc = fn(acc, load<T>(this.dataStart + (<usize>i << alignof<T>())), i, this);
~~~~
in ~lib/array.ts(325,78)