comptime integers part 2#422
Open
mbenke wants to merge 1 commit into
Open
Conversation
…romInteger Integer literals now have type `comptime integer` rather than `word`. `tcLit`/`typeOfTcExp` return `integer`; `isNumericTy` accepts it; a `markIntegerComptime` post-pass forces `ct=True` on any let binding of integer type. `Cond` propagates its expected type into both branches so literals in if/then/else infer correctly. Integer literal patterns adopt the scrutinee's numeric type in `tcPat`. A primitive `Int` class (instances `word` and `integer`) is introduced; `Int.fromInteger` is also accessible to user code. The specializer resolves `Int.fromInteger` to `wordFromInteger` or identity by result type. std gains `integer` instances for Eq/Ord/Add/Sub/Mul. Call sites that relied on bare literals defaulting to `word` now carry explicit `: word` annotations. Assisted-By: Claude Opus 4.8 <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.
This is the second part of comptime integer implementation: literals are of type integer; desugaring adds
Int.fromInteger