Skip to content

TypedArray forEach method have an unknown error #1051

@echoloyuk

Description

@echoloyuk

here is my demo code:

export function sum(arr: Uint32Array): i32 {
  let a: i32 = 0;
  arr.forEach((value: i32) => {
    a += value;
  });
  return a;
}

as the code sample means, function sum will return the array's sum. I use forEach to get the sum to param: a, and then return. but when i execute asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug command and then gets an error, with useless detail. I still cannot know whats going on?

The error in terminal is:

as1@1.0.0 asbuild:untouched /Users/mac/myProject/assemblyscript/as1
> asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug

ERROR: AssertionError: assertion failed
    at t.assert (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:556244)
    at m.compileBinaryExpression (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:258503)
    at m.compileExpression (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:245392)
    at m.compileExpressionStatement (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:234125)
    at m.compileStatement (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:230467)
    at m.compileStatements (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:231414)
    at m.compileFunctionBody (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:220994)
    at m.compileFunction (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:223519)
    at m.compileFunctionExpression (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:305108)
    at m.compileExpression (/Users/mac/myProject/assemblyscript/as1/node_modules/assemblyscript/dist/assemblyscript.js:1:245670)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! as1@1.0.0 asbuild:untouched: `asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the as1@1.0.0 asbuild:untouched script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mac/.npm/_logs/2020-01-10T16_49_30_104Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! as1@1.0.0 asbuild: `npm run asbuild:untouched && npm run asbuild:optimized`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the as1@1.0.0 asbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mac/.npm/_logs/2020-01-10T16_49_30_130Z-debug.log

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