Closed
Description
I have this strange error from asc
:
Fatal: Module::addExport: apply0<i16>> already exists
Steps to reproduce
Run this command line:
asc foo.ts bar.ts apply.ts --textFile module.wat
with these files:
- apply.ts
export class apply0<ReturnType, Runner0> {
execute(typeId: i32): ReturnType {
const runner = instantiate<Runner0>();
if (typeId == 0) return runner.execute<ReturnType, i16>();
if (typeId == 1) return runner.execute<ReturnType, i32>();
if (typeId == 2) return runner.execute<ReturnType, i64>();
throw new Error("Unknown typeId.");
}
}
export class apply1<ReturnType, Runner1> {
execute<Arg1Type>(typeId: i32, arg1: Arg1Type): ReturnType {
const runner = instantiate<Runner1>();
if (typeId == 0) return runner.execute<ReturnType, i16>(arg1);
if (typeId == 1) return runner.execute<ReturnType, i32>(arg1);
if (typeId == 2) return runner.execute<ReturnType, i64>(arg1);
throw new Error("Unknown typeId.");
}
}
- foo.ts:
import { apply0, apply1 } from "./apply";
function foo<T1, T2>(): i32 {
return sizeof<T1>() + sizeof<T2>();
}
class runner0<T1> {
execute<ReturnType, T2>(): ReturnType {
return foo<T1, T2>();
}
}
class runner1 {
execute<ReturnType, T1>(typeId: i32): ReturnType {
return new apply0<i32, runner0<T1>>().execute(typeId);
}
}
export function fooWithTypeId(typeId1: i32, typeId2: i32): i32 {
return new apply1<i32, runner1>().execute(typeId1, typeId2);
}
- bar.ts
import { apply0, apply1 } from "./apply";
function bar<T1, T2>(): i32 {
return sizeof<T1>() + sizeof<T2>();
}
class runner0<T1> {
execute<ReturnType, T2>(): ReturnType {
return bar<T1, T2>();
}
}
class runner1 {
execute<ReturnType, T1>(typeId: i32): ReturnType {
return new apply0<i32, runner0<T1>>().execute(typeId);
}
}
export function barWithTypeId(typeId1: i32, typeId2: i32): i32 {
return new apply1<i32, runner1>().execute(typeId1, typeId2);
}
WebAssembly Studio project
I was able to reproduce the crash (but without the strange message) here.