Files
carbon-lang/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon
T
Jon Ross-Perkins 2d586de63c Refactor index logic to share more code. (#3152)
Trying to improve diagnostic names and code flow. I was thinking
"operand" might be a better name than "name" in the context of what `a`
is in `a[b]`, where we already call `b` the `index`.

Flow-wise, note this replaces pushing BuiltinError with instead creating
Index nodes that may contain an error. This is intended to aim towards
producing a more consistent SemIR in the face of errors. There are pros
and cons of both approaches, but I'm aiming for simpler control flow.
2023-08-25 22:31:26 +00:00

115 lines
4.3 KiB
Plaintext

// 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,) = (12,);
var b: (i32,) = a;
// CHECK:STDERR: fail_tuple_large_index.carbon:[[@LINE+3]]:35: Index `295147905179352825855` is past the end of `(i32,) as type`.
// CHECK:STDERR: var c: i32 = b[0xFFFFFFFFFFFFFFFFF];
// CHECK:STDERR: ^
var c: i32 = b[0xFFFFFFFFFFFFFFFFF];
// CHECK:STDOUT: cross_reference_irs_size: 1
// CHECK:STDOUT: functions: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: integer_literals: [
// CHECK:STDOUT: 12,
// CHECK:STDOUT: -1,
// CHECK:STDOUT: ]
// CHECK:STDOUT: real_literals: [
// CHECK:STDOUT: ]
// CHECK:STDOUT: strings: [
// CHECK:STDOUT: a,
// CHECK:STDOUT: b,
// CHECK:STDOUT: c,
// CHECK:STDOUT: ]
// CHECK:STDOUT: types: [
// CHECK:STDOUT: node+1,
// CHECK:STDOUT: nodeIntegerType,
// CHECK:STDOUT: node+3,
// 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: VarStorage, arg0: str0, type: type2},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1},
// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1},
// CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2},
// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+7},
// CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType},
// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0},
// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2},
// CHECK:STDOUT: {kind: BindValue, arg0: node+4, type: type2},
// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12},
// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1},
// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1},
// CHECK:STDOUT: {kind: TupleIndex, arg0: node+11, arg1: nodeError, type: typeError},
// CHECK:STDOUT: {kind: Assign, arg0: node+14, 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: node+13,
// CHECK:STDOUT: node+14,
// CHECK:STDOUT: node+15,
// CHECK:STDOUT: node+16,
// CHECK:STDOUT: node+17,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+0,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+6,
// CHECK:STDOUT: ],
// CHECK:STDOUT: [
// CHECK:STDOUT: node+9,
// CHECK:STDOUT: ],
// CHECK:STDOUT: ]
// CHECK:STDOUT:
// CHECK:STDOUT: package {
// CHECK:STDOUT: %.loc7_9: type = stub_reference i32
// CHECK:STDOUT: %.loc7_13.1: type = tuple_type (type)
// CHECK:STDOUT: %.loc7_13.2: (type,) = tuple_value (%.loc7_9)
// CHECK:STDOUT: %.loc7_13.3: type = tuple_type (i32)
// CHECK:STDOUT: %a: (i32,) = var "a"
// CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12
// CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1
// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2)
// CHECK:STDOUT: assign %a, %.loc7_21
// CHECK:STDOUT: %.loc8_9: type = stub_reference i32
// CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9)
// CHECK:STDOUT: %b: (i32,) = var "b"
// CHECK:STDOUT: %.loc7_5: (i32,) = bind_value %a
// CHECK:STDOUT: assign %b, %.loc7_5
// CHECK:STDOUT: %c: i32 = var "c"
// CHECK:STDOUT: %.loc12_16: i32 = int_literal -1
// CHECK:STDOUT: %.loc12_35: <error> = tuple_index %b, <error>
// CHECK:STDOUT: assign %c, <error>
// CHECK:STDOUT: }