-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Hi!
Thanks again for this great project!
I was playing with some AssemblyScript code and was surprised by the difference between i8[]
and Int8Array
.
For example, let's say I have:
export function getInt8ArrayLength(array: i8[]): i32 {
return array.length;
}
Then when I execute it like this:
getInt8ArrayLength(new Int8Array(3));
I get unrelated numbers like 44381
.
Now, I'm not very familiar with AssemblyScript so I am not sure if this should simply be forbidden (explicit runtime error?) or correctly handled. I was able to reproduce that behavior in AssemblyScript directly:
export function getInt32ArrayLength(a: i32[]): i32 { return a.length; }
export const Int32Array_ID = idof<Int32Array>();
export const i32a_ID = idof<i32[]>();
Then:
getInt32ArrayLength(__newArray(Int32Array_ID, new Int32Array(3))); // returns a wrong integer
getInt32ArrayLength(__newArray(i32a_ID, new Int32Array(3))); // works well
So the question is: do we have any way to know if the exported function argument's types?
I've started a branch here https://github.com/sutoiku/as-bind/tree/as-typed-arrays with tests that reproduces the behavior:
Let me know your thoughts.
Thanks!
Y.
Metadata
Metadata
Assignees
Labels
No labels