AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.6k stars 650 forks source link

Wrong location for certain errors #2852

Open mattjohnsonpint opened 3 weeks ago

mattjohnsonpint commented 3 weeks ago

Bug description

For certain common errors, such as accessing an array index that is out of bounds, the error message returned shows the location of the error in the standard library rather than the location of the code that caused the error.

Steps to reproduce

Consider this user code, in a file at /assembly/index.ts:

export function test(): i32 {
  const a: i32[] = [0, 1, 2];
  const i = a[3]; // error should occur here
  return i;
}

When invoked by the host, the error given is:

abort: Index out of range in ~lib/array.ts(114:42)

Which is here, but IMHO not very useful.

I would expect:

abort: Index out of range in index.ts(3:15)

AssemblyScript version

v0.27.27