Skip to content

Commit

Permalink
Split evaluation up into one function per instruction kind (#5008)
Browse files Browse the repository at this point in the history
Replace the large and growing `TryEvalInstInContext` function with one
function per kind. While we still have special-case handling for a small
number of instruction kinds, most instructions are now handled either
fully automatically or use a common codepath that evaluates the
instruction operands and then performs an eval-context-independent
evaluation of the instruction.

To support this, `InstConstantKind` is expanded to describe more
fine-grained details about how each kind of instruction interacts with
constant evaluation. Also, the operand kinds of instructions become
slightly more fine-grained: we now distinguish between operands that
describe the destination of an initializing expression (`DestInstId`)
from other `InstId` operands, because `DestInstId` operands need
different treatment during constant evaluation. In particular, an
initializing expression can have a constant value even if its
destination is non-constant or has not yet been set, because evaluation
of an initializing expression doesn't include the store to the
destination.

Some minor test changes:

- We now more consistently propagate errors into the results of constant
evaluation, so more instructions that depend on errors have a constant
value of `<error>`.
- Diagnostic location for invalid array types now point at the whole
array type rather than the array index expression, because
`EvalConstantinst` doesn't have access to the original expression.
- Diagnostic for failed `RequireCompleteType` doesn't print the original
type any more because `EvalConstantInst` doesn't have access to the
original expression.

As a follow-up, some of this -- in particular, the `EvalConstantInst`
overloads -- will be moved to a separate file, in an effort to split the
overall constant evaluation machinery apart from the logic to evaluate
each individual kind of instruction.
  • Loading branch information
zygoloid authored Feb 27, 2025
1 parent 90b6f5a commit 0d2f364
Show file tree
Hide file tree
Showing 50 changed files with 1,036 additions and 915 deletions.
1,449 changes: 739 additions & 710 deletions toolchain/check/eval.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions toolchain/check/testdata/array/fail_bound_negative.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

fn Negate(n: i32) -> i32 = "int.snegate";

// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+4]]:19: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+4]]:8: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: var a: array(i32, Negate(1));
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(i32, Negate(1));

Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/testdata/array/fail_bound_overflow.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_bound_overflow.carbon

// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:19: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge]
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:8: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge]
// CHECK:STDERR: var a: array(i32, 39999999999999999993);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(i32, 39999999999999999993);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var p: Incomplete* = &a[0];
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a.ref: <error> = name_ref a, file.%a
// CHECK:STDOUT: %a.ref: <error> = name_ref a, file.%a [concrete = <error>]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %addr: <error> = addr_of <error> [concrete = <error>]
// CHECK:STDOUT: assign file.%p.var, <error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var b: i32 = a[{.index = 3}.index];
// CHECK:STDOUT: %.loc16_28.2: %i32 = value_of_initializer %int.convert_checked.loc16 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_28.3: %i32 = converted %.loc16_28.1, %.loc16_28.2 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_34.1: ref %i32 = array_index %a.ref, %.loc16_28.3 [concrete = <error>]
// CHECK:STDOUT: %.loc16_34.2: %i32 = bind_value %.loc16_34.1
// CHECK:STDOUT: %.loc16_34.2: %i32 = bind_value %.loc16_34.1 [concrete = <error>]
// CHECK:STDOUT: assign file.%b.var, %.loc16_34.2
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ fn HandleAnimal[T:! Animal & Eats](a: T) { Feed(a); }
// CHECK:STDOUT: }
// CHECK:STDOUT: %HandleAnimal.decl: %HandleAnimal.type = fn_decl @HandleAnimal [concrete = constants.%HandleAnimal] {
// CHECK:STDOUT: %T.patt.loc15_17.1: <error> = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc15_17.2 (constants.%T.patt.e01)]
// CHECK:STDOUT: %T.param_patt: <error> = value_param_pattern %T.patt.loc15_17.1, runtime_param<none> [symbolic = %T.patt.loc15_17.2 (constants.%T.patt.e01)]
// CHECK:STDOUT: %T.param_patt: <error> = value_param_pattern %T.patt.loc15_17.1, runtime_param<none> [concrete = <error>]
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.param: <error> = value_param runtime_param<none>
// CHECK:STDOUT: %.1: <error> = splice_block <error> [concrete = <error>] {
Expand Down Expand Up @@ -238,7 +238,7 @@ fn HandleAnimal[T:! Animal & Eats](a: T) { Feed(a); }
// CHECK:STDOUT: fn[%T.param_patt: <error>](%a.param_patt: <error>) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Feed.ref: %Feed.type = name_ref Feed, file.%Feed.decl [concrete = constants.%Feed]
// CHECK:STDOUT: %a.ref: <error> = name_ref a, %a
// CHECK:STDOUT: %a.ref: <error> = name_ref a, %a [concrete = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ fn G() {
// CHECK:STDOUT: %x.patt: @F.%HoldsType.loc21_31.2 (%HoldsType.f95cf2.1) = binding_pattern x
// CHECK:STDOUT: %x.param_patt: @F.%HoldsType.loc21_31.2 (%HoldsType.f95cf2.1) = value_param_pattern %x.patt, runtime_param0
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param1
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param1 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.param: %Class = value_param runtime_param<none>
// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
Expand Down Expand Up @@ -723,7 +723,7 @@ fn G() {
// CHECK:STDOUT: %x.patt: @F.%HoldsType.loc12_40.2 (%HoldsType) = binding_pattern x
// CHECK:STDOUT: %x.param_patt: @F.%HoldsType.loc12_40.2 (%HoldsType) = value_param_pattern %x.patt, runtime_param0
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param1
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param1 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.param: %array_type = value_param runtime_param<none>
// CHECK:STDOUT: %.loc12_23: type = splice_block %array_type [concrete = constants.%array_type] {
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/testdata/choice/fail_invalid.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ fn F() {
// CHECK:STDOUT: %.loc11_23.1: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: %Never.ref: type = name_ref Never, file.%Never.decl [concrete = constants.%Never]
// CHECK:STDOUT: %.loc11_23.2: ref %Never = temporary_storage
// CHECK:STDOUT: %.loc11_23.3: ref %Never = temporary %.loc11_23.2, <error>
// CHECK:STDOUT: %.loc11_23.4: ref %Never = converted %.loc11_23.1, %.loc11_23.3
// CHECK:STDOUT: %.loc11_23.3: ref %Never = temporary %.loc11_23.2, <error> [concrete = <error>]
// CHECK:STDOUT: %.loc11_23.4: ref %Never = converted %.loc11_23.1, %.loc11_23.3 [concrete = <error>]
// CHECK:STDOUT: %never: ref %Never = bind_name never, %.loc11_23.4
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/testdata/class/fail_generic_method.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ fn Class(N:! i32).F[self: Self](n: T) {}
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [concrete = constants.%.d85] {
// CHECK:STDOUT: %self.patt: <error> = binding_pattern self
// CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern %self.patt, runtime_param0
// CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern %self.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: %n.patt: <error> = binding_pattern n
// CHECK:STDOUT: %n.param_patt: <error> = value_param_pattern %n.patt, runtime_param1
// CHECK:STDOUT: %n.param_patt: <error> = value_param_pattern %n.patt, runtime_param1 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<none>
// CHECK:STDOUT: %.loc33: type = splice_block %i32 [concrete = constants.%i32] {
Expand Down
12 changes: 6 additions & 6 deletions toolchain/check/testdata/class/fail_init.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ fn F() {
// CHECK:STDOUT: %.loc21_10.1: %struct_type.a = struct_literal (%int_1.loc21)
// CHECK:STDOUT: %Class.ref.loc21: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
// CHECK:STDOUT: %.loc21_10.2: ref %Class = temporary_storage
// CHECK:STDOUT: %.loc21_10.3: ref %Class = temporary %.loc21_10.2, <error>
// CHECK:STDOUT: %.loc21_12: ref %Class = converted %.loc21_10.1, %.loc21_10.3
// CHECK:STDOUT: %.loc21_10.3: ref %Class = temporary %.loc21_10.2, <error> [concrete = <error>]
// CHECK:STDOUT: %.loc21_12: ref %Class = converted %.loc21_10.1, %.loc21_10.3 [concrete = <error>]
// CHECK:STDOUT: %int_1.loc26: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc26: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc26_18.1: %struct_type.a.c = struct_literal (%int_1.loc26, %int_2.loc26)
Expand All @@ -120,16 +120,16 @@ fn F() {
// CHECK:STDOUT: %.loc26_18.3: ref %Class = temporary_storage
// CHECK:STDOUT: %.loc26_18.4: ref %i32 = class_element_access %.loc26_18.3, element0
// CHECK:STDOUT: %.loc26_18.5: init %i32 = initialize_from %.loc26_18.2 to %.loc26_18.4 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc26_18.6: ref %Class = temporary %.loc26_18.3, <error>
// CHECK:STDOUT: %.loc26_20: ref %Class = converted %.loc26_18.1, %.loc26_18.6
// CHECK:STDOUT: %.loc26_18.6: ref %Class = temporary %.loc26_18.3, <error> [concrete = <error>]
// CHECK:STDOUT: %.loc26_20: ref %Class = converted %.loc26_18.1, %.loc26_18.6 [concrete = <error>]
// CHECK:STDOUT: %int_1.loc31: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc31: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc31_26.1: %struct_type.a.b.c = struct_literal (%int_1.loc31, %int_2.loc31, %int_3)
// CHECK:STDOUT: %Class.ref.loc31: type = name_ref Class, file.%Class.decl [concrete = constants.%Class]
// CHECK:STDOUT: %.loc31_26.2: ref %Class = temporary_storage
// CHECK:STDOUT: %.loc31_26.3: ref %Class = temporary %.loc31_26.2, <error>
// CHECK:STDOUT: %.loc31_28: ref %Class = converted %.loc31_26.1, %.loc31_26.3
// CHECK:STDOUT: %.loc31_26.3: ref %Class = temporary %.loc31_26.2, <error> [concrete = <error>]
// CHECK:STDOUT: %.loc31_28: ref %Class = converted %.loc31_26.1, %.loc31_26.3 [concrete = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
2 changes: 1 addition & 1 deletion toolchain/check/testdata/class/fail_self_param.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var v: C(0);
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] {
// CHECK:STDOUT: %x.patt.loc15_22.1: <error> = symbolic_binding_pattern x, 0 [symbolic = %x.patt.loc15_22.2 (constants.%x.patt)]
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt.loc15_22.1, runtime_param<none> [symbolic = %x.patt.loc15_22.2 (constants.%x.patt)]
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt.loc15_22.1, runtime_param<none> [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %x.param: <error> = value_param runtime_param<none>
// CHECK:STDOUT: %self.ref: <error> = name_ref self, <error> [concrete = <error>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ private class Redecl {}
// CHECK:STDOUT: %default.import = import <none>
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %c.patt: <error> = binding_pattern c
// CHECK:STDOUT: %c.param_patt: <error> = value_param_pattern %c.patt, runtime_param0
// CHECK:STDOUT: %c.param_patt: <error> = value_param_pattern %c.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %c.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %.loc10: type = splice_block %ptr [concrete = <error>] {
Expand Down Expand Up @@ -526,7 +526,7 @@ private class Redecl {}
// CHECK:STDOUT: %Test.import = import Test
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %c.patt: <error> = binding_pattern c
// CHECK:STDOUT: %c.param_patt: <error> = value_param_pattern %c.patt, runtime_param0
// CHECK:STDOUT: %c.param_patt: <error> = value_param_pattern %c.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %c.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %.loc10: type = splice_block %ptr [concrete = <error>] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ class C {
// CHECK:STDOUT: %C.decl.loc18: type = class_decl @C.2 [concrete = constants.%C.9f4] {} {}
// CHECK:STDOUT: %F2.decl: %F2.type = fn_decl @F2 [concrete = constants.%F2] {
// CHECK:STDOUT: %x.patt: <error> = binding_pattern x
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %x.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %.1: <error> = splice_block <error> [concrete = <error>] {
Expand Down Expand Up @@ -680,7 +680,7 @@ class C {
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %x.patt: <error> = binding_pattern x
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %x.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %C.ref: <error> = name_ref C, <error> [concrete = <error>]
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/testdata/deduce/int_float.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn G(a: f64) -> Core.IntLiteral() {
// CHECK:STDOUT: %N.patt.loc9_6.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc9_6.2 (constants.%N.patt)]
// CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc9_6.1, runtime_param<none> [symbolic = %N.patt.loc9_6.2 (constants.%N.patt)]
// CHECK:STDOUT: %n.patt: <error> = binding_pattern n
// CHECK:STDOUT: %n.param_patt: <error> = value_param_pattern %n.patt, runtime_param0
// CHECK:STDOUT: %n.param_patt: <error> = value_param_pattern %n.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: %return.patt: Core.IntLiteral = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: Core.IntLiteral = out_param_pattern %return.patt, runtime_param1
// CHECK:STDOUT: } {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn F(n: i32, a: array(i32, n)*);
// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n
// CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, runtime_param0
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param1
// CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param1 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %n.param: %i32 = value_param runtime_param0
// CHECK:STDOUT: %.loc15_9: type = splice_block %i32.loc15_9 [concrete = constants.%i32] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn K() -> {} { return {}; }
// CHECK:STDOUT: }
// CHECK:STDOUT: %.decl.loc36: %.type.b6a92a.3 = fn_decl @.3 [concrete = constants.%.d852be.3] {
// CHECK:STDOUT: %x.patt: <error> = binding_pattern x
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0
// CHECK:STDOUT: %x.param_patt: <error> = value_param_pattern %x.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %x.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %x: <error> = bind_name x, %x.param
Expand Down
4 changes: 2 additions & 2 deletions toolchain/check/testdata/generic/complete_type.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ library "[[@TEST_NAME]]";
class B;

class A(T:! type) {
// CHECK:STDERR: fail_incomplete_in_class.carbon:[[@LINE+6]]:10: error: `T` evaluates to incomplete type `B` [IncompleteTypeInMonomorphization]
// CHECK:STDERR: fail_incomplete_in_class.carbon:[[@LINE+6]]:10: error: type `B` is incomplete [IncompleteTypeInMonomorphization]
// CHECK:STDERR: var v: T;
// CHECK:STDERR: ^
// CHECK:STDERR: fail_incomplete_in_class.carbon:[[@LINE-6]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
Expand Down Expand Up @@ -61,7 +61,7 @@ library "[[@TEST_NAME]]";
class B;

fn F(T:! type) {
// CHECK:STDERR: fail_incomplete_in_function_at_eof.carbon:[[@LINE+6]]:10: error: `T` evaluates to incomplete type `B` [IncompleteTypeInMonomorphization]
// CHECK:STDERR: fail_incomplete_in_function_at_eof.carbon:[[@LINE+6]]:10: error: type `B` is incomplete [IncompleteTypeInMonomorphization]
// CHECK:STDERR: var v: T;
// CHECK:STDERR: ^
// CHECK:STDERR: fail_incomplete_in_function_at_eof.carbon:[[@LINE-6]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
Expand Down
7 changes: 3 additions & 4 deletions toolchain/check/testdata/impl/assoc_const_self.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ impl C as I where .V = () {}
library "[[@TEST_NAME]]";

interface I(N:! Core.IntLiteral()) {
// CHECK:STDERR: fail_monomorphization_failure.carbon:[[@LINE+3]]:17: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: fail_monomorphization_failure.carbon:[[@LINE+3]]:11: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: let V:! array(Self, N);
// CHECK:STDERR: ^~~~
// CHECK:STDERR: ^~~~~~~~~~~~~~
let V:! array(Self, N);
}

Expand Down Expand Up @@ -563,7 +563,6 @@ fn CallF() {
// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
// CHECK:STDOUT: %.Self.as_wit: <witness> = facet_access_witness %.Self [symbolic_self]
// CHECK:STDOUT: %I.facet: %I.type.057 = facet_value %.Self.as_type, %.Self.as_wit [symbolic_self]
// CHECK:STDOUT: %impl.elem0: <error> = impl_witness_access %.Self.as_wit, element0 [symbolic_self]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
Expand Down Expand Up @@ -614,7 +613,7 @@ fn CallF() {
// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
// CHECK:STDOUT: %.loc15_24.2: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
// CHECK:STDOUT: %.Self.as_wit: <witness> = facet_access_witness %.Self.ref [symbolic_self = constants.%.Self.as_wit]
// CHECK:STDOUT: %impl.elem0.loc15_24: <error> = impl_witness_access %.Self.as_wit, element0 [symbolic_self = constants.%impl.elem0]
// CHECK:STDOUT: %impl.elem0.loc15_24: <error> = impl_witness_access %.Self.as_wit, element0 [concrete = <error>]
// CHECK:STDOUT: %.loc15_30: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc15_18: type = where_expr %.Self [concrete = <error>] {
// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc15_24, <error>
Expand Down
2 changes: 1 addition & 1 deletion toolchain/check/testdata/impl/fail_call_invalid.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn InstanceCall(n: i32) {
// CHECK:STDOUT: impl @impl.006: %i32 as %Simple.ref {
// CHECK:STDOUT: %G.decl: %G.type.c98 = fn_decl @G.2 [concrete = constants.%G.e73] {
// CHECK:STDOUT: %self.patt: <error> = binding_pattern self
// CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern %self.patt, runtime_param0
// CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern %self.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %self.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %Undeclared.ref: <error> = name_ref Undeclared, <error> [concrete = <error>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl i32 as I {
// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
// CHECK:STDOUT: %F.decl: %F.type.cf0 = fn_decl @F.1 [concrete = constants.%F.bc6] {
// CHECK:STDOUT: %c.patt: <error> = binding_pattern c
// CHECK:STDOUT: %c.param_patt: <error> = value_param_pattern %c.patt, runtime_param0
// CHECK:STDOUT: %c.param_patt: <error> = value_param_pattern %c.patt, runtime_param0 [concrete = <error>]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %c.param: <error> = value_param runtime_param0
// CHECK:STDOUT: %.loc29: type = splice_block %C [concrete = <error>] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl () as I where .N = 2 {
// CHECK:STDOUT: %self.patt: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df) = binding_pattern self
// CHECK:STDOUT: %self.param_patt: @F.1.%Self.as_type.loc19_14.1 (%Self.as_type.3df) = value_param_pattern %self.patt, runtime_param0
// CHECK:STDOUT: %u.patt: <error> = binding_pattern u
// CHECK:STDOUT: %u.param_patt: <error> = value_param_pattern %u.patt, runtime_param1
// CHECK:STDOUT: %u.param_patt: <error> = value_param_pattern %u.patt, runtime_param1 [concrete = <error>]
// CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
// CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param2
// CHECK:STDOUT: } {
Expand Down
Loading

0 comments on commit 0d2f364

Please sign in to comment.