Repository navigation
Open
Labels
Description
Bug description
Hi, I found that asc crashes when compiling the following AS code, which should be compiled successfully (like TypeScript) instead of crashing.
Steps to reproduce
// bad.ts
class A<T>{}
class B extends A<B>{}
export function f(x:B):void{}> node ~/assemblyscript/bin/asc --optimizeLevel 2 --shrinkLevel 2 bad.ts -o bad.wasm
▌ Whoops, the AssemblyScript compiler has crashed during compile :-(
▌
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌
▌ RangeError: Maximum call stack size exceeded
▌ at t.get isInternalReference (~/assemblyscript/src/types.ts:274:7)
▌ at t.getClass (~/assemblyscript/src/types.ts:290:17)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:1997:31)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌ at On.checkTypeSupported (~/assemblyscript/src/program.ts:2003:23)
▌
▌ If you see where the error is, feel free to send us a pull request. If not,
▌ please let us know: https://github.com/AssemblyScript/assemblyscript/issues
▌
▌ Thank you!Other findings
- Directly extending the class itself without a generic base class does not trigger the same stack overflow. It reports a normal compilation error:
// good.ts
class B extends B {}
export function f(x:B):void{}
ERROR TS2506: 'B' is referenced directly or indirectly in its own base expression.- The recursive generic type must enter exported API/type checking to trigger the crash. The following program does not crash and can be compiled successfully:
// good.ts
class A<T> {}
class B extends A<B> {}
Activity