assemblyscript
assemblyscript copied to clipboard
Void type in some scenarios crashes the compiler
Credits
@DogWhich also found this interesting one on a whim
Code
typeof ((): void => {})();
Stack trace
▌ Whoops, the AssemblyScript compiler has crashed during compile :-(
▌
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌
▌ AssertionError: assertion failed
▌ at assert (D:\assemblyscript\std\portable\index.js:200:11)
▌ at Compiler.convertExpression (D:\assemblyscript\src\compiler.ts:3598:7)
▌ at Compiler.compileTypeof (D:\assemblyscript\src\compiler.ts:9948:25)
▌ at Compiler.compileUnaryPrefixExpression (D:\assemblyscript\src\compiler.ts:9889:21)
▌ at Compiler.compileExpression (D:\assemblyscript\src\compiler.ts:3539:21)
▌ at Compiler.compileExpressionStatement (D:\assemblyscript\src\compiler.ts:2521:17)
▌ at Compiler.compileStatement (D:\assemblyscript\src\compiler.ts:2213:21)
▌ at Compiler.compileTopLevelStatement (D:\assemblyscript\src\compiler.ts:2175:25)
▌ at Compiler.compileFile (D:\assemblyscript\src\compiler.ts:1111:12)
▌ at Compiler.compile (D:\assemblyscript\src\compiler.ts:486:14)
▌ at Object.compile (D:\assemblyscript\src\index.ts:280:32)
▌ at D:\assemblyscript\cli\asc.js:902:31
▌ at measure (D:\assemblyscript\cli\asc.js:1409:3)
▌ at Object.main (D:\assemblyscript\cli\asc.js:900:24)
▌ at runTest (D:\assemblyscript\tests\compiler.js:178:7)
▌
▌ If it refers to the dist files, try to 'npm install source-map-support' and
▌ run again, which should then show the actual code location in the sources.
▌
▌ 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!
Here's another test-case:
((): void => {})() ? 0 : 0
Yet another crash:
store<void>(1, ((): void => {})());
Original issue typeof ((): void => {})();
was fixed after #2412
Next ones still need to fix:
((): void => {})() ? 0 : 0
store<void>(1, ((): void => {})());