Skip to content

Commit db33acf

Browse files
authored
[cppia] Fix *= with boxed numbers in jit (#1259)
* [cppia] Fix *= with boxed numbers in jit In genSetter, if ioValue is a boxed int/float, then we cannot pass it directly into compiler->mult. We need to perform a conversion into a float. This is now closer to how aoSub is handled. * [tests] Add regression test for cppia jit *= bug
1 parent c284a29 commit db33acf

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/hx/cppia/Cppia.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3667,8 +3667,10 @@ void genSetter(CppiaCompiler *compiler, const JitVal &ioValue, ExprType exprType
36673667
compiler->mult(ioValue, sJitTempF0, ioValue,true);
36683668
else
36693669
{
3670-
compiler->mult(sJitTempF0, sJitTempF0, ioValue,true);
3671-
compiler->convert(sJitTempF0, etFloat, ioValue, exprType );
3670+
JitTemp fval(compiler, jtFloat);
3671+
compiler->convert(ioValue, exprType, fval, etFloat);
3672+
compiler->mult(sJitTempF0, sJitTempF0, fval, true);
3673+
compiler->convert(sJitTempF0, etFloat, ioValue, exprType);
36723674
}
36733675
}
36743676
break;

test/cppia/Client.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ class Client
189189
default:
190190
}
191191

192+
// regression test for #926
193+
var x:Dynamic = 3;
194+
x *= 5;
195+
if (x != 15) {
196+
Common.status = 'Failed regression test for #926. x: $x';
197+
return;
198+
}
199+
192200
final extending = new ClientExtendedExtendedRoot();
193201

194202
extending.addValue();

0 commit comments

Comments
 (0)