Address unresolved review comments: genhl.ml UInt32 design, Lua truncation fix, test assertion fixes#12859
Conversation
…cation, fix Int32/64 test assertions Co-authored-by: Simn <634365+Simn@users.noreply.github.com> Agent-Logs-Url: https://github.com/HaxeFoundation/haxe/sessions/01972f1a-bfdf-4e6b-94da-b1c2d5d377db
|
The lua part still looks awkward, but at least it should be correct now. |
Does it have correct behaviour for negative floats turned into uint32? |
Maybe? The best way to find out is probably to add a test for it. I'm surprised this hasn't caused more general problems in lua because it seems like |
|
Apart from float edge cases it uses the clamp method directly: Line 55 in 35cbcb5 I think It is a bit difficult to add test cases for |
|
In my mind there should be one "make it int" function and one "clamp it to XX" per size which internally calls the "make it int" function too. |
Four unresolved review comments from the numeric types unification PR addressed.
genhl.ml— document whyhaxe.UInt32is not treated as unsignedThe vague
(* TODO: this causes unit test failures *)comment is replaced with a precise explanation:Int32Helper.utoFloatusesv < 0to detect the high bit for unsigned-to-float conversion. After Haxe inlines this helper with aUInt32-typed argument, the comparisonv < 0retainsUInt32as the expression type. Enabling the unsigned check emitsjugte(unsigned ≥, always false) instead ofjsgte, silently breaking the conversion. Native HL unsigned opcodes forUInt32would require a native HL override for the helper functions.Also removed the dead
["haxe"], "UInt32"arm from theto_typecoreType block —UInt32is not@:coreTypeso that branch was unreachable._hx_bit_clamp.lua— fix truncation direction for out-of-range negativesThe out-of-range branches in both the native Lua 5.3+ path and the
_hx_bit_rawpath used unconditionalmath.floor(v), which truncates toward −∞ for negative fractional inputs. This differs fromStd.int/ C truncation-toward-zero semantics. Fixed to usemath.floorfor positive andmath.ceilfor negative values, consistent with the already-correct in-range branch.TestInt32.hx— convert dead boolean expressions to assertionsThree bare boolean expression statements (
-min == min; ...) were not wrapped in any assertion call, so they never actually tested anything. Converted tot()assertions to verify theInt32==operator directly.TestInt64.hx— remove duplicate assertionLine 414 was an exact duplicate of line 413 (
eq(c.toString(), "572248275467371265")).📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.