Skip to content

Assignment operators are not validated #118

Description

@anvaka
function helloWorld(stdlib, foreign, heap) {
  "use asm";

  var HEAP64 = new stdlib.Float64Array(heap);
  // this is what we're validating
  function giveThemTheAnswer() {
    var x = 2;
    // for each line below expected behavior to see:
    //  type error: unsupported expression;
    x += 2|0;
    x -= 2|0;
    x *= 2|0;
    x /= 2|0;
    x <<= 2|0;
    x >>= 2|0;

    // In reality asm.js doesn't see error above, and ignores it. If I run
    // this code through spider monkey shell (https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/ )
    // ./js -w hello.js
    // I get proper warnings.

    return x|0;
  }
  return { answer: giveThemTheAnswer };
}

print(helloWorld(this, null, new ArrayBuffer(0x10000)).answer());

PS: I know you mentioned in the readme file:

[..] this code is not up to date with the latest working draft and is not extensively tested. Patches to update it or fix bugs are welcome though.

Just wanted to log it here in case someone finds time to fix it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions