mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:31:04 +01:00
Support array types with dependent bounds. (#4751)
Given `N:! i32`, the type `[T; N]` is a valid but dependent array type.
This commit is contained in:
@@ -1,96 +0,0 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon
|
||||
|
||||
// CHECK:STDERR: fail_todo_param_in_type.carbon:[[@LINE+3]]:24: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn F(N:! i32, a: [i32; N]*);
|
||||
// CHECK:STDERR: ^
|
||||
fn F(N:! i32, a: [i32; N]*);
|
||||
|
||||
// CHECK:STDOUT: --- fail_todo_param_in_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
|
||||
// CHECK:STDOUT: %N.3e4: %i32 = bind_symbolic_name N, 0 [symbolic]
|
||||
// CHECK:STDOUT: %N.patt.52a: %i32 = symbolic_binding_pattern N, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Convert.type.a9b: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
|
||||
// CHECK:STDOUT: %impl_witness.dd3: <witness> = impl_witness (imports.%import_ref.a80), @impl.2(%int_32) [template]
|
||||
// CHECK:STDOUT: %Convert.type.d18: type = fn_type @Convert.3, @impl.2(%int_32) [template]
|
||||
// CHECK:STDOUT: %Convert.079: %Convert.type.d18 = struct_value () [template]
|
||||
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.3e4, %Convert.079 [symbolic]
|
||||
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.3(%int_32) [symbolic]
|
||||
// CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.3e4) [symbolic]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.187
|
||||
// CHECK:STDOUT: .ImplicitAs = %import_ref.a69
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
|
||||
// CHECK:STDOUT: %N.patt.loc14_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc14_6.2 (constants.%N.patt.52a)]
|
||||
// CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc14_6.1, runtime_param<invalid> [symbolic = %N.patt.loc14_6.2 (constants.%N.patt.52a)]
|
||||
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a
|
||||
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
|
||||
// CHECK:STDOUT: %.loc14_10: type = splice_block %i32.loc14_10 [template = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc14_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc14_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %N.loc14_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc14_6.2 (constants.%N.3e4)]
|
||||
// CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
|
||||
// CHECK:STDOUT: %.loc14_26: type = splice_block %ptr [template = <error>] {
|
||||
// CHECK:STDOUT: %int_32.loc14_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc14_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc14_6.1 [symbolic = %N.loc14_6.2 (constants.%N.3e4)]
|
||||
// CHECK:STDOUT: %impl.elem0: %Convert.type.a9b = impl_witness_access constants.%impl_witness.dd3, element0 [template = constants.%Convert.079]
|
||||
// CHECK:STDOUT: %Convert.bound.loc14_24.1: <bound method> = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound.loc14_24.2 (constants.%Convert.bound)]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc14_24.1: <specific function> = specific_function %Convert.bound.loc14_24.1, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc14_24.2 (constants.%Convert.specific_fn)]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_24.1: init Core.IntLiteral = call %Convert.specific_fn.loc14_24.1(%N.ref) [symbolic = %int.convert_checked.loc14_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %.loc14_24.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc14_24.1 [symbolic = %int.convert_checked.loc14_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %.loc14_24.2: Core.IntLiteral = converted %N.ref, %.loc14_24.1 [symbolic = %int.convert_checked.loc14_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %array_type: type = array_type %.loc14_24.2, %i32 [template = <error>]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [template = <error>]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %a: <error> = bind_name a, %a.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic fn @F(%N.loc14_6.1: %i32) {
|
||||
// CHECK:STDOUT: %N.loc14_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc14_6.2 (constants.%N.3e4)]
|
||||
// CHECK:STDOUT: %N.patt.loc14_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc14_6.2 (constants.%N.patt.52a)]
|
||||
// CHECK:STDOUT: %Convert.bound.loc14_24.2: <bound method> = bound_method %N.loc14_6.2, constants.%Convert.079 [symbolic = %Convert.bound.loc14_24.2 (constants.%Convert.bound)]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc14_24.2: <specific function> = specific_function %Convert.bound.loc14_24.2, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc14_24.2 (constants.%Convert.specific_fn)]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_24.2: init Core.IntLiteral = call %Convert.specific_fn.loc14_24.2(%N.loc14_6.2) [symbolic = %int.convert_checked.loc14_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn(%N.param_patt: %i32, %a.param_patt: <error>);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @F(constants.%N.3e4) {
|
||||
// CHECK:STDOUT: %N.loc14_6.2 => constants.%N.3e4
|
||||
// CHECK:STDOUT: %N.patt.loc14_6.2 => constants.%N.3e4
|
||||
// CHECK:STDOUT: %Convert.bound.loc14_24.2 => constants.%Convert.bound
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc14_24.2 => constants.%Convert.specific_fn
|
||||
// CHECK:STDOUT: %int.convert_checked.loc14_24.2 => constants.%int.convert_checked
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -0,0 +1,99 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/generic/param_in_type.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/param_in_type.carbon
|
||||
|
||||
fn F(N:! i32, a: [i32; N]*);
|
||||
|
||||
// CHECK:STDOUT: --- param_in_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
|
||||
// CHECK:STDOUT: %N.3e4: %i32 = bind_symbolic_name N, 0 [symbolic]
|
||||
// CHECK:STDOUT: %N.patt.52a: %i32 = symbolic_binding_pattern N, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Convert.type.a9b: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
|
||||
// CHECK:STDOUT: %impl_witness.dd3: <witness> = impl_witness (imports.%import_ref.a80), @impl.2(%int_32) [template]
|
||||
// CHECK:STDOUT: %Convert.type.d18: type = fn_type @Convert.3, @impl.2(%int_32) [template]
|
||||
// CHECK:STDOUT: %Convert.079: %Convert.type.d18 = struct_value () [template]
|
||||
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.3e4, %Convert.079 [symbolic]
|
||||
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.3(%int_32) [symbolic]
|
||||
// CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.3e4) [symbolic]
|
||||
// CHECK:STDOUT: %array_type: type = array_type %int.convert_checked, %i32 [symbolic]
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type %array_type [symbolic]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.187
|
||||
// CHECK:STDOUT: .ImplicitAs = %import_ref.a69
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
|
||||
// CHECK:STDOUT: %N.patt.loc11_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc11_6.2 (constants.%N.patt.52a)]
|
||||
// CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc11_6.1, runtime_param<invalid> [symbolic = %N.patt.loc11_6.2 (constants.%N.patt.52a)]
|
||||
// CHECK:STDOUT: %a.patt: @F.%ptr.loc11_26.2 (%ptr) = binding_pattern a
|
||||
// CHECK:STDOUT: %a.param_patt: @F.%ptr.loc11_26.2 (%ptr) = value_param_pattern %a.patt, runtime_param0
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
|
||||
// CHECK:STDOUT: %.loc11_10: type = splice_block %i32.loc11_10 [template = constants.%i32] {
|
||||
// CHECK:STDOUT: %int_32.loc11_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc11_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %N.loc11_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc11_6.2 (constants.%N.3e4)]
|
||||
// CHECK:STDOUT: %a.param: @F.%ptr.loc11_26.2 (%ptr) = value_param runtime_param0
|
||||
// CHECK:STDOUT: %.loc11_26: type = splice_block %ptr.loc11_26.1 [symbolic = %ptr.loc11_26.2 (constants.%ptr)] {
|
||||
// CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc11_6.1 [symbolic = %N.loc11_6.2 (constants.%N.3e4)]
|
||||
// CHECK:STDOUT: %impl.elem0: %Convert.type.a9b = impl_witness_access constants.%impl_witness.dd3, element0 [template = constants.%Convert.079]
|
||||
// CHECK:STDOUT: %Convert.bound.loc11_24.1: <bound method> = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound.loc11_24.2 (constants.%Convert.bound)]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc11_24.1: <specific function> = specific_function %Convert.bound.loc11_24.1, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc11_24.2 (constants.%Convert.specific_fn)]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc11_24.1: init Core.IntLiteral = call %Convert.specific_fn.loc11_24.1(%N.ref) [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %.loc11_24.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc11_24.1 [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %.loc11_24.2: Core.IntLiteral = converted %N.ref, %.loc11_24.1 [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %array_type.loc11_25.1: type = array_type %.loc11_24.2, %i32 [symbolic = %array_type.loc11_25.2 (constants.%array_type)]
|
||||
// CHECK:STDOUT: %ptr.loc11_26.1: type = ptr_type %array_type [symbolic = %ptr.loc11_26.2 (constants.%ptr)]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %a: @F.%ptr.loc11_26.2 (%ptr) = bind_name a, %a.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: generic fn @F(%N.loc11_6.1: %i32) {
|
||||
// CHECK:STDOUT: %N.loc11_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc11_6.2 (constants.%N.3e4)]
|
||||
// CHECK:STDOUT: %N.patt.loc11_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc11_6.2 (constants.%N.patt.52a)]
|
||||
// CHECK:STDOUT: %Convert.bound.loc11_24.2: <bound method> = bound_method %N.loc11_6.2, constants.%Convert.079 [symbolic = %Convert.bound.loc11_24.2 (constants.%Convert.bound)]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc11_24.2: <specific function> = specific_function %Convert.bound.loc11_24.2, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc11_24.2 (constants.%Convert.specific_fn)]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc11_24.2: init Core.IntLiteral = call %Convert.specific_fn.loc11_24.2(%N.loc11_6.2) [symbolic = %int.convert_checked.loc11_24.2 (constants.%int.convert_checked)]
|
||||
// CHECK:STDOUT: %array_type.loc11_25.2: type = array_type %int.convert_checked.loc11_24.2, %i32 [symbolic = %array_type.loc11_25.2 (constants.%array_type)]
|
||||
// CHECK:STDOUT: %ptr.loc11_26.2: type = ptr_type @F.%array_type.loc11_25.2 (%array_type) [symbolic = %ptr.loc11_26.2 (constants.%ptr)]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn(%N.param_patt: %i32, %a.param_patt: @F.%ptr.loc11_26.2 (%ptr));
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: specific @F(constants.%N.3e4) {
|
||||
// CHECK:STDOUT: %N.loc11_6.2 => constants.%N.3e4
|
||||
// CHECK:STDOUT: %N.patt.loc11_6.2 => constants.%N.3e4
|
||||
// CHECK:STDOUT: %Convert.bound.loc11_24.2 => constants.%Convert.bound
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc11_24.2 => constants.%Convert.specific_fn
|
||||
// CHECK:STDOUT: %int.convert_checked.loc11_24.2 => constants.%int.convert_checked
|
||||
// CHECK:STDOUT: %array_type.loc11_25.2 => constants.%array_type
|
||||
// CHECK:STDOUT: %ptr.loc11_26.2 => constants.%ptr
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
Reference in New Issue
Block a user