Files
carbon-lang/toolchain/check/testdata/struct/fail_nested_incomplete.carbon
T
Geoff RomerandDana Jansens e67b6db910 Give files shorthand names in textual SemIR (#8104)
Shorthand names are intended to be used in the textual format of
references to instructions in another IR (which can't happen now, but
will be possible in a forthcoming PR). The shorthand name uses the file
name (minus the `.carbon` suffix) as a base, and if that base name is
ambiguous within the compilation, it is given a numerical suffix `.N`,
just like other textual IR names. Shorthand names are prefixed with `$`
in the textual format, to distinguish them from inst and scope names.

For example, a file `foo/bar.carbon` has the shorthand name `$bar`, and
an instruction `@baz.%qux` in that file can be referenced from another
file as `$bar.@baz.%qux`.

This PR adds `toolchain/check/testdata/basics/file_name.carbon` to test
this behavior. All other test changes are just applying this change to
the existing textual SemIR dumps.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
2026-11-12 23:34:32 +00:00

86 lines
4.5 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/none.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/struct/fail_nested_incomplete.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_nested_incomplete.carbon
class Incomplete;
// CHECK:STDERR: ╭─┤ fail_nested_incomplete.carbon:[[@LINE+12]]:8
// CHECK:STDERR: │ class Incomplete;
// CHECK:STDERR: · ────────┬────────
// CHECK:STDERR: · ╰──┤ class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ var s: {.a: Incomplete};
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: binding pattern has incomplete type `{.a: Incomplete}` in
// CHECK:STDERR: · ┃ name binding declaration
// CHECK:STDERR: · ┃ [IncompleteTypeInBindingDecl]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var s: {.a: Incomplete};
var p: Incomplete* = &s.a;
// CHECK:STDOUT: --- fail_nested_incomplete.carbon = $fail_nested_incomplete
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: type: type = facet_type <type> [concrete]
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [concrete]
// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %Incomplete} [concrete]
// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [concrete]
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
// CHECK:STDOUT: %p.patt: %pattern_type = ref_binding_pattern p [concrete]
// CHECK:STDOUT: %p.var_patt: %pattern_type = var_pattern %p.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Incomplete = %Incomplete.decl
// CHECK:STDOUT: .s = %s
// CHECK:STDOUT: .p = %p
// CHECK:STDOUT: }
// CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [concrete = constants.%Incomplete] {} {}
// CHECK:STDOUT: %s.var: ref <error> = var_storage %s.var_patt [concrete = <error>]
// CHECK:STDOUT: %.loc29: type = splice_block %struct_type.a [concrete = constants.%struct_type.a] {
// CHECK:STDOUT: %Incomplete.ref.loc29: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %Incomplete} [concrete = constants.%struct_type.a]
// CHECK:STDOUT: }
// CHECK:STDOUT: %s: <error> = wrapper_binding s, <error> [concrete = <error>]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %s.patt: <error> = ref_binding_pattern s [concrete = <error>]
// CHECK:STDOUT: %s.var_patt: <error> = var_pattern %s.patt [concrete = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p.var: ref %ptr = var_storage %p.var_patt [concrete]
// CHECK:STDOUT: %.loc31: type = splice_block %ptr [concrete = constants.%ptr] {
// CHECK:STDOUT: %Incomplete.ref.loc31: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete.ref.loc31 [concrete = constants.%ptr]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p: ref %ptr = wrapper_binding p, %p.var [concrete = %p.var]
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %p.patt: %pattern_type = ref_binding_pattern p [concrete = constants.%p.patt]
// CHECK:STDOUT: %p.var_patt: %pattern_type = var_pattern %p.patt [concrete = constants.%p.var_patt]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @Incomplete;
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: assign file.%s.var, <error>
// CHECK:STDOUT: %s.ref: <error> = name_ref s, file.%s [concrete = <error>]
// CHECK:STDOUT: %a.ref: <error> = name_ref a, <error> [concrete = <error>]
// CHECK:STDOUT: %addr: <error> = addr_of %a.ref [concrete = <error>]
// CHECK:STDOUT: assign file.%p.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: