Bug description
Hi, I found that asc/warpo crashes during compilation when a class extends an undefined base class and declares an override method. I would expect a normal compilation error such as Cannot find name 'B' rather than a crash.
// bad.ts
class A extends B {
override f(): void {}
}
> ~/warpo/build/warpo/warpo_asc --optimizeLevel 2 --shrinkLevel 2 bad.ts -o bad.wasm
abort: <<NULL>> in assemblyscript/src/program.ts:1538:35
Error: Unreachable instruction executed
at assemblyscript/src/program/Program#initialize (wasm-function[5395])
at assemblyscript/src/index-wasm/initializeProgram (wasm-function[5396])
at export:assemblyscript/src/index-wasm/initializeProgram (wasm-function[5899])
compilation failed
AS wasm execution failed
ERROR: compilation failed
# ==========================================================
> node ~/assemblyscript/bin/asc --optimizeLevel 2 --shrinkLevel 2 bad.ts -o bad.wasm
▌ Whoops, the AssemblyScript compiler has crashed during initialize :-(
▌
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌
▌ AssertionError: assertion failed
▌ at Y.assert (~/assemblyscript/std/portable/index.js:216:11)
▌ at On.initialize (~/assemblyscript/src/program.ts:1399:35)
▌ at Module.MS (~/assemblyscript/src/index-wasm.ts:354:11)
▌ at Module.De (~/assemblyscript/cli/index.js:714:22)
▌ at async file:///assemblyscript/bin/asc.js:33:22
▌
▌ 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!
Environment
- AssemblyScript commit: b6bda05c29c9eb7d07d7f6cb2703508483b30493
- Warpo: 0637147
Other Findings
- If override is removed, extending an undefined class only raises a normal compilation error instead of crashing:
// good.ts
class A extends B {
f(): void {}
}
// node ~/assemblyscript/bin/asc --optimizeLevel 2 --shrinkLevel 2 good.ts -o good.wasm
ERROR TS2304: Cannot find name 'B'.
:
1 │ class A extends B {
│ ~
└─ in good.ts(1,17)
FAILURE 1 compile error(s)
- An override field also triggers the compiler crash:
class A extends B {
override f: C
}
Bug description
Hi, I found that
asc/warpocrashes during compilation when a class extends an undefined base class and declares anoverridemethod. I would expect a normal compilation error such as Cannot find name 'B' rather than a crash.Environment
Other Findings