From 821076628cee4e3f78f454a24792bf649b6d83c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:00:20 +0000 Subject: [PATCH 1/3] Initial plan From 41778d5838709380d6c3f5e314bfc5286c0fc878 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:13:21 +0000 Subject: [PATCH 2/3] Replace body-less @:op methods in Int32 with explicit implementations; add compare() Co-authored-by: Simn <634365+Simn@users.noreply.github.com> --- std/haxe/Int32.hx | 127 ++++++++++++++++++++++---------- std/haxe/numeric/Int32Direct.hx | 9 +++ std/haxe/numeric/Int32Native.hx | 9 +++ 3 files changed, 105 insertions(+), 40 deletions(-) diff --git a/std/haxe/Int32.hx b/std/haxe/Int32.hx index 1f08d229c43..38685791951 100644 --- a/std/haxe/Int32.hx +++ b/std/haxe/Int32.hx @@ -79,7 +79,8 @@ abstract Int32(Int32Native) from Int to Int { @:op(A + B) @:commutative private static inline function addInt(a:Int32, b:Int):Int32 return Int32Native.add(a, b); - @:op(A + B) @:commutative private static function addFloat(a:Int32, b:Float):Float; + @:op(A + B) @:commutative private static inline function addFloat(a:Int32, b:Float):Float + return (a : Int) + b; @:op(A - B) private static inline function sub(a:Int32, b:Int32):Int32 return Int32Native.sub(a, b); @@ -90,9 +91,11 @@ abstract Int32(Int32Native) from Int to Int { @:op(A - B) private static inline function intSub(a:Int, b:Int32):Int32 return Int32Native.sub(a, b); - @:op(A - B) private static function subFloat(a:Int32, b:Float):Float; + @:op(A - B) private static inline function subFloat(a:Int32, b:Float):Float + return (a : Int) - b; - @:op(A - B) private static function floatSub(a:Float, b:Int32):Float; + @:op(A - B) private static inline function floatSub(a:Float, b:Int32):Float + return a - (b : Int); @:op(A * B) private static inline function mul(a:Int32, b:Int32):Int32 return Int32Native.mul(a, b); @@ -100,79 +103,116 @@ abstract Int32(Int32Native) from Int to Int { @:op(A * B) @:commutative private static inline function mulInt(a:Int32, b:Int):Int32 return Int32Native.mul(a, b); - @:op(A * B) @:commutative private static function mulFloat(a:Int32, b:Float):Float; + @:op(A * B) @:commutative private static inline function mulFloat(a:Int32, b:Float):Float + return (a : Int) * b; - @:op(A / B) private static function div(a:Int32, b:Int32):Float; + @:op(A / B) private static inline function div(a:Int32, b:Int32):Float + return (a : Int) / (b : Int); - @:op(A / B) private static function divInt(a:Int32, b:Int):Float; + @:op(A / B) private static inline function divInt(a:Int32, b:Int):Float + return (a : Int) / b; - @:op(A / B) private static function intDiv(a:Int, b:Int32):Float; + @:op(A / B) private static inline function intDiv(a:Int, b:Int32):Float + return a / (b : Int); - @:op(A / B) private static function divFloat(a:Int32, b:Float):Float; + @:op(A / B) private static inline function divFloat(a:Int32, b:Float):Float + return (a : Int) / b; - @:op(A / B) private static function floatDiv(a:Float, b:Int32):Float; + @:op(A / B) private static inline function floatDiv(a:Float, b:Int32):Float + return a / (b : Int); - @:op(A % B) private static function mod(a:Int32, b:Int32):Int32; + @:op(A % B) private static inline function mod(a:Int32, b:Int32):Int32 + return Int32Native.mod(a, b); - @:op(A % B) private static function modInt(a:Int32, b:Int):Int; + @:op(A % B) private static inline function modInt(a:Int32, b:Int):Int + return (a : Int) % b; - @:op(A % B) private static function intMod(a:Int, b:Int32):Int; + @:op(A % B) private static inline function intMod(a:Int, b:Int32):Int + return a % (b : Int); - @:op(A % B) private static function modFloat(a:Int32, b:Float):Float; + @:op(A % B) private static inline function modFloat(a:Int32, b:Float):Float + return (a : Int) % b; - @:op(A % B) private static function floatMod(a:Float, b:Int32):Float; + @:op(A % B) private static inline function floatMod(a:Float, b:Int32):Float + return a % (b : Int); - @:op(A == B) private static function eq(a:Int32, b:Int32):Bool; + @:op(A == B) private static inline function eq(a:Int32, b:Int32):Bool + return (a : Int) == (b : Int); - @:op(A == B) @:commutative private static function eqInt(a:Int32, b:Int):Bool; + @:op(A == B) @:commutative private static inline function eqInt(a:Int32, b:Int):Bool + return (a : Int) == b; - @:op(A == B) @:commutative private static function eqFloat(a:Int32, b:Float):Bool; + @:op(A == B) @:commutative private static inline function eqFloat(a:Int32, b:Float):Bool + return (a : Int) == b; - @:op(A != B) private static function neq(a:Int32, b:Int32):Bool; + @:op(A != B) private static inline function neq(a:Int32, b:Int32):Bool + return (a : Int) != (b : Int); - @:op(A != B) @:commutative private static function neqInt(a:Int32, b:Int):Bool; + @:op(A != B) @:commutative private static inline function neqInt(a:Int32, b:Int):Bool + return (a : Int) != b; - @:op(A != B) @:commutative private static function neqFloat(a:Int32, b:Float):Bool; + @:op(A != B) @:commutative private static inline function neqFloat(a:Int32, b:Float):Bool + return (a : Int) != b; - @:op(A < B) private static function lt(a:Int32, b:Int32):Bool; + @:op(A < B) private static inline function lt(a:Int32, b:Int32):Bool + return compare(a, b) < 0; - @:op(A < B) private static function ltInt(a:Int32, b:Int):Bool; + @:op(A < B) private static inline function ltInt(a:Int32, b:Int):Bool + return (a : Int) < b; - @:op(A < B) private static function intLt(a:Int, b:Int32):Bool; + @:op(A < B) private static inline function intLt(a:Int, b:Int32):Bool + return a < (b : Int); - @:op(A < B) private static function ltFloat(a:Int32, b:Float):Bool; + @:op(A < B) private static inline function ltFloat(a:Int32, b:Float):Bool + return (a : Int) < b; - @:op(A < B) private static function floatLt(a:Float, b:Int32):Bool; + @:op(A < B) private static inline function floatLt(a:Float, b:Int32):Bool + return a < (b : Int); - @:op(A <= B) private static function lte(a:Int32, b:Int32):Bool; + @:op(A <= B) private static inline function lte(a:Int32, b:Int32):Bool + return compare(a, b) <= 0; - @:op(A <= B) private static function lteInt(a:Int32, b:Int):Bool; + @:op(A <= B) private static inline function lteInt(a:Int32, b:Int):Bool + return (a : Int) <= b; - @:op(A <= B) private static function intLte(a:Int, b:Int32):Bool; + @:op(A <= B) private static inline function intLte(a:Int, b:Int32):Bool + return a <= (b : Int); - @:op(A <= B) private static function lteFloat(a:Int32, b:Float):Bool; + @:op(A <= B) private static inline function lteFloat(a:Int32, b:Float):Bool + return (a : Int) <= b; - @:op(A <= B) private static function floatLte(a:Float, b:Int32):Bool; + @:op(A <= B) private static inline function floatLte(a:Float, b:Int32):Bool + return a <= (b : Int); - @:op(A > B) private static function gt(a:Int32, b:Int32):Bool; + @:op(A > B) private static inline function gt(a:Int32, b:Int32):Bool + return compare(a, b) > 0; - @:op(A > B) private static function gtInt(a:Int32, b:Int):Bool; + @:op(A > B) private static inline function gtInt(a:Int32, b:Int):Bool + return (a : Int) > b; - @:op(A > B) private static function intGt(a:Int, b:Int32):Bool; + @:op(A > B) private static inline function intGt(a:Int, b:Int32):Bool + return a > (b : Int); - @:op(A > B) private static function gtFloat(a:Int32, b:Float):Bool; + @:op(A > B) private static inline function gtFloat(a:Int32, b:Float):Bool + return (a : Int) > b; - @:op(A > B) private static function floatGt(a:Float, b:Int32):Bool; + @:op(A > B) private static inline function floatGt(a:Float, b:Int32):Bool + return a > (b : Int); - @:op(A >= B) private static function gte(a:Int32, b:Int32):Bool; + @:op(A >= B) private static inline function gte(a:Int32, b:Int32):Bool + return compare(a, b) >= 0; - @:op(A >= B) private static function gteInt(a:Int32, b:Int):Bool; + @:op(A >= B) private static inline function gteInt(a:Int32, b:Int):Bool + return (a : Int) >= b; - @:op(A >= B) private static function intGte(a:Int, b:Int32):Bool; + @:op(A >= B) private static inline function intGte(a:Int, b:Int32):Bool + return a >= (b : Int); - @:op(A >= B) private static function gteFloat(a:Int32, b:Float):Bool; + @:op(A >= B) private static inline function gteFloat(a:Int32, b:Float):Bool + return (a : Int) >= b; - @:op(A >= B) private static function floatGte(a:Float, b:Int32):Bool; + @:op(A >= B) private static inline function floatGte(a:Float, b:Int32):Bool + return a >= (b : Int); @:op(~A) private static inline function complement(a:Int32):Int32 return Int32Native.complement(a); @@ -225,6 +265,13 @@ abstract Int32(Int32Native) from Int to Int { @:to private inline function toFloat():Float return (this : Int); + /** + Compare `a` and `b` in signed mode. + Returns a negative value if `a < b`, positive if `a > b`, or 0 if `a == b`. + **/ + public static inline function compare(a:Int32, b:Int32):Int + return Int32Native.compare(a, b); + /** Compare `a` and `b` in unsigned mode. **/ diff --git a/std/haxe/numeric/Int32Direct.hx b/std/haxe/numeric/Int32Direct.hx index c8d07cd6017..81c482a6f24 100644 --- a/std/haxe/numeric/Int32Direct.hx +++ b/std/haxe/numeric/Int32Direct.hx @@ -67,6 +67,12 @@ abstract Int32Direct(Int) from Int to Int { public static inline function ushr(a:Int32Direct, b:Int):Int32Direct return cast((a : Int) >>> b); + public static inline function compare(a:Int32Direct, b:Int32Direct):Int { + var av:Int = a; + var bv:Int = b; + return av < bv ? -1 : (av > bv ? 1 : 0); + } + public static function ucompare(a:Int32Direct, b:Int32Direct):Int { if ((a : Int) < 0) return (b : Int) < 0 ? (~(b : Int) - ~(a : Int)) : 1; @@ -76,6 +82,9 @@ abstract Int32Direct(Int) from Int to Int { public inline function toFloat():Float return this; + public static inline function mod(a:Int32Direct, b:Int32Direct):Int32Direct + return cast((a : Int) % (b : Int)); + public static inline function clamp(x:Int):Int32Direct return cast x; } diff --git a/std/haxe/numeric/Int32Native.hx b/std/haxe/numeric/Int32Native.hx index 189df0f0cbf..3c5e4f6f35f 100644 --- a/std/haxe/numeric/Int32Native.hx +++ b/std/haxe/numeric/Int32Native.hx @@ -101,12 +101,21 @@ private abstract Int32NativeImpl(Int) from Int to Int { public static inline function ushr(a:Int32Native, b:Int):Int32Native return cast((a : Int) >>> b); + public static inline function compare(a:Int32Native, b:Int32Native):Int { + var av:Int = a; + var bv:Int = b; + return av < bv ? -1 : (av > bv ? 1 : 0); + } + public static function ucompare(a:Int32Native, b:Int32Native):Int { if ((a : Int) < 0) return (b : Int) < 0 ? (~(b : Int) - ~(a : Int)) : 1; return (b : Int) < 0 ? -1 : ((a : Int) - (b : Int)); } + public static inline function mod(a:Int32Native, b:Int32Native):Int32Native + return cast((a : Int) % (b : Int)); + public inline function toFloat():Float return this; From 617efe6a7ac1801c2966787c6d34d1fc163c9132 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:42:02 +0000 Subject: [PATCH 3/3] Redesign Int32 operator overloads: use type-parameter bounds, auto-promotions; remove exhaustive mixed-type permutations Co-authored-by: Simn <634365+Simn@users.noreply.github.com> --- std/haxe/Int32.hx | 163 +++++++++------------------------------------- 1 file changed, 29 insertions(+), 134 deletions(-) diff --git a/std/haxe/Int32.hx b/std/haxe/Int32.hx index 38685791951..04e42d3da79 100644 --- a/std/haxe/Int32.hx +++ b/std/haxe/Int32.hx @@ -76,143 +76,65 @@ abstract Int32(Int32Native) from Int to Int { @:op(A + B) private static inline function add(a:Int32, b:Int32):Int32 return Int32Native.add(a, b); - @:op(A + B) @:commutative private static inline function addInt(a:Int32, b:Int):Int32 - return Int32Native.add(a, b); - - @:op(A + B) @:commutative private static inline function addFloat(a:Int32, b:Float):Float - return (a : Int) + b; - @:op(A - B) private static inline function sub(a:Int32, b:Int32):Int32 return Int32Native.sub(a, b); - @:op(A - B) private static inline function subInt(a:Int32, b:Int):Int32 - return Int32Native.sub(a, b); - - @:op(A - B) private static inline function intSub(a:Int, b:Int32):Int32 - return Int32Native.sub(a, b); - - @:op(A - B) private static inline function subFloat(a:Int32, b:Float):Float - return (a : Int) - b; - - @:op(A - B) private static inline function floatSub(a:Float, b:Int32):Float - return a - (b : Int); - @:op(A * B) private static inline function mul(a:Int32, b:Int32):Int32 return Int32Native.mul(a, b); - @:op(A * B) @:commutative private static inline function mulInt(a:Int32, b:Int):Int32 - return Int32Native.mul(a, b); - - @:op(A * B) @:commutative private static inline function mulFloat(a:Int32, b:Float):Float - return (a : Int) * b; - @:op(A / B) private static inline function div(a:Int32, b:Int32):Float return (a : Int) / (b : Int); - @:op(A / B) private static inline function divInt(a:Int32, b:Int):Float - return (a : Int) / b; - - @:op(A / B) private static inline function intDiv(a:Int, b:Int32):Float - return a / (b : Int); - - @:op(A / B) private static inline function divFloat(a:Int32, b:Float):Float - return (a : Int) / b; - - @:op(A / B) private static inline function floatDiv(a:Float, b:Int32):Float - return a / (b : Int); - @:op(A % B) private static inline function mod(a:Int32, b:Int32):Int32 return Int32Native.mod(a, b); - @:op(A % B) private static inline function modInt(a:Int32, b:Int):Int - return (a : Int) % b; - - @:op(A % B) private static inline function intMod(a:Int, b:Int32):Int - return a % (b : Int); - - @:op(A % B) private static inline function modFloat(a:Int32, b:Float):Float - return (a : Int) % b; - - @:op(A % B) private static inline function floatMod(a:Float, b:Int32):Float - return a % (b : Int); - - @:op(A == B) private static inline function eq(a:Int32, b:Int32):Bool - return (a : Int) == (b : Int); - - @:op(A == B) @:commutative private static inline function eqInt(a:Int32, b:Int):Bool - return (a : Int) == b; - - @:op(A == B) @:commutative private static inline function eqFloat(a:Int32, b:Float):Bool + @:op(A == B) @:commutative private static inline function equalsInt(a:Int32, b:T):Bool return (a : Int) == b; - @:op(A != B) private static inline function neq(a:Int32, b:Int32):Bool - return (a : Int) != (b : Int); - - @:op(A != B) @:commutative private static inline function neqInt(a:Int32, b:Int):Bool + @:op(A != B) @:commutative private static inline function notEqualsInt(a:Int32, b:T):Bool return (a : Int) != b; - @:op(A != B) @:commutative private static inline function neqFloat(a:Int32, b:Float):Bool - return (a : Int) != b; + @:op(A == B) @:commutative private static inline function equalsFloat(a:Int32, b:T):Bool + return (a : Float) == b; + + @:op(A != B) @:commutative private static inline function notEqualsFloat(a:Int32, b:T):Bool + return (a : Float) != b; @:op(A < B) private static inline function lt(a:Int32, b:Int32):Bool return compare(a, b) < 0; - @:op(A < B) private static inline function ltInt(a:Int32, b:Int):Bool - return (a : Int) < b; - - @:op(A < B) private static inline function intLt(a:Int, b:Int32):Bool - return a < (b : Int); - - @:op(A < B) private static inline function ltFloat(a:Int32, b:Float):Bool - return (a : Int) < b; - - @:op(A < B) private static inline function floatLt(a:Float, b:Int32):Bool - return a < (b : Int); - @:op(A <= B) private static inline function lte(a:Int32, b:Int32):Bool return compare(a, b) <= 0; - @:op(A <= B) private static inline function lteInt(a:Int32, b:Int):Bool - return (a : Int) <= b; - - @:op(A <= B) private static inline function intLte(a:Int, b:Int32):Bool - return a <= (b : Int); - - @:op(A <= B) private static inline function lteFloat(a:Int32, b:Float):Bool - return (a : Int) <= b; - - @:op(A <= B) private static inline function floatLte(a:Float, b:Int32):Bool - return a <= (b : Int); - @:op(A > B) private static inline function gt(a:Int32, b:Int32):Bool return compare(a, b) > 0; - @:op(A > B) private static inline function gtInt(a:Int32, b:Int):Bool - return (a : Int) > b; + @:op(A >= B) private static inline function gte(a:Int32, b:Int32):Bool + return compare(a, b) >= 0; - @:op(A > B) private static inline function intGt(a:Int, b:Int32):Bool - return a > (b : Int); + @:op(A < B) private static inline function ltFloat(a:Int32, b:T):Bool + return (a : Float) < b; - @:op(A > B) private static inline function gtFloat(a:Int32, b:Float):Bool - return (a : Int) > b; + @:op(A < B) private static inline function floatLt(a:T, b:Int32):Bool + return a < (b : Float); - @:op(A > B) private static inline function floatGt(a:Float, b:Int32):Bool - return a > (b : Int); + @:op(A <= B) private static inline function lteFloat(a:Int32, b:T):Bool + return (a : Float) <= b; - @:op(A >= B) private static inline function gte(a:Int32, b:Int32):Bool - return compare(a, b) >= 0; + @:op(A <= B) private static inline function floatLte(a:T, b:Int32):Bool + return a <= (b : Float); - @:op(A >= B) private static inline function gteInt(a:Int32, b:Int):Bool - return (a : Int) >= b; + @:op(A > B) private static inline function gtFloat(a:Int32, b:T):Bool + return (a : Float) > b; - @:op(A >= B) private static inline function intGte(a:Int, b:Int32):Bool - return a >= (b : Int); + @:op(A > B) private static inline function floatGt(a:T, b:Int32):Bool + return a > (b : Float); - @:op(A >= B) private static inline function gteFloat(a:Int32, b:Float):Bool - return (a : Int) >= b; + @:op(A >= B) private static inline function gteFloat(a:Int32, b:T):Bool + return (a : Float) >= b; - @:op(A >= B) private static inline function floatGte(a:Float, b:Int32):Bool - return a >= (b : Int); + @:op(A >= B) private static inline function floatGte(a:T, b:Int32):Bool + return a >= (b : Float); @:op(~A) private static inline function complement(a:Int32):Int32 return Int32Native.complement(a); @@ -220,48 +142,21 @@ abstract Int32(Int32Native) from Int to Int { @:op(A & B) private static inline function and(a:Int32, b:Int32):Int32 return Int32Native.and(a, b); - @:op(A & B) @:commutative private static inline function andInt(a:Int32, b:Int):Int32 - return Int32Native.and(a, b); - @:op(A | B) private static inline function or(a:Int32, b:Int32):Int32 return Int32Native.or(a, b); - @:op(A | B) @:commutative private static inline function orInt(a:Int32, b:Int):Int32 - return Int32Native.or(a, b); - @:op(A ^ B) private static inline function xor(a:Int32, b:Int32):Int32 return Int32Native.xor(a, b); - @:op(A ^ B) @:commutative private static inline function xorInt(a:Int32, b:Int):Int32 - return Int32Native.xor(a, b); - - @:op(A >> B) private static inline function shr(a:Int32, b:Int32):Int32 - return Int32Native.shr(a, (b : Int)); + @:op(A << B) private static inline function shl(a:Int32, b:Int):Int32 + return Int32Native.shl(a, b); - @:op(A >> B) private static inline function shrInt(a:Int32, b:Int):Int32 + @:op(A >> B) private static inline function shr(a:Int32, b:Int):Int32 return Int32Native.shr(a, b); - @:op(A >> B) private static inline function intShr(a:Int, b:Int32):Int32 - return Int32Native.shr(a, (b : Int)); - - @:op(A >>> B) private static inline function ushr(a:Int32, b:Int32):Int32 - return Int32Native.ushr(a, (b : Int)); - - @:op(A >>> B) private static inline function ushrInt(a:Int32, b:Int):Int32 + @:op(A >>> B) private static inline function ushr(a:Int32, b:Int):Int32 return Int32Native.ushr(a, b); - @:op(A >>> B) private static inline function intUshr(a:Int, b:Int32):Int32 - return Int32Native.ushr(a, (b : Int)); - - @:op(A << B) private static inline function shl(a:Int32, b:Int32):Int32 - return Int32Native.shl(a, (b : Int)); - - @:op(A << B) private static inline function shlInt(a:Int32, b:Int):Int32 - return Int32Native.shl(a, b); - - @:op(A << B) private static inline function intShl(a:Int, b:Int32):Int32 - return Int32Native.shl(a, (b : Int)); - @:to private inline function toFloat():Float return (this : Int);