mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Adding support for UInt-to-char conversion (#6425)
This pull request adds support for integer-to-char conversion, allowing the compiler to correctly handle character casting, implementing part of the issue #5922. ```carbon import Core library "io"; fn Run() -> i32 { var i : i32 = 65; var ch: char = (i as char); // Support implemented! Core.PrintChar(ch); // Print 'A' return 0; } ``` --------- Co-authored-by: Dana Jansens <danakj@orodu.net> Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
This commit is contained in:
co-authored by
Dana Jansens
Carbon Infra Bot
parent
08669493b5
commit
f42352759f
@@ -446,6 +446,10 @@ constexpr BuiltinInfo CharConvertChecked = {
|
||||
"char.convert_checked",
|
||||
ValidateSignature<auto(CharLiteral)->CharCompatible>};
|
||||
|
||||
// Converts from an integer type to a char-compatible type (u8/adapted Char).
|
||||
constexpr BuiltinInfo IntConvertChar = {
|
||||
"int.convert_char", ValidateSignature<auto(AnyInt)->CharCompatible>};
|
||||
|
||||
// Converts between integer types, truncating if necessary.
|
||||
constexpr BuiltinInfo IntConvert = {"int.convert",
|
||||
ValidateSignature<auto(AnyInt)->AnyInt>};
|
||||
@@ -816,6 +820,7 @@ auto BuiltinFunctionKind::IsCompTimeOnly(const File& sem_ir,
|
||||
return true;
|
||||
|
||||
case IntConvert:
|
||||
case IntConvertChar:
|
||||
case IntSNegate:
|
||||
case IntComplement:
|
||||
case IntSAdd:
|
||||
|
||||
Reference in New Issue
Block a user