Semantics for array type (#3087)

Co-authored-by: Farzana Ahmed Siddique <fasiddique@google.com>
This commit is contained in:
Farzana Ahmed Siddique
2023-08-11 23:06:13 +00:00
committed by GitHub
co-authored by Farzana Ahmed Siddique
parent 90cca11ea3
commit 9228487d46
16 changed files with 836 additions and 5 deletions
@@ -0,0 +1,124 @@
// 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
fn F() -> (i32,) { return (0,); }
fn Run() {
var t: [i32; 1] = F();
}
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: {block3}}},
// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block5}}},
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 0,
// CHECK:STDOUT: 1,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: F,
// CHECK:STDOUT: Run,
// CHECK:STDOUT: t,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: typeTypeType,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: type1,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType},
// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1},
// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1},
// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2},
// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7},
// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+10, arg1: type1, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type3},
// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type3},
// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2},
// CHECK:STDOUT: {kind: ArrayValue, arg0: node+14, type: type3},
// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+15},
// CHECK:STDOUT: {kind: Return},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: node+12,
// CHECK:STDOUT: node+13,
// CHECK:STDOUT: node+14,
// CHECK:STDOUT: node+15,
// CHECK:STDOUT: node+16,
// CHECK:STDOUT: node+17,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc7_12: type = stub_reference i32
// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type)
// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12)
// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32)
// CHECK:STDOUT: %.loc7_1 = fn_decl @F
// CHECK:STDOUT: %.loc9 = fn_decl @Run
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> (i32,) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0
// CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1
// CHECK:STDOUT: %.loc7_30: (i32,) = tuple_value (%.loc7_28.2)
// CHECK:STDOUT: return %.loc7_30
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc10_16: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32
// CHECK:STDOUT: %t: [i32; 1] = var
// CHECK:STDOUT: %.loc10_22.1: (i32,) = call @F()
// CHECK:STDOUT: %.loc10_22.2: [i32; 1] = array_value %.loc10_22.1
// CHECK:STDOUT: assign %t, %.loc10_22.2
// CHECK:STDOUT: return
// CHECK:STDOUT: }
+127
View File
@@ -0,0 +1,127 @@
// 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
var a: (i32, i32, i32) = (1, 2, 3);
var b: [i32; 3] = a;
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 1,
// CHECK:STDOUT: 2,
// CHECK:STDOUT: 3,
// CHECK:STDOUT: 3,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: b,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+17,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: typeTypeType,
// CHECK:STDOUT: typeTypeType,
// CHECK:STDOUT: typeTypeType,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: type1,
// CHECK:STDOUT: type1,
// CHECK:STDOUT: type1,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType},
// CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType},
// CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type2},
// CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+6, type: type2},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1},
// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1},
// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1},
// CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type1},
// CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2},
// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+14},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+16, arg1: type1, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type3},
// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+18, type: type3},
// CHECK:STDOUT: {kind: ArrayValue, arg0: node+6, type: type3},
// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+20},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: node+12,
// CHECK:STDOUT: node+13,
// CHECK:STDOUT: node+14,
// CHECK:STDOUT: node+15,
// CHECK:STDOUT: node+16,
// CHECK:STDOUT: node+17,
// CHECK:STDOUT: node+18,
// CHECK:STDOUT: node+19,
// CHECK:STDOUT: node+20,
// CHECK:STDOUT: node+21,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: node+13,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc7_9: type = stub_reference i32
// CHECK:STDOUT: %.loc7_14: type = stub_reference i32
// CHECK:STDOUT: %.loc7_19: type = stub_reference i32
// CHECK:STDOUT: %.loc7_22.1: type = tuple_type (type, type, type)
// CHECK:STDOUT: %.loc7_22.2: (type, type, type) = tuple_value (%.loc7_9, %.loc7_14, %.loc7_19)
// CHECK:STDOUT: %.loc7_22.3: type = tuple_type (i32, i32, i32)
// CHECK:STDOUT: %a: (i32, i32, i32) = var
// CHECK:STDOUT: %.loc7_27.1: i32 = int_literal 1
// CHECK:STDOUT: %.loc7_27.2: i32 = stub_reference %.loc7_27.1
// CHECK:STDOUT: %.loc7_30.1: i32 = int_literal 2
// CHECK:STDOUT: %.loc7_30.2: i32 = stub_reference %.loc7_30.1
// CHECK:STDOUT: %.loc7_33.1: i32 = int_literal 3
// CHECK:STDOUT: %.loc7_33.2: i32 = stub_reference %.loc7_33.1
// CHECK:STDOUT: %.loc7_34: (i32, i32, i32) = tuple_value (%.loc7_27.2, %.loc7_30.2, %.loc7_33.2)
// CHECK:STDOUT: assign %a, %.loc7_34
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 3
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32
// CHECK:STDOUT: %b: [i32; 3] = var
// CHECK:STDOUT: %.loc7_5: [i32; 3] = array_value %a
// CHECK:STDOUT: assign %b, %.loc7_5
// CHECK:STDOUT: }
+205
View File
@@ -0,0 +1,205 @@
// 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
var a: [i32; 1] = (1,);
var b: [f64; 2] = (11.1, 2.2,);
var c: [(); 5] = ((), (), (), (), (),);
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 1,
// CHECK:STDOUT: 1,
// CHECK:STDOUT: 2,
// CHECK:STDOUT: 5,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: {mantissa: 111, exponent: -1, is_decimal: 1},
// CHECK:STDOUT: {mantissa: 22, exponent: -1, is_decimal: 1},
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: b,
// CHECK:STDOUT: c,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: nodeFloatingPointType,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: node+18,
// CHECK:STDOUT: node+22,
// CHECK:STDOUT: node+25,
// CHECK:STDOUT: node+38,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: type0,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: type3,
// CHECK:STDOUT: type3,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: type6,
// CHECK:STDOUT: type6,
// CHECK:STDOUT: type6,
// CHECK:STDOUT: type6,
// CHECK:STDOUT: type6,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+0, arg1: type0, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type1},
// CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0},
// CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2},
// CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1},
// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+10, arg1: type3, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type4},
// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type4},
// CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3},
// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type3},
// CHECK:STDOUT: {kind: RealLiteral, arg0: real1, type: type3},
// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type3},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type5},
// CHECK:STDOUT: {kind: ArrayValue, arg0: node+19, type: type4},
// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+20},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+24, arg1: type6, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type7},
// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+26, type: type7},
// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6},
// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type6},
// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6},
// CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type6},
// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6},
// CHECK:STDOUT: {kind: StubReference, arg0: node+32, type: type6},
// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6},
// CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type6},
// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6},
// CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type6},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock3, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type8},
// CHECK:STDOUT: {kind: ArrayValue, arg0: node+39, type: type7},
// CHECK:STDOUT: {kind: Assign, arg0: node+26, arg1: node+40},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: node+12,
// CHECK:STDOUT: node+13,
// CHECK:STDOUT: node+14,
// CHECK:STDOUT: node+15,
// CHECK:STDOUT: node+16,
// CHECK:STDOUT: node+17,
// CHECK:STDOUT: node+18,
// CHECK:STDOUT: node+19,
// CHECK:STDOUT: node+20,
// CHECK:STDOUT: node+21,
// CHECK:STDOUT: node+22,
// CHECK:STDOUT: node+23,
// CHECK:STDOUT: node+24,
// CHECK:STDOUT: node+25,
// CHECK:STDOUT: node+26,
// CHECK:STDOUT: node+27,
// CHECK:STDOUT: node+28,
// CHECK:STDOUT: node+29,
// CHECK:STDOUT: node+30,
// CHECK:STDOUT: node+31,
// CHECK:STDOUT: node+32,
// CHECK:STDOUT: node+33,
// CHECK:STDOUT: node+34,
// CHECK:STDOUT: node+35,
// CHECK:STDOUT: node+36,
// CHECK:STDOUT: node+37,
// CHECK:STDOUT: node+38,
// CHECK:STDOUT: node+39,
// CHECK:STDOUT: node+40,
// CHECK:STDOUT: node+41,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+15,
// CHECK:STDOUT: node+17,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+29,
// CHECK:STDOUT: node+31,
// CHECK:STDOUT: node+33,
// CHECK:STDOUT: node+35,
// CHECK:STDOUT: node+37,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc7_14: i32 = int_literal 1
// CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32
// CHECK:STDOUT: %a: [i32; 1] = var
// CHECK:STDOUT: %.loc7_20.1: i32 = int_literal 1
// CHECK:STDOUT: %.loc7_20.2: i32 = stub_reference %.loc7_20.1
// CHECK:STDOUT: %.loc7_22.1: type = tuple_type (i32)
// CHECK:STDOUT: %.loc7_22.2: (i32,) = tuple_value (%.loc7_20.2)
// CHECK:STDOUT: %.loc7_22.3: [i32; 1] = array_value %.loc7_22.2
// CHECK:STDOUT: assign %a, %.loc7_22.3
// CHECK:STDOUT: %.loc8_14: i32 = int_literal 2
// CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64
// CHECK:STDOUT: %b: [f64; 2] = var
// CHECK:STDOUT: %.loc8_20.1: f64 = real_literal 111e-1
// CHECK:STDOUT: %.loc8_20.2: f64 = stub_reference %.loc8_20.1
// CHECK:STDOUT: %.loc8_26.1: f64 = real_literal 22e-1
// CHECK:STDOUT: %.loc8_26.2: f64 = stub_reference %.loc8_26.1
// CHECK:STDOUT: %.loc8_30.1: type = tuple_type (f64, f64)
// CHECK:STDOUT: %.loc8_30.2: (f64, f64) = tuple_value (%.loc8_20.2, %.loc8_26.2)
// CHECK:STDOUT: %.loc8_30.3: [f64; 2] = array_value %.loc8_30.2
// CHECK:STDOUT: assign %b, %.loc8_30.3
// CHECK:STDOUT: %.loc9_10.1: type = tuple_type ()
// CHECK:STDOUT: %.loc9_10.2: () = tuple_value ()
// CHECK:STDOUT: %.loc9_13: i32 = int_literal 5
// CHECK:STDOUT: %.loc9_14: type = array_type %.loc9_13, ()
// CHECK:STDOUT: %c: [(); 5] = var
// CHECK:STDOUT: %.loc9_20.1: () = tuple_value ()
// CHECK:STDOUT: %.loc9_20.2: () = stub_reference %.loc9_20.1
// CHECK:STDOUT: %.loc9_24.1: () = tuple_value ()
// CHECK:STDOUT: %.loc9_24.2: () = stub_reference %.loc9_24.1
// CHECK:STDOUT: %.loc9_28.1: () = tuple_value ()
// CHECK:STDOUT: %.loc9_28.2: () = stub_reference %.loc9_28.1
// CHECK:STDOUT: %.loc9_32.1: () = tuple_value ()
// CHECK:STDOUT: %.loc9_32.2: () = stub_reference %.loc9_32.1
// CHECK:STDOUT: %.loc9_36.1: () = tuple_value ()
// CHECK:STDOUT: %.loc9_36.2: () = stub_reference %.loc9_36.1
// CHECK:STDOUT: %.loc9_38.1: type = tuple_type ((), (), (), (), ())
// CHECK:STDOUT: %.loc9_38.2: ((), (), (), (), ()) = tuple_value (%.loc9_20.2, %.loc9_24.2, %.loc9_28.2, %.loc9_32.2, %.loc9_36.2)
// CHECK:STDOUT: %.loc9_38.3: [(); 5] = array_value %.loc9_38.2
// CHECK:STDOUT: assign %c, %.loc9_38.3
// CHECK:STDOUT: }
@@ -0,0 +1,54 @@
// 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
// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+3]]:13: Cannot implicitly convert from `i32` to `type`.
// CHECK:STDERR: var a: [1; 1];
// CHECK:STDERR: ^
var a: [1; 1];
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 1,
// CHECK:STDOUT: 1,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+1, arg1: typeError, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type1},
// CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+3, type: type1},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc10_9: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_12: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_13: type = array_type %.loc10_12, <error>
// CHECK:STDOUT: %a: [<error>; 1] = var
// CHECK:STDOUT: }
@@ -0,0 +1,91 @@
// 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
// CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+3]]:28: Cannot implicitly convert from `(i32, i32, i32) as type` to `[i32; 1]`.
// CHECK:STDERR: var a: [i32; 1] = (1, 2, 3);
// CHECK:STDERR: ^
var a: [i32; 1] = (1, 2, 3);
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 1,
// CHECK:STDOUT: 1,
// CHECK:STDOUT: 2,
// CHECK:STDOUT: 3,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: type0,
// CHECK:STDOUT: type0,
// CHECK:STDOUT: type0,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+0, arg1: type0, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type1},
// CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0},
// CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0},
// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type0},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0},
// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2},
// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: node+11,
// CHECK:STDOUT: node+12,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc10_14: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, i32
// CHECK:STDOUT: %a: [i32; 1] = var
// CHECK:STDOUT: %.loc10_20.1: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_20.2: i32 = stub_reference %.loc10_20.1
// CHECK:STDOUT: %.loc10_23.1: i32 = int_literal 2
// CHECK:STDOUT: %.loc10_23.2: i32 = stub_reference %.loc10_23.1
// CHECK:STDOUT: %.loc10_26.1: i32 = int_literal 3
// CHECK:STDOUT: %.loc10_26.2: i32 = stub_reference %.loc10_26.1
// CHECK:STDOUT: %.loc10_27.1: type = tuple_type (i32, i32, i32)
// CHECK:STDOUT: %.loc10_27.2: (i32, i32, i32) = tuple_value (%.loc10_20.2, %.loc10_23.2, %.loc10_26.2)
// CHECK:STDOUT: assign %a, <error>
// CHECK:STDOUT: }
@@ -0,0 +1,83 @@
// 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
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:27: Cannot implicitly convert from `(i32, f64) as type` to `[i32; 2]`.
// CHECK:STDERR: var a: [i32; 2] = (1, 2.5);
// CHECK:STDERR: ^
var a: [i32; 2] = (1, 2.5);
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 2,
// CHECK:STDOUT: 1,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: {mantissa: 25, exponent: -1, is_decimal: 1},
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: nodeFloatingPointType,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: type0,
// CHECK:STDOUT: type2,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0},
// CHECK:STDOUT: {kind: ArrayType, arg0: node+0, arg1: type0, type: typeTypeType},
// CHECK:STDOUT: {kind: VarStorage, type: type1},
// CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0},
// CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0},
// CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type2},
// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type2},
// CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type3},
// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError},
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: node+2,
// CHECK:STDOUT: node+3,
// CHECK:STDOUT: node+4,
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: node+8,
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: node+10,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+5,
// CHECK:STDOUT: node+7,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc10_14: i32 = int_literal 2
// CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, i32
// CHECK:STDOUT: %a: [i32; 2] = var
// CHECK:STDOUT: %.loc10_20.1: i32 = int_literal 1
// CHECK:STDOUT: %.loc10_20.2: i32 = stub_reference %.loc10_20.1
// CHECK:STDOUT: %.loc10_23.1: f64 = real_literal 25e-1
// CHECK:STDOUT: %.loc10_23.2: f64 = stub_reference %.loc10_23.1
// CHECK:STDOUT: %.loc10_26.1: type = tuple_type (i32, f64)
// CHECK:STDOUT: %.loc10_26.2: (i32, f64) = tuple_value (%.loc10_20.2, %.loc10_23.2)
// CHECK:STDOUT: assign %a, <error>
// CHECK:STDOUT: }
@@ -0,0 +1,34 @@
// 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
// CHECK:STDERR: fail_undefined_bound.carbon:[[@LINE+3]]:14: Semantics TODO: HandleArrayExpressionWithoutBounds
// CHECK:STDERR: var a: [i32; ];
// CHECK:STDERR: ^
var a: [i32; ];
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: type_blocks: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: nodes: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: node_blocks: [
// CHECK:STDOUT: [
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: }