Skip to content

Assigning null to a const declaration annotated with anyref crashes the compiler #2209

Closed
@romdotdog

Description

@romdotdog

Code

// the `const` here is necessary
const a: anyref = null;
const b: i31ref = null;
// this also works
const c: dataref = null;
// and this
const d: dataref = undeclared_variable;
const e: dataref = 1;

Try it in the playground

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 Module.runExpression (D:\assemblyscript\src\module.ts:2574:7)
▌     at Compiler.compileGlobal (D:\assemblyscript\src\compiler.ts:1272:34)
▌     at Compiler.compileTopLevelStatement (D:\assemblyscript\src\compiler.ts:2140:20)
▌     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)
▌     at Array.forEach (<anonymous>)
▌     at D:\assemblyscript\tests\compiler.js:557:16
▌     at processTicksAndRejections (node:internal/process/task_queues:96:5)
▌ 
▌ 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