Zaplib/zaplib

When passing a casted typed array to rust, it gets the wrong type

janpaul123 opened this issue · 1 comments

Steps to reproduce:

  • Create a mutable ZapArray of u8
  • Cast it to a Float32Array (e.g. using new Float32Array(myarray.buffer, myarray.byteOffset, myarray.length / 4))
  • Pass it to Rust using callRustSync
  • It gets instantiated as a Vec<f32> with the wrong length

I think it's clearest if we disallow passing casted arrays to Rust, by throwing an error at runtime. We can later also catch this at compile time through Typescript definition generation (part of #99). We can then properly allow sending casted arrays to Rust when we've implemented #103.

Oh my bad, I was confused. This is already properly implemented (by @disambiguator)! Sorry!