Skip to content

comptime integers part 2#422

Open
mbenke wants to merge 1 commit into
comptime-intfrom
comptime-int2
Open

comptime integers part 2#422
mbenke wants to merge 1 commit into
comptime-intfrom
comptime-int2

Conversation

@mbenke

@mbenke mbenke commented May 30, 2026

Copy link
Copy Markdown
Collaborator

This is the second part of comptime integer implementation: literals are of type integer; desugaring adds Int.fromInteger

…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>
@mbenke mbenke requested a review from rodrigogribeiro May 30, 2026 12:17
@mbenke mbenke changed the title integer literals are comptime integer, desugared via overloaded Int.f… comptime integers part 2 May 30, 2026
@mbenke mbenke marked this pull request as ready for review June 4, 2026 14:32

@rodrigogribeiro rodrigogribeiro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

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.

2 participants