JS_WALA icon indicating copy to clipboard operation
JS_WALA copied to clipboard

handle ++ on strings in normalization

Open msridhar opened this issue 12 years ago • 1 comments

Consider the following code:

var j = "0";
var k = j++;
console.log(j);
console.log(k);
var l = "1";
var m = ++l;
console.log(l);
console.log(m);

When run under node, the output is:

1
0
2
2

But after normalization, we get:

01
0
11
11

Gotta love JavaScript.

msridhar avatar Jan 15 '14 04:01 msridhar

Nice. The normaliser currently ignores implicit conversions, which is, I believe, what leads to this bug.

It currently transforms ++x into x = x + 1, but this example suggests it should be `x = +x + 1'.

xiemaisi avatar Jan 15 '14 08:01 xiemaisi