haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Int64 operators crash when null

Open Nestorboy opened this issue 4 months ago • 2 comments

The Int64 class is supported using two backing Ints, and when performing operators, it needs to access those two backing Ints. However, none of the operators do any form of null checking and this leads to crashes when Int64 is nullable. Int32 differs in this regard, since it ends up treating null as 0. Here's just one of many examples where this issue occurs:

final i:Int64 = 123;
final n:Int64 = null;
trace(i == n); // TypeError: can't access property "high", n is null

final i:Int32 = 123;
final n:Int32 = null;
trace(i == n); // false

I can't find any information about this behaviour, but I'm assuming this is a bug since the behaviour doesn't coincide with Int32 or Int and can lead to weird gotchas

Nestorboy avatar Oct 16 '25 13:10 Nestorboy

I think this is an unfortunate necessity on targets that don't have a native Int64 implementation and need to emulate it. Int64 is a bit special because it's a native value on some targets and a class instance on others.

Simn avatar Nov 24 '25 17:11 Simn

What issues could arise from simply introducing a null check in the operators? Would it align less with the expected behavior of some platforms?

Nestorboy avatar Nov 24 '25 17:11 Nestorboy