Skip to content

fix(compiler): choose integer widening extension from source signedness#90

Merged
skydread1 merged 2 commits into
developfrom
fix/87-unsigned-widening-sign-extend
Jul 23, 2026
Merged

fix(compiler): choose integer widening extension from source signedness#90
skydread1 merged 2 commits into
developfrom
fix/87-unsigned-widening-sign-extend

Conversation

@skydread1

Copy link
Copy Markdown
Member

Closes #87

  • convert-type selected the widening conv opcode from the target type, so extension to an 8-byte integer ignored the source's signedness. UInt32 widened to Int64 via conv.i8 and sign-extended, so (long UInt32/MaxValue) returned -1, and signed values widened to UInt64 via conv.u8 and zero-extended.
  • Widening to Int64 or UInt64 now emits conv.u8 for unsigned sources and conv.i8 for signed ones. Other conversions, including the common int to long, are unchanged.
  • Adds a widen-unsigned-to-long regression test in numbers.clj.
  • Refreshes the magic.core.clj.dll bootstrap binary and its dll-sources.edn entry.

…ss (#87)

convert-type picked the widening conv opcode from the target type, so
extension to an 8-byte integer ignored the source's signedness. UInt32
widened to Int64 via conv.i8 and sign-extended, making (long
UInt32/MaxValue) return -1, and signed values widened to UInt64 via
conv.u8 and zero-extended. Emit conv.u8 for unsigned sources and conv.i8
for signed ones.
@skydread1 skydread1 self-assigned this Jul 23, 2026
@skydread1
skydread1 merged commit 824b881 into develop Jul 23, 2026
1 check passed
@skydread1
skydread1 deleted the fix/87-unsigned-widening-sign-extend branch July 23, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widening an unsigned value to long sign-extends: (long UInt32/MaxValue) is -1

1 participant