// 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/operators/overloaded/fail_error_recovery.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/fail_error_recovery.carbon // Each of these should only produce one error, and shouldn't complain that // `` doesn't implement an operator. fn F() { // CHECK:STDERR: fail_error_recovery.carbon:[[@LINE+4]]:3: error: name `undeclared` not found [NameNotFound] // CHECK:STDERR: undeclared + 1; // CHECK:STDERR: ^~~~~~~~~~ // CHECK:STDERR: undeclared + 1; } fn G(n: i32) { // CHECK:STDERR: fail_error_recovery.carbon:[[@LINE+4]]:7: error: name `undeclared` not found [NameNotFound] // CHECK:STDERR: n + undeclared; // CHECK:STDERR: ^~~~~~~~~~ // CHECK:STDERR: n + undeclared; } // CHECK:STDOUT: --- fail_error_recovery.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %Add.type: type = facet_type <@Add> [template] // CHECK:STDOUT: %Op.type.545: type = fn_type @Op.1 [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %G.type: type = fn_type @G [template] // CHECK:STDOUT: %G: %G.type = struct_value () [template] // CHECK:STDOUT: %impl_witness.01d: = impl_witness (imports.%Core.import_ref.344), @impl.14(%int_32) [template] // CHECK:STDOUT: %Op.type.210: type = fn_type @Op.2, @impl.14(%int_32) [template] // CHECK:STDOUT: %Op.c82: %Op.type.210 = struct_value () [template] // CHECK:STDOUT: %Add.facet: %Add.type = facet_value %i32, %impl_witness.01d [template] // CHECK:STDOUT: %.ede: type = fn_type_with_self_type %Op.type.545, %Add.facet [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .Add = %Core.Add // CHECK:STDOUT: .Int = %Core.Int // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .G = %G.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %n.patt: %i32 = binding_pattern n // CHECK:STDOUT: %n.param_patt: %i32 = value_param_pattern %n.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %n.param: %i32 = value_param runtime_param0 // CHECK:STDOUT: %.loc22: type = splice_block %i32 [template = constants.%i32] { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %n: %i32 = bind_name n, %n.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %undeclared.ref: = name_ref undeclared, [template = ] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %impl.elem0: = impl_witness_access , element0 [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%n.param_patt: %i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n // CHECK:STDOUT: %undeclared.ref: = name_ref undeclared, [template = ] // CHECK:STDOUT: %impl.elem0: %.ede = impl_witness_access constants.%impl_witness.01d, element0 [template = constants.%Op.c82] // CHECK:STDOUT: %bound_method: = bound_method %n.ref, %impl.elem0 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: