Skip to content

Passing the result of typeof into a generic fucntion causes an AssertionError in the compiler? #2282

Closed
@Heath123

Description

@Heath123

Save this to test.ts

function test<T>(value: T): void {}
test(typeof 1)
$ asc test.ts --binaryFile test.wasm

▌ 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 (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/std/portable/index.js:200:11)
▌     at h.resolveUnaryPrefixExpression (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/resolver.ts:1781:16)
▌     at h.resolveExpression (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/resolver.ts:1108:21)
▌     at h.maybeInferCall (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/resolver.ts:746:27)
▌     at f.compileCallExpression (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/compiler.ts:6330:46)
▌     at f.compileExpression (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/compiler.ts:3490:21)
▌     at f.compileExpressionStatement (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/compiler.ts:2521:17)
▌     at f.compileStatement (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/compiler.ts:2213:21)
▌     at f.compileTopLevelStatement (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/compiler.ts:2175:25)
▌     at f.compileFile (/usr/lib/node_modules/assemblyscript/dist/webpack:/assemblyscript/src/compiler.ts:1111:12)
▌ 
▌ 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions