Add prelude support for implicit conversion between integer literals and sized integer types. (#4525)

In preparation for changing integer literals to be of `IntLiteral` type.
Conversions from the integer literal type are only permitted when the
value fits within the destination type.

For now, if conversion cannot be checked because the source value is a
symbolic constant, produce a symbolic constant representing the
conversion rather than rejecting it.
This commit is contained in:
Richard Smith
2024-11-15 21:46:14 +00:00
committed by GitHub
parent c2ff865700
commit ff530305d1
18 changed files with 179 additions and 106 deletions
+2 -2
View File
@@ -52,7 +52,7 @@ var d: [i32; 3] = t2;
// CHECK:STDOUT: %tuple.type.1: type = tuple_type (i32, String, String) [template]
// CHECK:STDOUT: %.8: i32 = int_value 0 [template]
// CHECK:STDOUT: %tuple.type.2: type = tuple_type (type, type, type) [template]
// CHECK:STDOUT: %.15: i32 = int_value 2 [template]
// CHECK:STDOUT: %.33: i32 = int_value 2 [template]
// CHECK:STDOUT: %tuple.type.4: type = tuple_type (i32, i32) [template]
// CHECK:STDOUT: %tuple.type.5: type = tuple_type (type, type) [template]
// CHECK:STDOUT: }
@@ -145,7 +145,7 @@ var d: [i32; 3] = t2;
// CHECK:STDOUT: %.loc28_19.7: i32 = converted %.loc28_19.6, <error> [template = <error>]
// CHECK:STDOUT: assign file.%b.var, <error>
// CHECK:STDOUT: %.loc34_20: i32 = int_value 1 [template = constants.%.4]
// CHECK:STDOUT: %.loc34_23: i32 = int_value 2 [template = constants.%.15]
// CHECK:STDOUT: %.loc34_23: i32 = int_value 2 [template = constants.%.33]
// CHECK:STDOUT: %.loc34_24: %tuple.type.4 = tuple_literal (%.loc34_20, %.loc34_23)
// CHECK:STDOUT: assign file.%c.var, <error>
// CHECK:STDOUT: %t2.ref: ref %tuple.type.4 = name_ref t2, file.%t2