mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:34:45 +01:00
Change array syntax from [T; N] to array(T, N) (#4981)
In line with the proposal in #4682, this changes the array syntax to be array(T, N). `array` is a builtin keyword which must be followed by parens containing two expressions and a separating comma. The array type expression is still fully builtin, it does not forward to a Core.Array library type yet. It merely adds the `ArrayType` instruction, as was done with the previous syntax. Followup work will change the instruction to reference to Core.Array, once the library type exists and can be used directly. --------- Co-authored-by: zygoloid <richard@metafoo.co.uk>
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/fail_param_in_type.carbon
|
||||
|
||||
// CHECK:STDERR: fail_param_in_type.carbon:[[@LINE+4]]:23: error: array bound is not a constant [InvalidArrayExpr]
|
||||
// CHECK:STDERR: fn F(n: i32, a: [i32; n]*);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_in_type.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr]
|
||||
// CHECK:STDERR: fn F(n: i32, a: array(i32, n)*);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
fn F(n: i32, a: [i32; n]*);
|
||||
fn F(n: i32, a: array(i32, n)*);
|
||||
|
||||
// CHECK:STDOUT: --- fail_param_in_type.carbon
|
||||
// CHECK:STDOUT:
|
||||
@@ -50,9 +50,9 @@ fn F(n: i32, a: [i32; n]*);
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
|
||||
// CHECK:STDOUT: %a.param: <error> = value_param runtime_param1
|
||||
// CHECK:STDOUT: %.loc15_25: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %int_32.loc15_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc15_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc15_30: type = splice_block %ptr [concrete = <error>] {
|
||||
// CHECK:STDOUT: %int_32.loc15_23: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc15_23: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
|
||||
// CHECK:STDOUT: %ptr: type = ptr_type <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
Reference in New Issue
Block a user