Skip to content

Support conversion between integer types.#6856

Open
zygoloid wants to merge 1 commit intocarbon-language:trunkfrom
zygoloid:toolchain-int-convert
Open

Support conversion between integer types.#6856
zygoloid wants to merge 1 commit intocarbon-language:trunkfrom
zygoloid:toolchain-int-convert

Conversation

@zygoloid
Copy link
Contributor

@zygoloid zygoloid commented Mar 7, 2026

Add an IntFitsIn interface with a custom witness, such that T impls IntFitsIn(U) if T is an integer type all of whose values fit losslessly into the integer type U. Use it to constrain implicit conversions between integer types.

So far, this has not been extended to the CppCompat.[U]{Long32,LongLong64} types, only to Core.Int(N) and Core.UInt(N).

Assisted-by: Gemini 3 Pro via Antigravity

@zygoloid zygoloid requested a review from a team as a code owner March 7, 2026 02:30
@zygoloid zygoloid requested review from dwblaikie and removed request for a team March 7, 2026 02:30
Add an `IntFitsIn` interface with a custom witness, such that `T impls
IntFitsIn(U)` if `T` is an integer type all of whose values fit
losslessly into the integer type `U`. Use it to constrain implicit
conversions between integer types.

Assisted-by: Gemini 3 Pro via Antigravity
@zygoloid zygoloid force-pushed the toolchain-int-convert branch from 96e8777 to 4dff236 Compare March 7, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant