Repository navigation
A sign-neutral iN is signed: it prints, widens and compares keeping its sign - #432
Merged
Merged
Conversation
…ts sign `let a: i32 = -1` printed 4294967295 (while it converted to number as -1), `let b: i8 = -5` printed 251, and widening to a larger integer zero-extended unless both sides were signed: `let c: i64 = -7` held 4294967289, and `i16` -300 compared with 0 as 65236, so `d < 0` was false. Widening now follows the source: a signed or sign-neutral integer sign-extends (to any wider integer or index), only an unsigned one zero-extends. A sign-neutral integer prints signed; uN still prints unsigned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
A sign-neutral integer (
i8…i64) lost its sign:let a: i32 = -1; print(a)4294967295, althoughaconverts tonumberas -1let b: i8 = -5251let c: i64 = -74294967289: thes32literal was zero-extendedlet d: i16 = -300; d < 0false:dwas widened with zeros and compared as 65236A widening cast sign-extended only when both sides were signed integers. Otherwise it fell through to the zero-extension in
castLLVMTypesLogic, which sees only the signless LLVM types.Fix
In
CastLogicHelper.h:index. Only an unsigned one zero-extends. This replaces the two narrower sign-extension cases, signed→signed and signed→index.number.uNstill prints unsigned.Tests
00signless_int_signed.ts, run as compile and jit. It coversi8,i16,i32andi64printing and comparing,i32→index,i32inany, and that unsigned sources still widen with zeros. It passes under gc, rc and none.-mm=own.🤖 Generated with Claude Code