mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Convert array bounds to IntLiteral. (#4526)
Instead of leaving array bounds as whatever integer type they arrive as, convert them to the `IntLiteral` type as part of forming an `ArrayType`. This ensures that array types canonicalize properly even when the bounds are specified with different types. Create an empty generic definition for a generic builtin function to avoid this causing "use of undefined generic function" errors.
This commit is contained in:
+22
-10
@@ -22,12 +22,19 @@ fn G(T:! type) {
|
||||
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %G: %G.type = struct_value () [template]
|
||||
// CHECK:STDOUT: %.1: i32 = int_value 0 [template]
|
||||
// CHECK:STDOUT: %.2: type = array_type %.1, %T [symbolic]
|
||||
// CHECK:STDOUT: %array: %.2 = tuple_value () [symbolic]
|
||||
// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
|
||||
// CHECK:STDOUT: %Convert.type.15: type = fn_type @Convert.11 [template]
|
||||
// CHECK:STDOUT: %Convert.15: %Convert.type.15 = struct_value () [template]
|
||||
// CHECK:STDOUT: %.25: <witness> = interface_witness (%Convert.15) [template]
|
||||
// CHECK:STDOUT: %.26: <bound method> = bound_method %.1, %Convert.15 [template]
|
||||
// CHECK:STDOUT: %.27: Core.IntLiteral = int_value 0 [template]
|
||||
// CHECK:STDOUT: %.28: type = array_type %.27, %T [symbolic]
|
||||
// CHECK:STDOUT: %array: %.28 = tuple_value () [symbolic]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .ImplicitAs = %import_ref.1
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
@@ -53,19 +60,24 @@ fn G(T:! type) {
|
||||
// CHECK:STDOUT: %T.patt.loc11_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !definition:
|
||||
// CHECK:STDOUT: %.loc13_17.2: type = array_type constants.%.1, @G.%T.loc11_6.2 (%T) [symbolic = %.loc13_17.2 (constants.%.2)]
|
||||
// CHECK:STDOUT: %array: @G.%.loc13_17.2 (%.2) = tuple_value () [symbolic = %array (constants.%array)]
|
||||
// CHECK:STDOUT: %.loc13_17.2: type = array_type constants.%.27, @G.%T.loc11_6.2 (%T) [symbolic = %.loc13_17.2 (constants.%.28)]
|
||||
// CHECK:STDOUT: %array: @G.%.loc13_17.2 (%.28) = tuple_value () [symbolic = %array (constants.%array)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn(%T.param_patt: type) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)]
|
||||
// CHECK:STDOUT: %.loc13_16: i32 = int_value 0 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc13_17.1: type = array_type %.loc13_16, %T [symbolic = %.loc13_17.2 (constants.%.2)]
|
||||
// CHECK:STDOUT: %arr.var: ref @G.%.loc13_17.2 (%.2) = var arr
|
||||
// CHECK:STDOUT: %arr: ref @G.%.loc13_17.2 (%.2) = bind_name arr, %arr.var
|
||||
// CHECK:STDOUT: %.loc13_16.1: i32 = int_value 0 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc13_16.2: %Convert.type.2 = interface_witness_access constants.%.25, element0 [template = constants.%Convert.15]
|
||||
// CHECK:STDOUT: %.loc13_16.3: <bound method> = bound_method %.loc13_16.1, %.loc13_16.2 [template = constants.%.26]
|
||||
// CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %.loc13_16.3(%.loc13_16.1) [template = constants.%.27]
|
||||
// CHECK:STDOUT: %.loc13_16.4: Core.IntLiteral = value_of_initializer %int.convert_checked [template = constants.%.27]
|
||||
// CHECK:STDOUT: %.loc13_16.5: Core.IntLiteral = converted %.loc13_16.1, %.loc13_16.4 [template = constants.%.27]
|
||||
// CHECK:STDOUT: %.loc13_17.1: type = array_type %.loc13_16.5, %T [symbolic = %.loc13_17.2 (constants.%.28)]
|
||||
// CHECK:STDOUT: %arr.var: ref @G.%.loc13_17.2 (%.28) = var arr
|
||||
// CHECK:STDOUT: %arr: ref @G.%.loc13_17.2 (%.28) = bind_name arr, %arr.var
|
||||
// CHECK:STDOUT: %.loc13_22.1: %empty_tuple.type = tuple_literal ()
|
||||
// CHECK:STDOUT: %.loc13_22.2: init @G.%.loc13_17.2 (%.2) = array_init () to %arr.var [symbolic = %array (constants.%array)]
|
||||
// CHECK:STDOUT: %.loc13_23: init @G.%.loc13_17.2 (%.2) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)]
|
||||
// CHECK:STDOUT: %.loc13_22.2: init @G.%.loc13_17.2 (%.28) = array_init () to %arr.var [symbolic = %array (constants.%array)]
|
||||
// CHECK:STDOUT: %.loc13_23: init @G.%.loc13_17.2 (%.28) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)]
|
||||
// CHECK:STDOUT: assign %arr.var, %.loc13_23
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
Reference in New Issue
Block a user