Skip to content

Bug with TypedArray.set() when the code is optimized? #1288

Description

@alexvictoor

Hello all,
I have found a strange behaviour with TypedArray.set().
The following code fragment works fine in an as-pect test or when the code is compiled without the "--optimize" flag:

  let buffer = new Uint8Array(1);
  buffer[0] = 42;
  const oldBuffer = buffer;
  buffer = new Uint8Array(2);
  buffer.set(oldBuffer);
  buffer[1] = 1;
  // buffer[0] === 42

However, when the "--optimize" flag is used, buffer[0] is set to 0 at the end...
Here is a link to see this bug in action: https://webassembly.studio/?f=wtzfbyvd2q
Let me know if you need anything else!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions