mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 20:38:18 +00:00
Historically, we disabled the rendered form in tests outside of `toolchain/diagnostics`. The idea was to keep tests shorter and avoid very long chains of autoupdate before stabilizing due to all the line numbers and other artifacts in the rendered form. This PR adds `--diagnostic-line-numbers=[all|first]` and defaults to `first` in tests. This keeps the rendered form so that we can easily code review that form and the visual cues it does or doesn't provide. But it removes all but the first location's line numbers to provide significantly more stability in tests. By default, tests get the full unicode line-drawing form of diagnostics so we can ensure all of the artifacts there make sense with the specific case being diagnosed, but we do retain some focused ASCII-rendering tests to ensure that fallback remains usable. There are some issues here that will be fixed in subsequent PRs. Notably, we try to keep the frame together in the check lines, and so force some parts to use the first location. This largely works, but fails in some edge cases, causing the entire frame to be located incorrectly. There is a TODO about this that we need to fix, and it only occurs 6 times across the test suite, so it didn't seem worth front-loading a fix for here. Assisted-by: Claude Code
222 lines
15 KiB
Plaintext
222 lines
15 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
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/fail_call_invalid.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/fail_call_invalid.carbon
|
|
|
|
interface Simple {
|
|
fn G(self);
|
|
}
|
|
|
|
impl i32 as Simple {
|
|
// CHECK:STDERR: ╭─┤ fail_call_invalid.carbon:[[@LINE+6]]:14
|
|
// CHECK:STDERR: -> │ fn G(self: Undeclared);
|
|
// CHECK:STDERR: · ━━━━━┳━━━━
|
|
// CHECK:STDERR: · ┗━━┫ error: name `Undeclared` not found [NameNotFound]
|
|
// CHECK:STDERR: ╰────
|
|
// CHECK:STDERR:
|
|
fn G(self: Undeclared);
|
|
}
|
|
|
|
fn InstanceCall(n: i32) {
|
|
n.(Simple.G)();
|
|
}
|
|
|
|
|
|
// CHECK:STDOUT: --- fail_call_invalid.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
|
|
// CHECK:STDOUT: %Simple.type: type = facet_type <@Simple> [concrete]
|
|
// CHECK:STDOUT: %Self: %Simple.type = symbolic_binding Self, 0 [symbolic]
|
|
// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
|
|
// CHECK:STDOUT: %pattern_type.c62: type = pattern_type %Self.as_type [symbolic]
|
|
// CHECK:STDOUT: %self.param_patt.b93: %pattern_type.c62 = value_param_pattern [symbolic]
|
|
// CHECK:STDOUT: %self.patt.25d: %pattern_type.c62 = wrapper_binding_pattern self, %self.param_patt.b93 [symbolic]
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.type.b40: type = fn_type @Simple.WithSelf.G, @Simple.WithSelf(%Self) [symbolic]
|
|
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.687: %Simple.WithSelf.G.type.b40 = struct_value () [symbolic]
|
|
// CHECK:STDOUT: %Simple.assoc_type: type = assoc_entity_type @Simple [concrete]
|
|
// CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, @Simple.WithSelf.%Simple.WithSelf.G.decl [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %Int.type: type = parameterized_class_name_type @Int [concrete]
|
|
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %.b0e: <witness> = impl_self_witness %i32, @Simple [concrete]
|
|
// CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness @i32.as.Simple.impl.%Simple.impl_witness_table [concrete]
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.type.321a2c.1: type = fn_type @i32.as.Simple.impl.G.loc26_25.1 [concrete]
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.d407b2.1: %i32.as.Simple.impl.G.type.321a2c.1 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %Simple.facet: %Simple.type = facet_value %i32, (%Simple.impl_witness) [concrete]
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.type.34c: type = fn_type @Simple.WithSelf.G, @Simple.WithSelf(%Simple.facet) [concrete]
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.0e7: %Simple.WithSelf.G.type.34c = struct_value () [concrete]
|
|
// CHECK:STDOUT: %pattern_type.d94: type = pattern_type %i32 [concrete]
|
|
// CHECK:STDOUT: %self.param_patt.f52: %pattern_type.d94 = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %self.patt.835: %pattern_type.d94 = wrapper_binding_pattern self, %self.param_patt.f52 [concrete]
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.type.321a2c.2: type = fn_type @i32.as.Simple.impl.G.loc26_25.2 [concrete]
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.d407b2.2: %i32.as.Simple.impl.G.type.321a2c.2 = struct_value () [concrete]
|
|
// CHECK:STDOUT: %n.param_patt: %pattern_type.d94 = value_param_pattern [concrete]
|
|
// CHECK:STDOUT: %n.patt: %pattern_type.d94 = wrapper_binding_pattern n, %n.param_patt [concrete]
|
|
// CHECK:STDOUT: %InstanceCall.type: type = fn_type @InstanceCall [concrete]
|
|
// CHECK:STDOUT: %InstanceCall: %InstanceCall.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %.20e: type = fn_type_with_self_type %Simple.WithSelf.G.type.34c, %Simple.facet [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
|
// CHECK:STDOUT: .Int = %Core.Int
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Simple = %Simple.decl
|
|
// CHECK:STDOUT: .Undeclared = <poisoned>
|
|
// CHECK:STDOUT: .InstanceCall = %InstanceCall.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %Simple.decl: type = interface_decl @Simple [concrete = constants.%Simple.type] {} {}
|
|
// CHECK:STDOUT: impl_decl @i32.as.Simple.impl [concrete] {} {
|
|
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %.loc19: <witness> = impl_self_witness @i32.as.Simple.impl.%i32, @Simple [concrete = constants.%.b0e]
|
|
// CHECK:STDOUT: %InstanceCall.decl: %InstanceCall.type = fn_decl @InstanceCall [concrete = constants.%InstanceCall] {
|
|
// CHECK:STDOUT: %n.param_patt: %pattern_type.d94 = value_param_pattern [concrete = constants.%n.param_patt]
|
|
// CHECK:STDOUT: %n.patt: %pattern_type.d94 = wrapper_binding_pattern n, %n.param_patt [concrete = constants.%n.patt]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %n.param: %i32 = value_param call_param0
|
|
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %n: %i32 = wrapper_binding n, %n.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: interface @Simple {
|
|
// CHECK:STDOUT: %Self: %Simple.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
|
|
// CHECK:STDOUT: %Simple.WithSelf.decl = interface_with_self_decl @Simple [concrete]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !with Self:
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.decl: @Simple.WithSelf.%Simple.WithSelf.G.type (%Simple.WithSelf.G.type.b40) = fn_decl @Simple.WithSelf.G [symbolic = @Simple.WithSelf.%Simple.WithSelf.G (constants.%Simple.WithSelf.G.687)] {
|
|
// CHECK:STDOUT: %self.param_patt.loc16_8.1: @Simple.WithSelf.G.%pattern_type (%pattern_type.c62) = value_param_pattern [symbolic = %self.param_patt.loc16_8.2 (constants.%self.param_patt.b93)]
|
|
// CHECK:STDOUT: %self.patt.loc16_8.1: @Simple.WithSelf.G.%pattern_type (%pattern_type.c62) = wrapper_binding_pattern self, %self.param_patt.loc16_8.1 [symbolic = %self.patt.loc16_8.2 (constants.%self.patt.25d)]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: @Simple.WithSelf.G.%Self.as_type.loc16_8.1 (%Self.as_type) = value_param call_param0
|
|
// CHECK:STDOUT: %.loc16_8.1: type = splice_block %.loc16_8.2 [symbolic = %Self.as_type.loc16_8.1 (constants.%Self.as_type)] {
|
|
// CHECK:STDOUT: %Self.ref: %Simple.type = name_ref Self, @Simple.%Self [symbolic = %Self (constants.%Self)]
|
|
// CHECK:STDOUT: %Self.as_type.loc16_8.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc16_8.1 (constants.%Self.as_type)]
|
|
// CHECK:STDOUT: %.loc16_8.2: type = converted %Self.ref, %Self.as_type.loc16_8.2 [symbolic = %Self.as_type.loc16_8.1 (constants.%Self.as_type)]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %self: @Simple.WithSelf.G.%Self.as_type.loc16_8.1 (%Self.as_type) = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %assoc0: %Simple.assoc_type = assoc_entity element0, %Simple.WithSelf.G.decl [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = %Self
|
|
// CHECK:STDOUT: .G = @Simple.WithSelf.%assoc0
|
|
// CHECK:STDOUT: .Undeclared = <poisoned>
|
|
// CHECK:STDOUT: witness = (@Simple.WithSelf.%Simple.WithSelf.G.decl)
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !requires:
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @i32.as.Simple.impl: %i32 as %Simple.ref {
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.decl.loc26_25.1: %i32.as.Simple.impl.G.type.321a2c.1 = fn_decl @i32.as.Simple.impl.G.loc26_25.1 [concrete = constants.%i32.as.Simple.impl.G.d407b2.1] {
|
|
// CHECK:STDOUT: %self.param_patt: <error> = value_param_pattern [concrete = <error>]
|
|
// CHECK:STDOUT: %self.patt: <error> = wrapper_binding_pattern self, %self.param_patt [concrete = <error>]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: <error> = value_param call_param0
|
|
// CHECK:STDOUT: %Undeclared.ref: <error> = name_ref Undeclared, <error> [concrete = <error>]
|
|
// CHECK:STDOUT: %self: <error> = wrapper_binding self, <error> [concrete = <error>]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.decl.loc26_25.2: %i32.as.Simple.impl.G.type.321a2c.2 = fn_decl @i32.as.Simple.impl.G.loc26_25.2 [concrete = constants.%i32.as.Simple.impl.G.d407b2.2] {
|
|
// CHECK:STDOUT: %.1: %pattern_type.d94 = specific_constant constants.%self.param_patt.f52, @Simple.WithSelf.G(constants.%Simple.facet) [concrete = constants.%self.param_patt.f52]
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.d94 = wrapper_binding_pattern self, %.1 [concrete = constants.%self.patt.835]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: %i32 = value_param call_param0
|
|
// CHECK:STDOUT: %self: %i32 = wrapper_binding self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Simple.impl_witness_table = impl_witness_table (%i32.as.Simple.impl.G.decl.loc26_25.2), @i32.as.Simple.impl [concrete]
|
|
// CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness %Simple.impl_witness_table [concrete = constants.%Simple.impl_witness]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Undeclared = <poisoned>
|
|
// CHECK:STDOUT: .G = %i32.as.Simple.impl.G.decl.loc26_25.1
|
|
// CHECK:STDOUT: extend %Simple.ref
|
|
// CHECK:STDOUT: witness = %Simple.impl_witness
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: generic fn @Simple.WithSelf.G(@Simple.%Self: %Simple.type) {
|
|
// CHECK:STDOUT: %Self: %Simple.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self)]
|
|
// CHECK:STDOUT: %Self.as_type.loc16_8.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc16_8.1 (constants.%Self.as_type)]
|
|
// CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc16_8.1 [symbolic = %pattern_type (constants.%pattern_type.c62)]
|
|
// CHECK:STDOUT: %self.param_patt.loc16_8.2: @Simple.WithSelf.G.%pattern_type (%pattern_type.c62) = value_param_pattern [symbolic = %self.param_patt.loc16_8.2 (constants.%self.param_patt.b93)]
|
|
// CHECK:STDOUT: %self.patt.loc16_8.2: @Simple.WithSelf.G.%pattern_type (%pattern_type.c62) = wrapper_binding_pattern self, %self.param_patt.loc16_8.2 [symbolic = %self.patt.loc16_8.2 (constants.%self.patt.25d)]
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn(%self.param: @Simple.WithSelf.G.%Self.as_type.loc16_8.1 (%Self.as_type));
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @i32.as.Simple.impl.G.loc26_25.1(%self.param: <error>);
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @i32.as.Simple.impl.G.loc26_25.2(%self.param: %i32) [thunk @i32.as.Simple.impl.%i32.as.Simple.impl.G.decl.loc26_25.1 for @Simple.WithSelf.%Simple.WithSelf.G.decl, @Simple.WithSelf.G(constants.%Simple.facet)] {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %G.ref: %i32.as.Simple.impl.G.type.321a2c.1 = name_ref G, @i32.as.Simple.impl.%i32.as.Simple.impl.G.decl.loc26_25.1 [concrete = constants.%i32.as.Simple.impl.G.d407b2.1]
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.bound: <bound method> = bound_method %self.param, %G.ref
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.call: init %empty_tuple.type = call %i32.as.Simple.impl.G.bound(<error>)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @InstanceCall(%n.param: %i32) {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
|
|
// CHECK:STDOUT: %Simple.ref: type = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.type]
|
|
// CHECK:STDOUT: %G.ref.loc30_12: %Simple.assoc_type = name_ref G, @Simple.WithSelf.%assoc0 [concrete = constants.%assoc0]
|
|
// CHECK:STDOUT: %impl.elem0: %.20e = impl_witness_access constants.%Simple.impl_witness, element0 [concrete = constants.%i32.as.Simple.impl.G.d407b2.2]
|
|
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %n.ref, %impl.elem0
|
|
// CHECK:STDOUT: %G.ref.loc30_16: %i32.as.Simple.impl.G.type.321a2c.1 = name_ref G, @i32.as.Simple.impl.%i32.as.Simple.impl.G.decl.loc26_25.1 [concrete = constants.%i32.as.Simple.impl.G.d407b2.1]
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.bound: <bound method> = bound_method %n.ref, %G.ref.loc30_16
|
|
// CHECK:STDOUT: %i32.as.Simple.impl.G.call: init %empty_tuple.type = call %i32.as.Simple.impl.G.bound(<error>)
|
|
// CHECK:STDOUT: return
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @Simple.WithSelf(constants.%Self) {
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %Self => constants.%Self
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.type => constants.%Simple.WithSelf.G.type.b40
|
|
// CHECK:STDOUT: %Simple.WithSelf.G => constants.%Simple.WithSelf.G.687
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @Simple.WithSelf.G(constants.%Self) {
|
|
// CHECK:STDOUT: %Self => constants.%Self
|
|
// CHECK:STDOUT: %Self.as_type.loc16_8.1 => constants.%Self.as_type
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.c62
|
|
// CHECK:STDOUT: %self.param_patt.loc16_8.2 => constants.%self.param_patt.b93
|
|
// CHECK:STDOUT: %self.patt.loc16_8.2 => constants.%self.patt.25d
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @Simple.WithSelf(constants.%Simple.facet) {
|
|
// CHECK:STDOUT: !definition:
|
|
// CHECK:STDOUT: %Self => constants.%Simple.facet
|
|
// CHECK:STDOUT: %Simple.WithSelf.G.type => constants.%Simple.WithSelf.G.type.34c
|
|
// CHECK:STDOUT: %Simple.WithSelf.G => constants.%Simple.WithSelf.G.0e7
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: specific @Simple.WithSelf.G(constants.%Simple.facet) {
|
|
// CHECK:STDOUT: %Self => constants.%Simple.facet
|
|
// CHECK:STDOUT: %Self.as_type.loc16_8.1 => constants.%i32
|
|
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.d94
|
|
// CHECK:STDOUT: %self.param_patt.loc16_8.2 => constants.%self.param_patt.f52
|
|
// CHECK:STDOUT: %self.patt.loc16_8.2 => constants.%self.patt.835
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|