Skip to content

fix(compiler): cast Object to narrow numeric types and promote unsigned arithmetic to long#94

Merged
skydread1 merged 5 commits into
developfrom
fix/91-92-numeric-casts-and-unsigned-promotion
Jul 23, 2026
Merged

fix(compiler): cast Object to narrow numeric types and promote unsigned arithmetic to long#94
skydread1 merged 5 commits into
developfrom
fix/91-92-numeric-casts-and-unsigned-promotion

Conversation

@skydread1

@skydread1 skydread1 commented Jul 23, 2026

Copy link
Copy Markdown
Member

Closes #91, Closes #92

  • convert-type now casts Object to Char, SByte, Int16, UInt16, UInt32 and UInt64 via the matching RT.*Cast methods instead of falling through to unbox.any, which threw InvalidCastException on a boxed value of another type.
  • Unsigned narrow integers (Byte, UInt16, UInt32) promote to Int64 for arithmetic, so (inc UInt32/MaxValue) is 4294967296 rather than wrapping to 0. inc and dec convert their argument to the computed type.
  • Adds suite and IL2CPP smoke regression coverage for both.
  • Refreshes the affected compiler and stdlib DLLs (clojure.core, core_clr, core_print, main, pprint.cl_format, string).

convert-type only cast Object to Int32, Int64, Byte, Single and Double;
Char, SByte, Int16, UInt16, UInt32 and UInt64 fell through to unbox.any
and threw InvalidCastException on a boxed value of another type. Add the
missing cases via the matching RT.*Cast / RT.unchecked*Cast methods.
Arithmetic computed in the operand's own type, so unsigned narrow ints
used signed .ovf opcodes in 32 bits and wrapped: (inc UInt32/MaxValue)
was 0. Promote Byte, UInt16 and UInt32 to Int64, and have inc and dec
convert their argument to the computed type.
@skydread1 skydread1 self-assigned this Jul 23, 2026
@skydread1
skydread1 force-pushed the fix/91-92-numeric-casts-and-unsigned-promotion branch from 09e6e38 to d206c73 Compare July 23, 2026 09:00
@skydread1
skydread1 merged commit ff984b4 into develop Jul 23, 2026
1 check passed
@skydread1
skydread1 deleted the fix/91-92-numeric-casts-and-unsigned-promotion branch July 23, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant