gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

Assignment in a for final expression is no longer supported

Open gnandretta opened this issue 7 years ago • 2 comments

What is wrong?

I can no longer use an assignment in the expression that gets evaluated after each loop in a for statement because an exception is raised. It used to work on v1.10.4.

Where does it happen?

I've seen this in node and in the browser, in ubuntu and in mac os. Using gpu.js version 2.0.2.

How do we replicate the issue?

const { GPU } = require('gpu.js');

const gpu = new GPU();

const f = gpu.createKernel(function() {
  let sum = 0;
  for (let i = 0; i < 5; i += 1) { // i = i + 1 also fails
    sum += 1;
  }
  return sum;
}).setOutput([5]);

f();

How important is this (1-5)?

1 — the code can be rewritten using a while, but it can make upgrading to v2 more difficult

gnandretta avatar Oct 01 '19 18:10 gnandretta

This works now, at least in v2.6.6.

robertleeplummerjr avatar Jan 24 '20 15:01 robertleeplummerjr

Thanks!

gnandretta avatar Jan 24 '20 17:01 gnandretta