-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
Addition is the only operator that can change its return type during Lowering. Consider:
function f() {
var i = 17;
var j = 18;
var k;
for (;;) {
k = i + j;
i = {};
}
}
Here, the addition i + j will be computed as ((double)i) + ((double)j) as that is the type used for integer additions (i = 17,j = 18), but when i is reassigned object, the addition remains, even though it should have been converted to a ScriptRuntime.ADD.
function runScript() {
function f() {
[|2|];
var i = ((object)17) [i (type=O) (slot=4)];
[|3|];
var j = 18 [j (type=I) (slot=5)];
[|4|];
var k [k (type=O) (slot=6)];
[|5|];
{
for (; ; ) {
[|6|];
DISCARD(k = (object)((double)i) + ((double)j));
[|7|];
DISCARD(i = {});
} [GOTO] [TERMINAL]
} [GOTO] [TERMINAL]
}
We need to keep track of additions based on type changing source variables. I believe that the add operator is unique here as it is the only "either object or numeric return value" operator that exists.
function f() {
var i = 17;
var j = 18;
var k;
for (;;) {
k = i + j;
i = {};
}
}
Here, the addition i + j will be computed as ((double)i) + ((double)j) as that is the type used for integer additions (i = 17,j = 18), but when i is reassigned object, the addition remains, even though it should have been converted to a ScriptRuntime.ADD.
function runScript() {
function f() {
[|2|];
var i = ((object)17) [i (type=O) (slot=4)];
[|3|];
var j = 18 [j (type=I) (slot=5)];
[|4|];
var k [k (type=O) (slot=6)];
[|5|];
{
for (; ; ) {
[|6|];
DISCARD(k = (object)((double)i) + ((double)j));
[|7|];
DISCARD(i = {});
} [GOTO] [TERMINAL]
} [GOTO] [TERMINAL]
}
We need to keep track of additions based on type changing source variables. I believe that the add operator is unique here as it is the only "either object or numeric return value" operator that exists.