Bug description
Hi, I found that asc/warpo crashes while compiling the following code snippet. I would expect this to report a normal compilation error rather than crashing.
// bad.ts
export declare function f(x?: i32): void;
> node ~/fuzz_emerging_compilers/AssemblyScript/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: Invalid array length
▌ at t.getNonParameterLocalTypes (.../assemblyscript/src/program.ts:3903:17)
▌ at t.ensureVarargsStub (.../assemblyscript/src/compiler.ts:6692:24)
▌ at t.compileModuleExport (.../assemblyscript/src/compiler.ts:984:37)
▌ at t.compileModuleExport (.../assemblyscript/src/compiler.ts:972:18)
▌ at t.compileModuleExports (.../assemblyscript/src/compiler.ts:951:14)
▌ at t.compile (.../assemblyscript/src/compiler.ts:570:14)
# ==========================================================
> ~/BMW-wasm/warpo/build/warpo/warpo_asc --optimizeLevel 2 --shrinkLevel 2 bad.ts -o bad.wasm
Error: Unreachable instruction executed
at ~lib/array/Array<assemblyscript/src/types/Type>#constructor (wasm-function[3446])
at assemblyscript/src/program/Function#getNonParameterLocalTypes (wasm-function[3958])
at assemblyscript/src/compiler/Compiler#ensureVarargsStub (wasm-function[3967])
at assemblyscript/src/compiler/Compiler#compileModuleExport (wasm-function[5412])
at assemblyscript/src/compiler/Compiler#compileModuleExport (wasm-function[5412])
at assemblyscript/src/compiler/Compiler#compileModuleExports (wasm-function[5413])
at assemblyscript/src/compiler/Compiler#compile (wasm-function[5490])
at assemblyscript/src/index-wasm/compile (wasm-function[5491])
at export:assemblyscript/src/index-wasm/compile (wasm-function[5896])
abort: Invalid length in ~lib/array.ts:70:60
compilation failed
AS wasm execution failed
ERROR: compilation failed
Environment
- AssemblyScript commit: b6bda05c29c9eb7d07d7f6cb2703508483b30493
- Warpo commit: 0637147
Other Findings
Removing the optional parameter marker avoids the crash. Besides, I found that the error messages in this case are very similar to those in #635, so I am wondering whether they are caused by the same bug.
Bug description
Hi, I found that
asc/warpocrashes while compiling the following code snippet. I would expect this to report a normal compilation error rather than crashing.Environment
Other Findings
Removing the optional parameter marker avoids the crash. Besides, I found that the error messages in this case are very similar to those in #635, so I am wondering whether they are caused by the same bug.