Skip to content

fix(compiler): promote narrow integer arithmetic to long (#93)#95

Merged
skydread1 merged 2 commits into
developfrom
fix/93-integer-promotion
Jul 23, 2026
Merged

fix(compiler): promote narrow integer arithmetic to long (#93)#95
skydread1 merged 2 commits into
developfrom
fix/93-integer-promotion

Conversation

@skydread1

@skydread1 skydread1 commented Jul 23, 2026

Copy link
Copy Markdown
Member

Closes #93

  • Arithmetic intrinsics computed in the operand's own type, so narrow integers overflowed or wrapped at the edge of that width. (inc Int32/MaxValue) threw OverflowException instead of giving the long 2147483648.
  • Generalize promote-unsigned to promote-integer, widening the whole narrow integer family (Byte, SByte, Int16, UInt16, Int32, UInt32) to Int64, matching ClojureCLR's long-based numeric tower where these types dispatch to LongOps.
  • UInt64 stays as is. It cannot widen to Int64 losslessly, and ClojureCLR promotes it to BigInteger.
  • Refresh the compiler and affected stdlib DLLs across references and both magic-unity variants.

Arithmetic intrinsics computed in the operand's own type, so narrow
integers overflowed or wrapped: (inc Int32/MaxValue) threw instead of
giving the long 2147483648. Widen the whole narrow family (Byte, SByte,
Int16, UInt16, Int32, UInt32) to Int64, matching ClojureCLR's long-based
numeric tower. UInt64 stays as is: it cannot fit Int64, and ClojureCLR
promotes it to BigInteger.
…ion (#93)

Regenerate the compiler and affected stdlib DLLs across references and
both magic-unity variants for the narrow integer promotion fix.
@skydread1 skydread1 added comp:magic-compiler Clojure compiler and stdlib comp:unity-examples Example Unity projects under unity-examples/ (smoke + coexist) labels Jul 23, 2026
@skydread1 skydread1 self-assigned this Jul 23, 2026
@skydread1
skydread1 merged commit 2af9b70 into develop Jul 23, 2026
1 check passed
@skydread1
skydread1 deleted the fix/93-integer-promotion branch July 23, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:magic-compiler Clojure compiler and stdlib comp:unity-examples Example Unity projects under unity-examples/ (smoke + coexist)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer arithmetic does not promote narrow types to long: (inc Int32/MaxValue) overflows

1 participant