Skip to content

Compiler error on call_indirect/function pointer #2349

Closed
@dsyer

Description

@dsyer
> asc assembly/index.ts --target debug


▌ Whoops, the AssemblyScript compiler has crashed during buildJS :-(
▌ 
▌ Here is the stack trace hinting at the problem, perhaps it's useful?
▌ 
▌ /home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/std/portable/index.js:200
▌     throw new AssertionError(message);
▌           ^
▌ 
▌ AssertionError: assertion failed
▌     at null.Q.assert (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/std/portable/index.js:200:11)
▌     at er.makeLowerToValue (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/js.ts:1020:21)
▌     at er.visitFunction (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/js.ts:390:16)
▌     at er.visitFunctionInstances (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/util.ts:132:53)
▌     at er.visitElement (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/util.ts:91:14)
▌     at er.visitFile (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/util.ts:59:14)
▌     at er.walk (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/util.ts:47:65)
▌     at er.build (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/js.ts:616:10)
▌     at Function.build (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/bindings/js.ts:99:40)
▌     at Module.mS (/home/dsyer/dev/scratch/hello-as/node_modules/assemblyscript/src/index-wasm.ts:335:20)
▌ 
▌ 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!

Simple program to reproduce:

@external("env", "console.log")
declare function print(s: i32): void

function increment(input: i32): i32 {
  return input + 1;
}

export function callback(fn: (input: i32) => i32, input: i32): i32 {
  return fn(input);
}

export function call(input: i32): i32 {
  return callback(increment, input);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions