fix(compiler): cast Object to narrow numeric types and promote unsigned arithmetic to long#94
Merged
skydread1 merged 5 commits intoJul 23, 2026
Conversation
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
force-pushed
the
fix/91-92-numeric-casts-and-unsigned-promotion
branch
from
July 23, 2026 09:00
09e6e38 to
d206c73
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #91, Closes #92
convert-typenow castsObjecttoChar,SByte,Int16,UInt16,UInt32andUInt64via the matchingRT.*Castmethods instead of falling through tounbox.any, which threwInvalidCastExceptionon a boxed value of another type.Byte,UInt16,UInt32) promote toInt64for arithmetic, so(inc UInt32/MaxValue)is4294967296rather than wrapping to0.incanddecconvert their argument to the computed type.clojure.core,core_clr,core_print,main,pprint.cl_format,string).