Open yuxiaomao opened 3 months ago
Same issue there:
static inline function allocUID() : UID {
return (SEQ << (#if hxbit64 64 #else 32 #end - SEQ_BITS)) | (++UID);
}
With hxbit.UID should be Int
on ++UID
. Reverting a57c74c fixes that.
I have no intuition for how accessor + operator overload should interact here. Should this behave the same way as the +=
case or what?
The case of @kLabz is exactly why I open this issue. I'm replacing it locally to continue my dev, with
UID += 1;
return (SEQ << (#if hxbit64 64 #else 32 #end - SEQ_BITS)) | (UID);
@Simn if we have a + operator, we should be able to use +=
and prefix/postfix ++
, by generating the following code:
x += 1; // x = X.add(x,1)
++x; // same
x++; // { var tmp = x; x = X.add(x,1); tmp; }
Ok hang on, the specification is really not clear to me. We can have three different kinds of operator overload:
@:op(A + B)
@:op(A += B)
@:op(++A)
If I'm understanding what you're saying correctly, the following should be true:
a + b
only checks for @:op(A + B)
a += b
checks for @:op(A += B)
, and if that's not applicable it checks for @:op(A + B)
++a
checks for @:op(++A)
, and if that's not applicable it checks for @:op(A += B)
, and if that's not applicable it checks for @:op(A + B)
Is that correct? Note that I'm not even talking about getters/setters because it seems like the problem here starts even earlier.
I thought that @:op(A++)
is defined for haxe.Int64 which will performs an add1 (seems quite natural for me as that's an Int), I must have misunderstood something :'(
If I recall correctly, @ncannasse said that ++ on String should not be valid (but there is a + on String), so I do not think ++ should automatically performs a +1
Recently, the following example does not compile, with message "haxe.Int64 should be Int". However, we should be able to increment an
haxe.Int64
value. Without getter or without increment, the code compile correctly.The first bad commit is https://github.com/HaxeFoundation/haxe/commit/a57c74c770e986f6bbd40c350af6e1bae65abf0b which is also related to the issue about setter and increment https://github.com/HaxeFoundation/haxe/issues/11577