Просмотр исходного кода

Improve diagnostics for missing qualified names. (#4638)

Mention the scope in which the name wasn't found.

---------

Co-authored-by: Geoff Romer <gromer@google.com>
Richard Smith 1 год назад
Родитель
Сommit
e75ef34591
23 измененных файлов с 1243 добавлено и 25 удалено
  1. 54 1
      toolchain/check/context.cpp
  2. 9 0
      toolchain/check/context.h
  3. 1 1
      toolchain/check/testdata/alias/no_prelude/fail_local_in_namespace.carbon
  4. 1 1
      toolchain/check/testdata/alias/no_prelude/import_access.carbon
  5. 1 1
      toolchain/check/testdata/class/adapter/adapt.carbon
  6. 2 2
      toolchain/check/testdata/class/adapter/extend_adapt.carbon
  7. 1 1
      toolchain/check/testdata/class/adapter/fail_adapt_bad_decl.carbon
  8. 1 1
      toolchain/check/testdata/class/fail_base_bad_type.carbon
  9. 1 1
      toolchain/check/testdata/class/fail_unknown_member.carbon
  10. 701 0
      toolchain/check/testdata/class/generic/member_lookup.carbon
  11. 3 3
      toolchain/check/testdata/class/no_prelude/import_access.carbon
  12. 3 3
      toolchain/check/testdata/function/definition/import_access.carbon
  13. 449 0
      toolchain/check/testdata/interface/member_lookup.carbon
  14. 1 1
      toolchain/check/testdata/interface/no_prelude/fail_lookup_in_type_type.carbon
  15. 1 1
      toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon
  16. 2 2
      toolchain/check/testdata/interface/no_prelude/import_access.carbon
  17. 1 1
      toolchain/check/testdata/let/no_prelude/import_access.carbon
  18. 1 1
      toolchain/check/testdata/package_expr/fail_not_found.carbon
  19. 1 1
      toolchain/check/testdata/packages/no_prelude/cross_package_import.carbon
  20. 1 1
      toolchain/check/testdata/var/no_prelude/import_access.carbon
  21. 1 1
      toolchain/check/testdata/where_expr/designator.carbon
  22. 2 0
      toolchain/diagnostics/diagnostic_kind.def
  23. 5 1
      toolchain/sem_ir/stringify_type.cpp

+ 54 - 1
toolchain/check/context.cpp

@@ -222,6 +222,54 @@ auto Context::DiagnoseNameNotFound(SemIRLoc loc, SemIR::NameId name_id)
   emitter_->Emit(loc, NameNotFound, name_id);
 }
 
+// Given an instruction associated with a scope and a `SpecificId` for that
+// scope, returns an instruction that describes the specific scope.
+static auto GetInstForSpecificScope(Context& context, SemIR::InstId inst_id,
+                                    SemIR::SpecificId specific_id)
+    -> SemIR::InstId {
+  if (!specific_id.is_valid()) {
+    return inst_id;
+  }
+  auto inst = context.insts().Get(inst_id);
+  CARBON_KIND_SWITCH(inst) {
+    case CARBON_KIND(SemIR::ClassDecl class_decl): {
+      return context.types().GetInstId(
+          context.GetClassType(class_decl.class_id, specific_id));
+    }
+    case CARBON_KIND(SemIR::InterfaceDecl interface_decl): {
+      return context.types().GetInstId(
+          context.GetInterfaceType(interface_decl.interface_id, specific_id));
+    }
+    default: {
+      // Don't know how to form a specific for this generic scope.
+      // TODO: Handle more cases.
+      return SemIR::InstId::Invalid;
+    }
+  }
+}
+
+auto Context::DiagnoseMemberNameNotFound(
+    SemIRLoc loc, SemIR::NameId name_id,
+    llvm::ArrayRef<LookupScope> lookup_scopes) -> void {
+  if (lookup_scopes.size() == 1 &&
+      lookup_scopes.front().name_scope_id.is_valid()) {
+    const auto& scope = name_scopes().Get(lookup_scopes.front().name_scope_id);
+    if (auto specific_inst_id = GetInstForSpecificScope(
+            *this, scope.inst_id(), lookup_scopes.front().specific_id);
+        specific_inst_id.is_valid()) {
+      CARBON_DIAGNOSTIC(MemberNameNotFoundInScope, Error,
+                        "member name `{0}` not found in {1}", SemIR::NameId,
+                        InstIdAsType);
+      emitter_->Emit(loc, MemberNameNotFoundInScope, name_id, specific_inst_id);
+      return;
+    }
+  }
+
+  CARBON_DIAGNOSTIC(MemberNameNotFound, Error, "member name `{0}` not found",
+                    SemIR::NameId);
+  emitter_->Emit(loc, MemberNameNotFound, name_id);
+}
+
 auto Context::NoteAbstractClass(SemIR::ClassId class_id,
                                 DiagnosticBuilder& builder) -> void {
   const auto& class_info = classes().Get(class_id);
@@ -590,7 +638,7 @@ auto Context::LookupQualifiedName(SemIRLoc loc, SemIR::NameId name_id,
   if (required && !result.inst_id.is_valid()) {
     if (!has_error) {
       if (prohibited_accesses.empty()) {
-        DiagnoseNameNotFound(loc, name_id);
+        DiagnoseMemberNameNotFound(loc, name_id, lookup_scopes);
       } else {
         //  TODO: We should report multiple prohibited accesses in case we don't
         //  find a valid lookup. Reporting the last one should suffice for now.
@@ -1361,6 +1409,11 @@ auto Context::GetSingletonType(SemIR::InstId singleton_id) -> SemIR::TypeId {
   return type_id;
 }
 
+auto Context::GetClassType(SemIR::ClassId class_id,
+                           SemIR::SpecificId specific_id) -> SemIR::TypeId {
+  return GetCompleteTypeImpl<SemIR::ClassType>(*this, class_id, specific_id);
+}
+
 auto Context::GetFunctionType(SemIR::FunctionId fn_id,
                               SemIR::SpecificId specific_id) -> SemIR::TypeId {
   return GetCompleteTypeImpl<SemIR::FunctionType>(*this, fn_id, specific_id);

+ 9 - 0
toolchain/check/context.h

@@ -248,6 +248,11 @@ class Context {
   // Prints a diagnostic for a missing name.
   auto DiagnoseNameNotFound(SemIRLoc loc, SemIR::NameId name_id) -> void;
 
+  // Prints a diagnostic for a missing qualified name.
+  auto DiagnoseMemberNameNotFound(SemIRLoc loc, SemIR::NameId name_id,
+                                  llvm::ArrayRef<LookupScope> lookup_scopes)
+      -> void;
+
   // Adds a note to a diagnostic explaining that a class is incomplete.
   auto NoteIncompleteClass(SemIR::ClassId class_id, DiagnosticBuilder& builder)
       -> void;
@@ -386,6 +391,10 @@ class Context {
   // `singleton_id` is already validated to be a singleton.
   auto GetSingletonType(SemIR::InstId singleton_id) -> SemIR::TypeId;
 
+  // Gets a class type.
+  auto GetClassType(SemIR::ClassId class_id, SemIR::SpecificId specific_id)
+      -> SemIR::TypeId;
+
   // Gets a function type. The returned type will be complete.
   auto GetFunctionType(SemIR::FunctionId fn_id, SemIR::SpecificId specific_id)
       -> SemIR::TypeId;

+ 1 - 1
toolchain/check/testdata/alias/no_prelude/fail_local_in_namespace.carbon

@@ -20,7 +20,7 @@ fn F() -> {} {
   // CHECK:STDERR:                ^~
   // CHECK:STDERR:
   alias NS.a = {};
-  // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+3]]:10: error: name `a` not found [NameNotFound]
+  // CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+3]]:10: error: member name `a` not found in `NS` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   return NS.a;
   // CHECK:STDERR:          ^~~~
   return NS.a;

+ 1 - 1
toolchain/check/testdata/alias/no_prelude/import_access.carbon

@@ -47,7 +47,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "def";
 
-// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:11: error: name `A` not found [NameNotFound]
+// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:11: error: member name `A` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var inst: Test.A = {};
 // CHECK:STDERR:           ^~~~~~
 var inst: Test.A = {};

+ 1 - 1
toolchain/check/testdata/class/adapter/adapt.carbon

@@ -39,7 +39,7 @@ class AdaptNotExtend {
 
 fn F(a: AdaptNotExtend) {
   // `Adapted` is not extended, so lookup for `F` finds nothing.
-  // CHECK:STDERR: fail_not_extend.carbon:[[@LINE+3]]:3: error: name `F` not found [NameNotFound]
+  // CHECK:STDERR: fail_not_extend.carbon:[[@LINE+3]]:3: error: member name `F` not found in `AdaptNotExtend` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   a.F();
   // CHECK:STDERR:   ^~~
   a.F();

+ 2 - 2
toolchain/check/testdata/class/adapter/extend_adapt.carbon

@@ -95,7 +95,7 @@ class StructAdapter {
 
 fn F(a: StructAdapter) -> i32 {
   // TODO: This should be allowed.
-  // CHECK:STDERR: fail_todo_adapt_struct.carbon:[[@LINE+4]]:10: error: name `b` not found [NameNotFound]
+  // CHECK:STDERR: fail_todo_adapt_struct.carbon:[[@LINE+4]]:10: error: member name `b` not found in `StructAdapter` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   return a.b;
   // CHECK:STDERR:          ^~~
   // CHECK:STDERR:
@@ -131,7 +131,7 @@ class IntAdapter {
 
 fn F(a: IntAdapter) -> i32 {
   // Builtin types have no member names.
-  // CHECK:STDERR: fail_adapt_builtin.carbon:[[@LINE+3]]:10: error: name `foo` not found [NameNotFound]
+  // CHECK:STDERR: fail_adapt_builtin.carbon:[[@LINE+3]]:10: error: member name `foo` not found in `IntAdapter` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   return a.foo;
   // CHECK:STDERR:          ^~~~~
   return a.foo;

+ 1 - 1
toolchain/check/testdata/class/adapter/fail_adapt_bad_decl.carbon

@@ -23,7 +23,7 @@ class Bad {
   adapt 100;
 }
 
-// CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:18: error: name `F` not found [NameNotFound]
+// CHECK:STDERR: fail_not_type.carbon:[[@LINE+4]]:18: error: member name `F` not found in `Bad` [MemberNameNotFoundInScope]
 // CHECK:STDERR: fn Use(b: Bad) { b.F(); }
 // CHECK:STDERR:                  ^~~
 // CHECK:STDERR:

+ 1 - 1
toolchain/check/testdata/class/fail_base_bad_type.carbon

@@ -174,7 +174,7 @@ fn AccessMemberWithInvalidBaseFinal_WithMember(p: DeriveFromFinal*) -> i32 {
 }
 
 fn AccessMemberWithInvalidBaseFinal_NoMember(p: DeriveFromFinal*) -> i32 {
-  // CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE+3]]:10: error: name `b` not found [NameNotFound]
+  // CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE+3]]:10: error: member name `b` not found in `DeriveFromFinal` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   return (*p).b;
   // CHECK:STDERR:          ^~~~~~
   return (*p).b;

+ 1 - 1
toolchain/check/testdata/class/fail_unknown_member.carbon

@@ -14,7 +14,7 @@ class Class {
 
 fn G(c: Class) -> i32 {
   // TODO: Mention the scope in which we looked for the name.
-  // CHECK:STDERR: fail_unknown_member.carbon:[[@LINE+3]]:10: error: name `something` not found [NameNotFound]
+  // CHECK:STDERR: fail_unknown_member.carbon:[[@LINE+3]]:10: error: member name `something` not found in `Class` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   return c.something;
   // CHECK:STDERR:          ^~~~~~~~~~~
   return c.something;

+ 701 - 0
toolchain/check/testdata/class/generic/member_lookup.carbon

@@ -0,0 +1,701 @@
+// 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/class/generic/member_lookup.carbon
+// TIP: To dump output, run:
+// TIP:   bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/member_lookup.carbon
+
+// --- member_access.carbon
+
+library "[[@TEST_NAME]]";
+
+base class Base(T:! type) {
+  var b: T;
+}
+
+class Derived(T:! type) {
+  extend base: Base(T);
+  var d: T;
+}
+
+fn AccessDerived[T:! type](x: Derived(T)) -> T {
+  return x.d;
+}
+
+fn AccessBase[T:! type](x: Derived(T)) -> T {
+  return x.b;
+}
+
+fn AccessConcrete(x: Derived(i32)) -> i32 {
+  return x.b;
+}
+
+// --- fail_no_member.carbon
+
+library "[[@TEST_NAME]]";
+
+base class Base(T:! type) {
+  var b: T;
+}
+
+class Derived(T:! type) {
+  extend base: Base(T);
+  var d: T;
+}
+
+fn AccessMissingBase[T:! type](x: Base(T)) -> T {
+  // CHECK:STDERR: fail_no_member.carbon:[[@LINE+4]]:10: error: member name `nonesuch` not found in `Base(T)` [MemberNameNotFoundInScope]
+  // CHECK:STDERR:   return x.nonesuch;
+  // CHECK:STDERR:          ^~~~~~~~~~
+  // CHECK:STDERR:
+  return x.nonesuch;
+}
+
+fn AccessMissingDerived[T:! type](x: Derived(T)) -> T {
+  // CHECK:STDERR: fail_no_member.carbon:[[@LINE+4]]:10: error: member name `nonesuch` not found in `Derived(T)` [MemberNameNotFoundInScope]
+  // CHECK:STDERR:   return x.nonesuch;
+  // CHECK:STDERR:          ^~~~~~~~~~
+  // CHECK:STDERR:
+  return x.nonesuch;
+}
+
+fn AccessMissingConcrete(x: Derived(i32)) -> i32 {
+  // CHECK:STDERR: fail_no_member.carbon:[[@LINE+3]]:10: error: member name `nonesuch` not found in `Derived(i32)` [MemberNameNotFoundInScope]
+  // CHECK:STDERR:   return x.nonesuch;
+  // CHECK:STDERR:          ^~~~~~~~~~
+  return x.nonesuch;
+}
+
+// CHECK:STDOUT: --- member_access.carbon
+// CHECK:STDOUT:
+// CHECK:STDOUT: constants {
+// CHECK:STDOUT:   %T: type = bind_symbolic_name T, 0 [symbolic]
+// CHECK:STDOUT:   %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
+// CHECK:STDOUT:   %Base.type: type = generic_class_type @Base [template]
+// CHECK:STDOUT:   %Base.generic: %Base.type = struct_value () [template]
+// CHECK:STDOUT:   %Base.1: type = class_type @Base, @Base(%T) [symbolic]
+// CHECK:STDOUT:   %Base.elem.1: type = unbound_element_type %Base.1, %T [symbolic]
+// CHECK:STDOUT:   %struct_type.b.1: type = struct_type {.b: %T} [symbolic]
+// CHECK:STDOUT:   %complete_type.1: <witness> = complete_type_witness %struct_type.b.1 [symbolic]
+// CHECK:STDOUT:   %Derived.type: type = generic_class_type @Derived [template]
+// CHECK:STDOUT:   %Derived.generic: %Derived.type = struct_value () [template]
+// CHECK:STDOUT:   %Derived.1: type = class_type @Derived, @Derived(%T) [symbolic]
+// CHECK:STDOUT:   %Derived.elem.1: type = unbound_element_type %Derived.1, %Base.1 [symbolic]
+// CHECK:STDOUT:   %Derived.elem.2: type = unbound_element_type %Derived.1, %T [symbolic]
+// CHECK:STDOUT:   %struct_type.base.d.1: type = struct_type {.base: %Base.1, .d: %T} [symbolic]
+// CHECK:STDOUT:   %complete_type.2: <witness> = complete_type_witness %struct_type.base.d.1 [symbolic]
+// CHECK:STDOUT:   %AccessDerived.type: type = fn_type @AccessDerived [template]
+// CHECK:STDOUT:   %AccessDerived: %AccessDerived.type = struct_value () [template]
+// CHECK:STDOUT:   %AccessBase.type: type = fn_type @AccessBase [template]
+// CHECK:STDOUT:   %AccessBase: %AccessBase.type = struct_value () [template]
+// CHECK:STDOUT:   %int_32: Core.IntLiteral = int_value 32 [template]
+// CHECK:STDOUT:   %Int.type: type = fn_type @Int [template]
+// CHECK:STDOUT:   %Int: %Int.type = struct_value () [template]
+// CHECK:STDOUT:   %i32: type = int_type signed, %int_32 [template]
+// CHECK:STDOUT:   %Derived.2: type = class_type @Derived, @Derived(%i32) [template]
+// CHECK:STDOUT:   %AccessConcrete.type: type = fn_type @AccessConcrete [template]
+// CHECK:STDOUT:   %AccessConcrete: %AccessConcrete.type = struct_value () [template]
+// CHECK:STDOUT:   %Base.2: type = class_type @Base, @Base(%i32) [template]
+// CHECK:STDOUT:   %Derived.elem.3: type = unbound_element_type %Derived.2, %Base.2 [template]
+// CHECK:STDOUT:   %Derived.elem.4: type = unbound_element_type %Derived.2, %i32 [template]
+// CHECK:STDOUT:   %struct_type.base.d.3: type = struct_type {.base: %Base.2, .d: %i32} [template]
+// CHECK:STDOUT:   %complete_type.3: <witness> = complete_type_witness %struct_type.base.d.3 [template]
+// CHECK:STDOUT:   %Base.elem.2: type = unbound_element_type %Base.2, %i32 [template]
+// CHECK:STDOUT:   %struct_type.b.2: type = struct_type {.b: %i32} [template]
+// CHECK:STDOUT:   %complete_type.4: <witness> = complete_type_witness %struct_type.b.2 [template]
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: imports {
+// CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
+// CHECK:STDOUT:     .Int = %import_ref
+// CHECK:STDOUT:     import Core//prelude
+// CHECK:STDOUT:     import Core//prelude/...
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace [template] {
+// CHECK:STDOUT:     .Core = imports.%Core
+// CHECK:STDOUT:     .Base = %Base.decl
+// CHECK:STDOUT:     .Derived = %Derived.decl
+// CHECK:STDOUT:     .AccessDerived = %AccessDerived.decl
+// CHECK:STDOUT:     .AccessBase = %AccessBase.decl
+// CHECK:STDOUT:     .AccessConcrete = %AccessConcrete.decl
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Core.import = import Core
+// CHECK:STDOUT:   %Base.decl: %Base.type = class_decl @Base [template = constants.%Base.generic] {
+// CHECK:STDOUT:     %T.patt.loc4_17.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc4_17.1, runtime_param<invalid> [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)]
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc4_17.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_17.2 (constants.%T)]
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Derived.decl: %Derived.type = class_decl @Derived [template = constants.%Derived.generic] {
+// CHECK:STDOUT:     %T.patt.loc8_15.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc8_15.1, runtime_param<invalid> [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc8_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessDerived.decl: %AccessDerived.type = fn_decl @AccessDerived [template = constants.%AccessDerived] {
+// CHECK:STDOUT:     %T.patt.loc13_18.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_18.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc13_18.1, runtime_param<invalid> [symbolic = %T.patt.loc13_18.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %x.patt: @AccessDerived.%Derived.loc13_40.2 (%Derived.1) = binding_pattern x
+// CHECK:STDOUT:     %x.param_patt: @AccessDerived.%Derived.loc13_40.2 (%Derived.1) = value_param_pattern %x.patt, runtime_param0
+// CHECK:STDOUT:     %return.patt: @AccessDerived.%T.loc13_18.2 (%T) = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: @AccessDerived.%T.loc13_18.2 (%T) = out_param_pattern %return.patt, runtime_param1
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Derived.ref: %Derived.type = name_ref Derived, file.%Derived.decl [template = constants.%Derived.generic]
+// CHECK:STDOUT:     %T.ref.loc13_39: type = name_ref T, %T.loc13_18.1 [symbolic = %T.loc13_18.2 (constants.%T)]
+// CHECK:STDOUT:     %Derived.loc13_40.1: type = class_type @Derived, @Derived(constants.%T) [symbolic = %Derived.loc13_40.2 (constants.%Derived.1)]
+// CHECK:STDOUT:     %T.ref.loc13_46: type = name_ref T, %T.loc13_18.1 [symbolic = %T.loc13_18.2 (constants.%T)]
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc13_18.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc13_18.2 (constants.%T)]
+// CHECK:STDOUT:     %x.param: @AccessDerived.%Derived.loc13_40.2 (%Derived.1) = value_param runtime_param0
+// CHECK:STDOUT:     %x: @AccessDerived.%Derived.loc13_40.2 (%Derived.1) = bind_name x, %x.param
+// CHECK:STDOUT:     %return.param: ref @AccessDerived.%T.loc13_18.2 (%T) = out_param runtime_param1
+// CHECK:STDOUT:     %return: ref @AccessDerived.%T.loc13_18.2 (%T) = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessBase.decl: %AccessBase.type = fn_decl @AccessBase [template = constants.%AccessBase] {
+// CHECK:STDOUT:     %T.patt.loc17_15.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc17_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc17_15.1, runtime_param<invalid> [symbolic = %T.patt.loc17_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %x.patt: @AccessBase.%Derived.loc17_37.2 (%Derived.1) = binding_pattern x
+// CHECK:STDOUT:     %x.param_patt: @AccessBase.%Derived.loc17_37.2 (%Derived.1) = value_param_pattern %x.patt, runtime_param0
+// CHECK:STDOUT:     %return.patt: @AccessBase.%T.loc17_15.2 (%T) = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: @AccessBase.%T.loc17_15.2 (%T) = out_param_pattern %return.patt, runtime_param1
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Derived.ref: %Derived.type = name_ref Derived, file.%Derived.decl [template = constants.%Derived.generic]
+// CHECK:STDOUT:     %T.ref.loc17_36: type = name_ref T, %T.loc17_15.1 [symbolic = %T.loc17_15.2 (constants.%T)]
+// CHECK:STDOUT:     %Derived.loc17_37.1: type = class_type @Derived, @Derived(constants.%T) [symbolic = %Derived.loc17_37.2 (constants.%Derived.1)]
+// CHECK:STDOUT:     %T.ref.loc17_43: type = name_ref T, %T.loc17_15.1 [symbolic = %T.loc17_15.2 (constants.%T)]
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc17_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc17_15.2 (constants.%T)]
+// CHECK:STDOUT:     %x.param: @AccessBase.%Derived.loc17_37.2 (%Derived.1) = value_param runtime_param0
+// CHECK:STDOUT:     %x: @AccessBase.%Derived.loc17_37.2 (%Derived.1) = bind_name x, %x.param
+// CHECK:STDOUT:     %return.param: ref @AccessBase.%T.loc17_15.2 (%T) = out_param runtime_param1
+// CHECK:STDOUT:     %return: ref @AccessBase.%T.loc17_15.2 (%T) = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessConcrete.decl: %AccessConcrete.type = fn_decl @AccessConcrete [template = constants.%AccessConcrete] {
+// CHECK:STDOUT:     %x.patt: %Derived.2 = binding_pattern x
+// CHECK:STDOUT:     %x.param_patt: %Derived.2 = value_param_pattern %x.patt, runtime_param0
+// CHECK:STDOUT:     %return.patt: %i32 = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Derived.ref: %Derived.type = name_ref Derived, file.%Derived.decl [template = constants.%Derived.generic]
+// CHECK:STDOUT:     %int_32.loc21_30: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc21_30: init type = call constants.%Int(%int_32.loc21_30) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc21_33.1: type = value_of_initializer %int.make_type_signed.loc21_30 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc21_33.2: type = converted %int.make_type_signed.loc21_30, %.loc21_33.1 [template = constants.%i32]
+// CHECK:STDOUT:     %Derived: type = class_type @Derived, @Derived(constants.%i32) [template = constants.%Derived.2]
+// CHECK:STDOUT:     %int_32.loc21_39: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc21_39: init type = call constants.%Int(%int_32.loc21_39) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc21_39.1: type = value_of_initializer %int.make_type_signed.loc21_39 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc21_39.2: type = converted %int.make_type_signed.loc21_39, %.loc21_39.1 [template = constants.%i32]
+// CHECK:STDOUT:     %x.param: %Derived.2 = value_param runtime_param0
+// CHECK:STDOUT:     %x: %Derived.2 = bind_name x, %x.param
+// CHECK:STDOUT:     %return.param: ref %i32 = out_param runtime_param1
+// CHECK:STDOUT:     %return: ref %i32 = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic class @Base(%T.loc4_17.1: type) {
+// CHECK:STDOUT:   %T.loc4_17.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_17.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc4_17.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base: type = class_type @Base, @Base(%T.loc4_17.2) [symbolic = %Base (constants.%Base.1)]
+// CHECK:STDOUT:   %Base.elem: type = unbound_element_type @Base.%Base (%Base.1), @Base.%T.loc4_17.2 (%T) [symbolic = %Base.elem (constants.%Base.elem.1)]
+// CHECK:STDOUT:   %struct_type.b: type = struct_type {.b: @Base.%T.loc4_17.2 (%T)} [symbolic = %struct_type.b (constants.%struct_type.b.1)]
+// CHECK:STDOUT:   %complete_type.loc6_1.2: <witness> = complete_type_witness @Base.%struct_type.b (%struct_type.b.1) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   class {
+// CHECK:STDOUT:     %T.ref: type = name_ref T, %T.loc4_17.1 [symbolic = %T.loc4_17.2 (constants.%T)]
+// CHECK:STDOUT:     %.loc5: @Base.%Base.elem (%Base.elem.1) = field_decl b, element0 [template]
+// CHECK:STDOUT:     %complete_type.loc6_1.1: <witness> = complete_type_witness %struct_type.b.1 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   !members:
+// CHECK:STDOUT:     .Self = constants.%Base.1
+// CHECK:STDOUT:     .b = %.loc5
+// CHECK:STDOUT:     complete_type_witness = %complete_type.loc6_1.1
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic class @Derived(%T.loc8_15.1: type) {
+// CHECK:STDOUT:   %T.loc8_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc8_15.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base.loc9_22.2: type = class_type @Base, @Base(%T.loc8_15.2) [symbolic = %Base.loc9_22.2 (constants.%Base.1)]
+// CHECK:STDOUT:   %Derived: type = class_type @Derived, @Derived(%T.loc8_15.2) [symbolic = %Derived (constants.%Derived.1)]
+// CHECK:STDOUT:   %Derived.elem.loc9: type = unbound_element_type @Derived.%Derived (%Derived.1), @Derived.%Base.loc9_22.2 (%Base.1) [symbolic = %Derived.elem.loc9 (constants.%Derived.elem.1)]
+// CHECK:STDOUT:   %Derived.elem.loc10: type = unbound_element_type @Derived.%Derived (%Derived.1), @Derived.%T.loc8_15.2 (%T) [symbolic = %Derived.elem.loc10 (constants.%Derived.elem.2)]
+// CHECK:STDOUT:   %struct_type.base.d: type = struct_type {.base: @Derived.%Base.loc9_22.2 (%Base.1), .d: @Derived.%T.loc8_15.2 (%T)} [symbolic = %struct_type.base.d (constants.%struct_type.base.d.1)]
+// CHECK:STDOUT:   %complete_type.loc11_1.2: <witness> = complete_type_witness @Derived.%struct_type.base.d (%struct_type.base.d.1) [symbolic = %complete_type.loc11_1.2 (constants.%complete_type.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   class {
+// CHECK:STDOUT:     %Base.ref: %Base.type = name_ref Base, file.%Base.decl [template = constants.%Base.generic]
+// CHECK:STDOUT:     %T.ref.loc9: type = name_ref T, %T.loc8_15.1 [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:     %Base.loc9_22.1: type = class_type @Base, @Base(constants.%T) [symbolic = %Base.loc9_22.2 (constants.%Base.1)]
+// CHECK:STDOUT:     %.loc9: @Derived.%Derived.elem.loc9 (%Derived.elem.1) = base_decl %Base.loc9_22.1, element0 [template]
+// CHECK:STDOUT:     %T.ref.loc10: type = name_ref T, %T.loc8_15.1 [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:     %.loc10: @Derived.%Derived.elem.loc10 (%Derived.elem.2) = field_decl d, element1 [template]
+// CHECK:STDOUT:     %complete_type.loc11_1.1: <witness> = complete_type_witness %struct_type.base.d.1 [symbolic = %complete_type.loc11_1.2 (constants.%complete_type.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   !members:
+// CHECK:STDOUT:     .Self = constants.%Derived.1
+// CHECK:STDOUT:     .base = %.loc9
+// CHECK:STDOUT:     .d = %.loc10
+// CHECK:STDOUT:     extend %Base.loc9_22.1
+// CHECK:STDOUT:     complete_type_witness = %complete_type.loc11_1.1
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessDerived(%T.loc13_18.1: type) {
+// CHECK:STDOUT:   %T.loc13_18.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc13_18.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc13_18.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_18.2 (constants.%T.patt)]
+// CHECK:STDOUT:   %Derived.loc13_40.2: type = class_type @Derived, @Derived(%T.loc13_18.2) [symbolic = %Derived.loc13_40.2 (constants.%Derived.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Derived.elem: type = unbound_element_type @AccessDerived.%Derived.loc13_40.2 (%Derived.1), @AccessDerived.%T.loc13_18.2 (%T) [symbolic = %Derived.elem (constants.%Derived.elem.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn[%T.param_patt: type](%x.param_patt: @AccessDerived.%Derived.loc13_40.2 (%Derived.1)) -> @AccessDerived.%T.loc13_18.2 (%T) {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %x.ref: @AccessDerived.%Derived.loc13_40.2 (%Derived.1) = name_ref x, %x
+// CHECK:STDOUT:     %d.ref: @AccessDerived.%Derived.elem (%Derived.elem.2) = name_ref d, @Derived.%.loc10 [template = @Derived.%.loc10]
+// CHECK:STDOUT:     %.loc14_11.1: ref @AccessDerived.%T.loc13_18.2 (%T) = class_element_access %x.ref, element1
+// CHECK:STDOUT:     %.loc14_11.2: @AccessDerived.%T.loc13_18.2 (%T) = bind_value %.loc14_11.1
+// CHECK:STDOUT:     return %.loc14_11.2
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessBase(%T.loc17_15.1: type) {
+// CHECK:STDOUT:   %T.loc17_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc17_15.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc17_15.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc17_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:   %Derived.loc17_37.2: type = class_type @Derived, @Derived(%T.loc17_15.2) [symbolic = %Derived.loc17_37.2 (constants.%Derived.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base: type = class_type @Base, @Base(%T.loc17_15.2) [symbolic = %Base (constants.%Base.1)]
+// CHECK:STDOUT:   %Base.elem: type = unbound_element_type @AccessBase.%Base (%Base.1), @AccessBase.%T.loc17_15.2 (%T) [symbolic = %Base.elem (constants.%Base.elem.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn[%T.param_patt: type](%x.param_patt: @AccessBase.%Derived.loc17_37.2 (%Derived.1)) -> @AccessBase.%T.loc17_15.2 (%T) {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %x.ref: @AccessBase.%Derived.loc17_37.2 (%Derived.1) = name_ref x, %x
+// CHECK:STDOUT:     %b.ref: @AccessBase.%Base.elem (%Base.elem.1) = name_ref b, @Base.%.loc5 [template = @Base.%.loc5]
+// CHECK:STDOUT:     %.loc18_11.1: ref @AccessBase.%Base (%Base.1) = class_element_access %x.ref, element0
+// CHECK:STDOUT:     %.loc18_11.2: ref @AccessBase.%Base (%Base.1) = converted %x.ref, %.loc18_11.1
+// CHECK:STDOUT:     %.loc18_11.3: ref @AccessBase.%T.loc17_15.2 (%T) = class_element_access %.loc18_11.2, element0
+// CHECK:STDOUT:     %.loc18_11.4: @AccessBase.%T.loc17_15.2 (%T) = bind_value %.loc18_11.3
+// CHECK:STDOUT:     return %.loc18_11.4
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: fn @AccessConcrete(%x.param_patt: %Derived.2) -> %i32 {
+// CHECK:STDOUT: !entry:
+// CHECK:STDOUT:   %x.ref: %Derived.2 = name_ref x, %x
+// CHECK:STDOUT:   %b.ref: %Base.elem.2 = name_ref b, @Base.%.loc5 [template = @Base.%.loc5]
+// CHECK:STDOUT:   %.loc22_11.1: ref %Base.2 = class_element_access %x.ref, element0
+// CHECK:STDOUT:   %.loc22_11.2: ref %Base.2 = converted %x.ref, %.loc22_11.1
+// CHECK:STDOUT:   %.loc22_11.3: ref %i32 = class_element_access %.loc22_11.2, element0
+// CHECK:STDOUT:   %.loc22_11.4: %i32 = bind_value %.loc22_11.3
+// CHECK:STDOUT:   return %.loc22_11.4
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(constants.%T) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base => constants.%Base.1
+// CHECK:STDOUT:   %Base.elem => constants.%Base.elem.1
+// CHECK:STDOUT:   %struct_type.b => constants.%struct_type.b.1
+// CHECK:STDOUT:   %complete_type.loc6_1.2 => constants.%complete_type.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(%T.loc4_17.2) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(constants.%T) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base.loc9_22.2 => constants.%Base.1
+// CHECK:STDOUT:   %Derived => constants.%Derived.1
+// CHECK:STDOUT:   %Derived.elem.loc9 => constants.%Derived.elem.1
+// CHECK:STDOUT:   %Derived.elem.loc10 => constants.%Derived.elem.2
+// CHECK:STDOUT:   %struct_type.base.d => constants.%struct_type.base.d.1
+// CHECK:STDOUT:   %complete_type.loc11_1.2 => constants.%complete_type.2
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(@Derived.%T.loc8_15.2) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(%T.loc8_15.2) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(@AccessDerived.%T.loc13_18.2) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessDerived(constants.%T) {
+// CHECK:STDOUT:   %T.loc13_18.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc13_18.2 => constants.%T
+// CHECK:STDOUT:   %Derived.loc13_40.2 => constants.%Derived.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(@AccessBase.%T.loc17_15.2) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessBase(constants.%T) {
+// CHECK:STDOUT:   %T.loc17_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc17_15.2 => constants.%T
+// CHECK:STDOUT:   %Derived.loc17_37.2 => constants.%Derived.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(@AccessBase.%T.loc17_15.2) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(constants.%i32) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%i32
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%i32
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base.loc9_22.2 => constants.%Base.2
+// CHECK:STDOUT:   %Derived => constants.%Derived.2
+// CHECK:STDOUT:   %Derived.elem.loc9 => constants.%Derived.elem.3
+// CHECK:STDOUT:   %Derived.elem.loc10 => constants.%Derived.elem.4
+// CHECK:STDOUT:   %struct_type.base.d => constants.%struct_type.base.d.3
+// CHECK:STDOUT:   %complete_type.loc11_1.2 => constants.%complete_type.3
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(constants.%i32) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%i32
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%i32
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base => constants.%Base.2
+// CHECK:STDOUT:   %Base.elem => constants.%Base.elem.2
+// CHECK:STDOUT:   %struct_type.b => constants.%struct_type.b.2
+// CHECK:STDOUT:   %complete_type.loc6_1.2 => constants.%complete_type.4
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: --- fail_no_member.carbon
+// CHECK:STDOUT:
+// CHECK:STDOUT: constants {
+// CHECK:STDOUT:   %T: type = bind_symbolic_name T, 0 [symbolic]
+// CHECK:STDOUT:   %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
+// CHECK:STDOUT:   %Base.type: type = generic_class_type @Base [template]
+// CHECK:STDOUT:   %Base.generic: %Base.type = struct_value () [template]
+// CHECK:STDOUT:   %Base.1: type = class_type @Base, @Base(%T) [symbolic]
+// CHECK:STDOUT:   %Base.elem.1: type = unbound_element_type %Base.1, %T [symbolic]
+// CHECK:STDOUT:   %struct_type.b.1: type = struct_type {.b: %T} [symbolic]
+// CHECK:STDOUT:   %complete_type.1: <witness> = complete_type_witness %struct_type.b.1 [symbolic]
+// CHECK:STDOUT:   %Derived.type: type = generic_class_type @Derived [template]
+// CHECK:STDOUT:   %Derived.generic: %Derived.type = struct_value () [template]
+// CHECK:STDOUT:   %Derived.1: type = class_type @Derived, @Derived(%T) [symbolic]
+// CHECK:STDOUT:   %Derived.elem.1: type = unbound_element_type %Derived.1, %Base.1 [symbolic]
+// CHECK:STDOUT:   %Derived.elem.2: type = unbound_element_type %Derived.1, %T [symbolic]
+// CHECK:STDOUT:   %struct_type.base.d.1: type = struct_type {.base: %Base.1, .d: %T} [symbolic]
+// CHECK:STDOUT:   %complete_type.2: <witness> = complete_type_witness %struct_type.base.d.1 [symbolic]
+// CHECK:STDOUT:   %AccessMissingBase.type: type = fn_type @AccessMissingBase [template]
+// CHECK:STDOUT:   %AccessMissingBase: %AccessMissingBase.type = struct_value () [template]
+// CHECK:STDOUT:   %AccessMissingDerived.type: type = fn_type @AccessMissingDerived [template]
+// CHECK:STDOUT:   %AccessMissingDerived: %AccessMissingDerived.type = struct_value () [template]
+// CHECK:STDOUT:   %int_32: Core.IntLiteral = int_value 32 [template]
+// CHECK:STDOUT:   %Int.type: type = fn_type @Int [template]
+// CHECK:STDOUT:   %Int: %Int.type = struct_value () [template]
+// CHECK:STDOUT:   %i32: type = int_type signed, %int_32 [template]
+// CHECK:STDOUT:   %Derived.2: type = class_type @Derived, @Derived(%i32) [template]
+// CHECK:STDOUT:   %AccessMissingConcrete.type: type = fn_type @AccessMissingConcrete [template]
+// CHECK:STDOUT:   %AccessMissingConcrete: %AccessMissingConcrete.type = struct_value () [template]
+// CHECK:STDOUT:   %Base.2: type = class_type @Base, @Base(%i32) [template]
+// CHECK:STDOUT:   %Derived.elem.3: type = unbound_element_type %Derived.2, %Base.2 [template]
+// CHECK:STDOUT:   %Derived.elem.4: type = unbound_element_type %Derived.2, %i32 [template]
+// CHECK:STDOUT:   %struct_type.base.d.3: type = struct_type {.base: %Base.2, .d: %i32} [template]
+// CHECK:STDOUT:   %complete_type.3: <witness> = complete_type_witness %struct_type.base.d.3 [template]
+// CHECK:STDOUT:   %Base.elem.2: type = unbound_element_type %Base.2, %i32 [template]
+// CHECK:STDOUT:   %struct_type.b.2: type = struct_type {.b: %i32} [template]
+// CHECK:STDOUT:   %complete_type.4: <witness> = complete_type_witness %struct_type.b.2 [template]
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: imports {
+// CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
+// CHECK:STDOUT:     .Int = %import_ref
+// CHECK:STDOUT:     import Core//prelude
+// CHECK:STDOUT:     import Core//prelude/...
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace [template] {
+// CHECK:STDOUT:     .Core = imports.%Core
+// CHECK:STDOUT:     .Base = %Base.decl
+// CHECK:STDOUT:     .Derived = %Derived.decl
+// CHECK:STDOUT:     .AccessMissingBase = %AccessMissingBase.decl
+// CHECK:STDOUT:     .AccessMissingDerived = %AccessMissingDerived.decl
+// CHECK:STDOUT:     .AccessMissingConcrete = %AccessMissingConcrete.decl
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Core.import = import Core
+// CHECK:STDOUT:   %Base.decl: %Base.type = class_decl @Base [template = constants.%Base.generic] {
+// CHECK:STDOUT:     %T.patt.loc4_17.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc4_17.1, runtime_param<invalid> [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)]
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc4_17.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_17.2 (constants.%T)]
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Derived.decl: %Derived.type = class_decl @Derived [template = constants.%Derived.generic] {
+// CHECK:STDOUT:     %T.patt.loc8_15.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc8_15.1, runtime_param<invalid> [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc8_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessMissingBase.decl: %AccessMissingBase.type = fn_decl @AccessMissingBase [template = constants.%AccessMissingBase] {
+// CHECK:STDOUT:     %T.patt.loc13_22.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_22.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc13_22.1, runtime_param<invalid> [symbolic = %T.patt.loc13_22.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %x.patt: @AccessMissingBase.%Base.loc13_41.2 (%Base.1) = binding_pattern x
+// CHECK:STDOUT:     %x.param_patt: @AccessMissingBase.%Base.loc13_41.2 (%Base.1) = value_param_pattern %x.patt, runtime_param0
+// CHECK:STDOUT:     %return.patt: @AccessMissingBase.%T.loc13_22.2 (%T) = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: @AccessMissingBase.%T.loc13_22.2 (%T) = out_param_pattern %return.patt, runtime_param1
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Base.ref: %Base.type = name_ref Base, file.%Base.decl [template = constants.%Base.generic]
+// CHECK:STDOUT:     %T.ref.loc13_40: type = name_ref T, %T.loc13_22.1 [symbolic = %T.loc13_22.2 (constants.%T)]
+// CHECK:STDOUT:     %Base.loc13_41.1: type = class_type @Base, @Base(constants.%T) [symbolic = %Base.loc13_41.2 (constants.%Base.1)]
+// CHECK:STDOUT:     %T.ref.loc13_47: type = name_ref T, %T.loc13_22.1 [symbolic = %T.loc13_22.2 (constants.%T)]
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc13_22.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc13_22.2 (constants.%T)]
+// CHECK:STDOUT:     %x.param: @AccessMissingBase.%Base.loc13_41.2 (%Base.1) = value_param runtime_param0
+// CHECK:STDOUT:     %x: @AccessMissingBase.%Base.loc13_41.2 (%Base.1) = bind_name x, %x.param
+// CHECK:STDOUT:     %return.param: ref @AccessMissingBase.%T.loc13_22.2 (%T) = out_param runtime_param1
+// CHECK:STDOUT:     %return: ref @AccessMissingBase.%T.loc13_22.2 (%T) = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessMissingDerived.decl: %AccessMissingDerived.type = fn_decl @AccessMissingDerived [template = constants.%AccessMissingDerived] {
+// CHECK:STDOUT:     %T.patt.loc21_25.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_25.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc21_25.1, runtime_param<invalid> [symbolic = %T.patt.loc21_25.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %x.patt: @AccessMissingDerived.%Derived.loc21_47.2 (%Derived.1) = binding_pattern x
+// CHECK:STDOUT:     %x.param_patt: @AccessMissingDerived.%Derived.loc21_47.2 (%Derived.1) = value_param_pattern %x.patt, runtime_param0
+// CHECK:STDOUT:     %return.patt: @AccessMissingDerived.%T.loc21_25.2 (%T) = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: @AccessMissingDerived.%T.loc21_25.2 (%T) = out_param_pattern %return.patt, runtime_param1
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Derived.ref: %Derived.type = name_ref Derived, file.%Derived.decl [template = constants.%Derived.generic]
+// CHECK:STDOUT:     %T.ref.loc21_46: type = name_ref T, %T.loc21_25.1 [symbolic = %T.loc21_25.2 (constants.%T)]
+// CHECK:STDOUT:     %Derived.loc21_47.1: type = class_type @Derived, @Derived(constants.%T) [symbolic = %Derived.loc21_47.2 (constants.%Derived.1)]
+// CHECK:STDOUT:     %T.ref.loc21_53: type = name_ref T, %T.loc21_25.1 [symbolic = %T.loc21_25.2 (constants.%T)]
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc21_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc21_25.2 (constants.%T)]
+// CHECK:STDOUT:     %x.param: @AccessMissingDerived.%Derived.loc21_47.2 (%Derived.1) = value_param runtime_param0
+// CHECK:STDOUT:     %x: @AccessMissingDerived.%Derived.loc21_47.2 (%Derived.1) = bind_name x, %x.param
+// CHECK:STDOUT:     %return.param: ref @AccessMissingDerived.%T.loc21_25.2 (%T) = out_param runtime_param1
+// CHECK:STDOUT:     %return: ref @AccessMissingDerived.%T.loc21_25.2 (%T) = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessMissingConcrete.decl: %AccessMissingConcrete.type = fn_decl @AccessMissingConcrete [template = constants.%AccessMissingConcrete] {
+// CHECK:STDOUT:     %x.patt: %Derived.2 = binding_pattern x
+// CHECK:STDOUT:     %x.param_patt: %Derived.2 = value_param_pattern %x.patt, runtime_param0
+// CHECK:STDOUT:     %return.patt: %i32 = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Derived.ref: %Derived.type = name_ref Derived, file.%Derived.decl [template = constants.%Derived.generic]
+// CHECK:STDOUT:     %int_32.loc29_37: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc29_37: init type = call constants.%Int(%int_32.loc29_37) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc29_40.1: type = value_of_initializer %int.make_type_signed.loc29_37 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc29_40.2: type = converted %int.make_type_signed.loc29_37, %.loc29_40.1 [template = constants.%i32]
+// CHECK:STDOUT:     %Derived: type = class_type @Derived, @Derived(constants.%i32) [template = constants.%Derived.2]
+// CHECK:STDOUT:     %int_32.loc29_46: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc29_46: init type = call constants.%Int(%int_32.loc29_46) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc29_46.1: type = value_of_initializer %int.make_type_signed.loc29_46 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc29_46.2: type = converted %int.make_type_signed.loc29_46, %.loc29_46.1 [template = constants.%i32]
+// CHECK:STDOUT:     %x.param: %Derived.2 = value_param runtime_param0
+// CHECK:STDOUT:     %x: %Derived.2 = bind_name x, %x.param
+// CHECK:STDOUT:     %return.param: ref %i32 = out_param runtime_param1
+// CHECK:STDOUT:     %return: ref %i32 = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic class @Base(%T.loc4_17.1: type) {
+// CHECK:STDOUT:   %T.loc4_17.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_17.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc4_17.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base: type = class_type @Base, @Base(%T.loc4_17.2) [symbolic = %Base (constants.%Base.1)]
+// CHECK:STDOUT:   %Base.elem: type = unbound_element_type @Base.%Base (%Base.1), @Base.%T.loc4_17.2 (%T) [symbolic = %Base.elem (constants.%Base.elem.1)]
+// CHECK:STDOUT:   %struct_type.b: type = struct_type {.b: @Base.%T.loc4_17.2 (%T)} [symbolic = %struct_type.b (constants.%struct_type.b.1)]
+// CHECK:STDOUT:   %complete_type.loc6_1.2: <witness> = complete_type_witness @Base.%struct_type.b (%struct_type.b.1) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   class {
+// CHECK:STDOUT:     %T.ref: type = name_ref T, %T.loc4_17.1 [symbolic = %T.loc4_17.2 (constants.%T)]
+// CHECK:STDOUT:     %.loc5: @Base.%Base.elem (%Base.elem.1) = field_decl b, element0 [template]
+// CHECK:STDOUT:     %complete_type.loc6_1.1: <witness> = complete_type_witness %struct_type.b.1 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   !members:
+// CHECK:STDOUT:     .Self = constants.%Base.1
+// CHECK:STDOUT:     .b = %.loc5
+// CHECK:STDOUT:     complete_type_witness = %complete_type.loc6_1.1
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic class @Derived(%T.loc8_15.1: type) {
+// CHECK:STDOUT:   %T.loc8_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc8_15.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base.loc9_22.2: type = class_type @Base, @Base(%T.loc8_15.2) [symbolic = %Base.loc9_22.2 (constants.%Base.1)]
+// CHECK:STDOUT:   %Derived: type = class_type @Derived, @Derived(%T.loc8_15.2) [symbolic = %Derived (constants.%Derived.1)]
+// CHECK:STDOUT:   %Derived.elem.loc9: type = unbound_element_type @Derived.%Derived (%Derived.1), @Derived.%Base.loc9_22.2 (%Base.1) [symbolic = %Derived.elem.loc9 (constants.%Derived.elem.1)]
+// CHECK:STDOUT:   %Derived.elem.loc10: type = unbound_element_type @Derived.%Derived (%Derived.1), @Derived.%T.loc8_15.2 (%T) [symbolic = %Derived.elem.loc10 (constants.%Derived.elem.2)]
+// CHECK:STDOUT:   %struct_type.base.d: type = struct_type {.base: @Derived.%Base.loc9_22.2 (%Base.1), .d: @Derived.%T.loc8_15.2 (%T)} [symbolic = %struct_type.base.d (constants.%struct_type.base.d.1)]
+// CHECK:STDOUT:   %complete_type.loc11_1.2: <witness> = complete_type_witness @Derived.%struct_type.base.d (%struct_type.base.d.1) [symbolic = %complete_type.loc11_1.2 (constants.%complete_type.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   class {
+// CHECK:STDOUT:     %Base.ref: %Base.type = name_ref Base, file.%Base.decl [template = constants.%Base.generic]
+// CHECK:STDOUT:     %T.ref.loc9: type = name_ref T, %T.loc8_15.1 [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:     %Base.loc9_22.1: type = class_type @Base, @Base(constants.%T) [symbolic = %Base.loc9_22.2 (constants.%Base.1)]
+// CHECK:STDOUT:     %.loc9: @Derived.%Derived.elem.loc9 (%Derived.elem.1) = base_decl %Base.loc9_22.1, element0 [template]
+// CHECK:STDOUT:     %T.ref.loc10: type = name_ref T, %T.loc8_15.1 [symbolic = %T.loc8_15.2 (constants.%T)]
+// CHECK:STDOUT:     %.loc10: @Derived.%Derived.elem.loc10 (%Derived.elem.2) = field_decl d, element1 [template]
+// CHECK:STDOUT:     %complete_type.loc11_1.1: <witness> = complete_type_witness %struct_type.base.d.1 [symbolic = %complete_type.loc11_1.2 (constants.%complete_type.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   !members:
+// CHECK:STDOUT:     .Self = constants.%Derived.1
+// CHECK:STDOUT:     .base = %.loc9
+// CHECK:STDOUT:     .d = %.loc10
+// CHECK:STDOUT:     extend %Base.loc9_22.1
+// CHECK:STDOUT:     complete_type_witness = %complete_type.loc11_1.1
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessMissingBase(%T.loc13_22.1: type) {
+// CHECK:STDOUT:   %T.loc13_22.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc13_22.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc13_22.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_22.2 (constants.%T.patt)]
+// CHECK:STDOUT:   %Base.loc13_41.2: type = class_type @Base, @Base(%T.loc13_22.2) [symbolic = %Base.loc13_41.2 (constants.%Base.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn[%T.param_patt: type](%x.param_patt: @AccessMissingBase.%Base.loc13_41.2 (%Base.1)) -> @AccessMissingBase.%T.loc13_22.2 (%T) {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %x.ref: @AccessMissingBase.%Base.loc13_41.2 (%Base.1) = name_ref x, %x
+// CHECK:STDOUT:     %nonesuch.ref: <error> = name_ref nonesuch, <error> [template = <error>]
+// CHECK:STDOUT:     return <error>
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessMissingDerived(%T.loc21_25.1: type) {
+// CHECK:STDOUT:   %T.loc21_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc21_25.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc21_25.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_25.2 (constants.%T.patt)]
+// CHECK:STDOUT:   %Derived.loc21_47.2: type = class_type @Derived, @Derived(%T.loc21_25.2) [symbolic = %Derived.loc21_47.2 (constants.%Derived.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn[%T.param_patt: type](%x.param_patt: @AccessMissingDerived.%Derived.loc21_47.2 (%Derived.1)) -> @AccessMissingDerived.%T.loc21_25.2 (%T) {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %x.ref: @AccessMissingDerived.%Derived.loc21_47.2 (%Derived.1) = name_ref x, %x
+// CHECK:STDOUT:     %nonesuch.ref: <error> = name_ref nonesuch, <error> [template = <error>]
+// CHECK:STDOUT:     return <error>
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: fn @AccessMissingConcrete(%x.param_patt: %Derived.2) -> %i32 {
+// CHECK:STDOUT: !entry:
+// CHECK:STDOUT:   %x.ref: %Derived.2 = name_ref x, %x
+// CHECK:STDOUT:   %nonesuch.ref: <error> = name_ref nonesuch, <error> [template = <error>]
+// CHECK:STDOUT:   return <error>
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(constants.%T) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base => constants.%Base.1
+// CHECK:STDOUT:   %Base.elem => constants.%Base.elem.1
+// CHECK:STDOUT:   %struct_type.b => constants.%struct_type.b.1
+// CHECK:STDOUT:   %complete_type.loc6_1.2 => constants.%complete_type.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(%T.loc4_17.2) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(constants.%T) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base.loc9_22.2 => constants.%Base.1
+// CHECK:STDOUT:   %Derived => constants.%Derived.1
+// CHECK:STDOUT:   %Derived.elem.loc9 => constants.%Derived.elem.1
+// CHECK:STDOUT:   %Derived.elem.loc10 => constants.%Derived.elem.2
+// CHECK:STDOUT:   %struct_type.base.d => constants.%struct_type.base.d.1
+// CHECK:STDOUT:   %complete_type.loc11_1.2 => constants.%complete_type.2
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(@Derived.%T.loc8_15.2) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(%T.loc8_15.2) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(@AccessMissingBase.%T.loc13_22.2) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessMissingBase(constants.%T) {
+// CHECK:STDOUT:   %T.loc13_22.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc13_22.2 => constants.%T
+// CHECK:STDOUT:   %Base.loc13_41.2 => constants.%Base.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(@AccessMissingDerived.%T.loc21_25.2) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessMissingDerived(constants.%T) {
+// CHECK:STDOUT:   %T.loc21_25.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc21_25.2 => constants.%T
+// CHECK:STDOUT:   %Derived.loc21_47.2 => constants.%Derived.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Derived(constants.%i32) {
+// CHECK:STDOUT:   %T.loc8_15.2 => constants.%i32
+// CHECK:STDOUT:   %T.patt.loc8_15.2 => constants.%i32
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base.loc9_22.2 => constants.%Base.2
+// CHECK:STDOUT:   %Derived => constants.%Derived.2
+// CHECK:STDOUT:   %Derived.elem.loc9 => constants.%Derived.elem.3
+// CHECK:STDOUT:   %Derived.elem.loc10 => constants.%Derived.elem.4
+// CHECK:STDOUT:   %struct_type.base.d => constants.%struct_type.base.d.3
+// CHECK:STDOUT:   %complete_type.loc11_1.2 => constants.%complete_type.3
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Base(constants.%i32) {
+// CHECK:STDOUT:   %T.loc4_17.2 => constants.%i32
+// CHECK:STDOUT:   %T.patt.loc4_17.2 => constants.%i32
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Base => constants.%Base.2
+// CHECK:STDOUT:   %Base.elem => constants.%Base.elem.2
+// CHECK:STDOUT:   %struct_type.b => constants.%struct_type.b.2
+// CHECK:STDOUT:   %complete_type.loc6_1.2 => constants.%complete_type.4
+// CHECK:STDOUT: }
+// CHECK:STDOUT:

+ 3 - 3
toolchain/check/testdata/class/no_prelude/import_access.carbon

@@ -60,7 +60,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "def";
 
-// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:8: error: name `Def` not found [NameNotFound]
+// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:8: error: member name `Def` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var c: Test.Def = {};
 // CHECK:STDERR:        ^~~~~~~~
 // CHECK:STDERR:
@@ -90,7 +90,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "forward_with_def";
 
-// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:8: error: name `ForwardWithDef` not found [NameNotFound]
+// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:8: error: member name `ForwardWithDef` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var c: Test.ForwardWithDef = {};
 // CHECK:STDERR:        ^~~~~~~~~~~~~~~~~~~
 // CHECK:STDERR:
@@ -122,7 +122,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "forward";
 
-// CHECK:STDERR: fail_other_forward.carbon:[[@LINE+3]]:9: error: name `Forward` not found [NameNotFound]
+// CHECK:STDERR: fail_other_forward.carbon:[[@LINE+3]]:9: error: member name `Forward` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: fn F(c: Test.Forward*) {}
 // CHECK:STDERR:         ^~~~~~~~~~~~
 fn F(c: Test.Forward*) {}

+ 3 - 3
toolchain/check/testdata/function/definition/import_access.carbon

@@ -60,7 +60,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "def";
 
-// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:13: error: name `Def` not found [NameNotFound]
+// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:13: error: member name `Def` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var f: () = Test.Def();
 // CHECK:STDERR:             ^~~~~~~~
 // CHECK:STDERR:
@@ -90,7 +90,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "forward_with_def";
 
-// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:13: error: name `ForwardWithDef` not found [NameNotFound]
+// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:13: error: member name `ForwardWithDef` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var f: () = Test.ForwardWithDef();
 // CHECK:STDERR:             ^~~~~~~~~~~~~~~~~~~
 // CHECK:STDERR:
@@ -122,7 +122,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "forward";
 
-// CHECK:STDERR: fail_other_forward.carbon:[[@LINE+3]]:13: error: name `Forward` not found [NameNotFound]
+// CHECK:STDERR: fail_other_forward.carbon:[[@LINE+3]]:13: error: member name `Forward` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var f: () = Test.Forward();
 // CHECK:STDERR:             ^~~~~~~~~~~~
 var f: () = Test.Forward();

+ 449 - 0
toolchain/check/testdata/interface/member_lookup.carbon

@@ -0,0 +1,449 @@
+// 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/interface/member_lookup.carbon
+// TIP: To dump output, run:
+// TIP:   bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/member_lookup.carbon
+
+// --- member_access.carbon
+
+library "[[@TEST_NAME]]";
+
+interface Interface(T:! type) {
+  let X:! T;
+}
+
+fn AccessGeneric[T:! type](I:! Interface(T)) -> T {
+  return I.X;
+}
+
+fn AccessConcrete(I:! Interface(i32)) -> i32 {
+  return I.X;
+}
+
+// --- fail_no_member.carbon
+
+library "[[@TEST_NAME]]";
+
+interface Interface(T:! type) {
+  let X:! T;
+}
+
+fn AccessMissingGeneric[T:! type](I:! Interface(T)) -> T {
+  // CHECK:STDERR: fail_no_member.carbon:[[@LINE+4]]:10: error: member name `nonesuch` not found in `Interface(T)` [MemberNameNotFoundInScope]
+  // CHECK:STDERR:   return I.nonesuch;
+  // CHECK:STDERR:          ^~~~~~~~~~
+  // CHECK:STDERR:
+  return I.nonesuch;
+}
+
+fn AccessMissingConcrete(I:! Interface(i32)) -> i32 {
+  // CHECK:STDERR: fail_no_member.carbon:[[@LINE+3]]:10: error: member name `nonesuch` not found in `Interface(i32)` [MemberNameNotFoundInScope]
+  // CHECK:STDERR:   return I.nonesuch;
+  // CHECK:STDERR:          ^~~~~~~~~~
+  return I.nonesuch;
+}
+
+// CHECK:STDOUT: --- member_access.carbon
+// CHECK:STDOUT:
+// CHECK:STDOUT: constants {
+// CHECK:STDOUT:   %T: type = bind_symbolic_name T, 0 [symbolic]
+// CHECK:STDOUT:   %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
+// CHECK:STDOUT:   %Interface.type.1: type = generic_interface_type @Interface [template]
+// CHECK:STDOUT:   %Interface.generic: %Interface.type.1 = struct_value () [template]
+// CHECK:STDOUT:   %Interface.type.2: type = facet_type <@Interface, @Interface(%T)> [symbolic]
+// CHECK:STDOUT:   %Self: %Interface.type.2 = bind_symbolic_name Self, 1 [symbolic]
+// CHECK:STDOUT:   %assoc_type.1: type = assoc_entity_type %Interface.type.2, %T [symbolic]
+// CHECK:STDOUT:   %assoc0.1: %assoc_type.1 = assoc_entity element0, @Interface.%X [symbolic]
+// CHECK:STDOUT:   %I.1: %Interface.type.2 = bind_symbolic_name I, 1 [symbolic]
+// CHECK:STDOUT:   %I.patt.1: %Interface.type.2 = symbolic_binding_pattern I, 1 [symbolic]
+// CHECK:STDOUT:   %AccessGeneric.type: type = fn_type @AccessGeneric [template]
+// CHECK:STDOUT:   %AccessGeneric: %AccessGeneric.type = struct_value () [template]
+// CHECK:STDOUT:   %I.as_wit.1: <witness> = facet_access_witness %I.1 [symbolic]
+// CHECK:STDOUT:   %impl.elem0.1: %T = interface_witness_access %I.as_wit.1, element0 [symbolic]
+// CHECK:STDOUT:   %int_32: Core.IntLiteral = int_value 32 [template]
+// CHECK:STDOUT:   %Int.type: type = fn_type @Int [template]
+// CHECK:STDOUT:   %Int: %Int.type = struct_value () [template]
+// CHECK:STDOUT:   %i32: type = int_type signed, %int_32 [template]
+// CHECK:STDOUT:   %Interface.type.3: type = facet_type <@Interface, @Interface(%i32)> [template]
+// CHECK:STDOUT:   %I.2: %Interface.type.3 = bind_symbolic_name I, 0 [symbolic]
+// CHECK:STDOUT:   %I.patt.2: %Interface.type.3 = symbolic_binding_pattern I, 0 [symbolic]
+// CHECK:STDOUT:   %AccessConcrete.type: type = fn_type @AccessConcrete [template]
+// CHECK:STDOUT:   %AccessConcrete: %AccessConcrete.type = struct_value () [template]
+// CHECK:STDOUT:   %assoc_type.2: type = assoc_entity_type %Interface.type.3, %i32 [template]
+// CHECK:STDOUT:   %assoc0.2: %assoc_type.2 = assoc_entity element0, @Interface.%X [template]
+// CHECK:STDOUT:   %I.as_wit.2: <witness> = facet_access_witness %I.2 [symbolic]
+// CHECK:STDOUT:   %impl.elem0.2: %i32 = interface_witness_access %I.as_wit.2, element0 [symbolic]
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: imports {
+// CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
+// CHECK:STDOUT:     .Int = %import_ref
+// CHECK:STDOUT:     import Core//prelude
+// CHECK:STDOUT:     import Core//prelude/...
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace [template] {
+// CHECK:STDOUT:     .Core = imports.%Core
+// CHECK:STDOUT:     .Interface = %Interface.decl
+// CHECK:STDOUT:     .AccessGeneric = %AccessGeneric.decl
+// CHECK:STDOUT:     .AccessConcrete = %AccessConcrete.decl
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Core.import = import Core
+// CHECK:STDOUT:   %Interface.decl: %Interface.type.1 = interface_decl @Interface [template = constants.%Interface.generic] {
+// CHECK:STDOUT:     %T.patt.loc4_21.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_21.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc4_21.1, runtime_param<invalid> [symbolic = %T.patt.loc4_21.2 (constants.%T.patt)]
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc4_21.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_21.2 (constants.%T)]
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessGeneric.decl: %AccessGeneric.type = fn_decl @AccessGeneric [template = constants.%AccessGeneric] {
+// CHECK:STDOUT:     %T.patt.loc8_18.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_18.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc8_18.1, runtime_param<invalid> [symbolic = %T.patt.loc8_18.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %I.patt.loc8_28.1: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2) = symbolic_binding_pattern I, 1 [symbolic = %I.patt.loc8_28.2 (constants.%I.patt.1)]
+// CHECK:STDOUT:     %I.param_patt: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2) = value_param_pattern %I.patt.loc8_28.1, runtime_param<invalid> [symbolic = %I.patt.loc8_28.2 (constants.%I.patt.1)]
+// CHECK:STDOUT:     %return.patt: @AccessGeneric.%T.loc8_18.2 (%T) = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: @AccessGeneric.%T.loc8_18.2 (%T) = out_param_pattern %return.patt, runtime_param0
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Interface.ref: %Interface.type.1 = name_ref Interface, file.%Interface.decl [template = constants.%Interface.generic]
+// CHECK:STDOUT:     %T.ref.loc8_42: type = name_ref T, %T.loc8_18.1 [symbolic = %T.loc8_18.2 (constants.%T)]
+// CHECK:STDOUT:     %Interface.type.loc8_43.1: type = facet_type <@Interface, @Interface(constants.%T)> [symbolic = %Interface.type.loc8_43.2 (constants.%Interface.type.2)]
+// CHECK:STDOUT:     %T.ref.loc8_49: type = name_ref T, %T.loc8_18.1 [symbolic = %T.loc8_18.2 (constants.%T)]
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc8_18.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_18.2 (constants.%T)]
+// CHECK:STDOUT:     %I.param: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2) = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %I.loc8_28.1: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2) = bind_symbolic_name I, 1, %I.param [symbolic = %I.loc8_28.2 (constants.%I.1)]
+// CHECK:STDOUT:     %return.param: ref @AccessGeneric.%T.loc8_18.2 (%T) = out_param runtime_param0
+// CHECK:STDOUT:     %return: ref @AccessGeneric.%T.loc8_18.2 (%T) = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessConcrete.decl: %AccessConcrete.type = fn_decl @AccessConcrete [template = constants.%AccessConcrete] {
+// CHECK:STDOUT:     %I.patt.loc12_19.1: %Interface.type.3 = symbolic_binding_pattern I, 0 [symbolic = %I.patt.loc12_19.2 (constants.%I.patt.2)]
+// CHECK:STDOUT:     %I.param_patt: %Interface.type.3 = value_param_pattern %I.patt.loc12_19.1, runtime_param<invalid> [symbolic = %I.patt.loc12_19.2 (constants.%I.patt.2)]
+// CHECK:STDOUT:     %return.patt: %i32 = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Interface.ref: %Interface.type.1 = name_ref Interface, file.%Interface.decl [template = constants.%Interface.generic]
+// CHECK:STDOUT:     %int_32.loc12_33: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc12_33: init type = call constants.%Int(%int_32.loc12_33) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc12_36.1: type = value_of_initializer %int.make_type_signed.loc12_33 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc12_36.2: type = converted %int.make_type_signed.loc12_33, %.loc12_36.1 [template = constants.%i32]
+// CHECK:STDOUT:     %Interface.type: type = facet_type <@Interface, @Interface(constants.%i32)> [template = constants.%Interface.type.3]
+// CHECK:STDOUT:     %int_32.loc12_42: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc12_42: init type = call constants.%Int(%int_32.loc12_42) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc12_42.1: type = value_of_initializer %int.make_type_signed.loc12_42 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc12_42.2: type = converted %int.make_type_signed.loc12_42, %.loc12_42.1 [template = constants.%i32]
+// CHECK:STDOUT:     %I.param: %Interface.type.3 = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %I.loc12_19.1: %Interface.type.3 = bind_symbolic_name I, 0, %I.param [symbolic = %I.loc12_19.2 (constants.%I.2)]
+// CHECK:STDOUT:     %return.param: ref %i32 = out_param runtime_param0
+// CHECK:STDOUT:     %return: ref %i32 = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic interface @Interface(%T.loc4_21.1: type) {
+// CHECK:STDOUT:   %T.loc4_21.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_21.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc4_21.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_21.2 (constants.%T.patt)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Interface.type: type = facet_type <@Interface, @Interface(%T.loc4_21.2)> [symbolic = %Interface.type (constants.%Interface.type.2)]
+// CHECK:STDOUT:   %Self.2: %Interface.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
+// CHECK:STDOUT:   %assoc_type: type = assoc_entity_type @Interface.%Interface.type (%Interface.type.2), @Interface.%T.loc4_21.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.1)]
+// CHECK:STDOUT:   %assoc0.loc5_12.2: @Interface.%assoc_type (%assoc_type.1) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   interface {
+// CHECK:STDOUT:     %Self.1: @Interface.%Interface.type (%Interface.type.2) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
+// CHECK:STDOUT:     %T.ref: type = name_ref T, %T.loc4_21.1 [symbolic = %T.loc4_21.2 (constants.%T)]
+// CHECK:STDOUT:     %X: @Interface.%T.loc4_21.2 (%T) = assoc_const_decl X [template]
+// CHECK:STDOUT:     %assoc0.loc5_12.1: @Interface.%assoc_type (%assoc_type.1) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   !members:
+// CHECK:STDOUT:     .Self = %Self.1
+// CHECK:STDOUT:     .X = %assoc0.loc5_12.1
+// CHECK:STDOUT:     witness = (%X)
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessGeneric(%T.loc8_18.1: type, %I.loc8_28.1: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2)) {
+// CHECK:STDOUT:   %T.loc8_18.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_18.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc8_18.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_18.2 (constants.%T.patt)]
+// CHECK:STDOUT:   %Interface.type.loc8_43.2: type = facet_type <@Interface, @Interface(%T.loc8_18.2)> [symbolic = %Interface.type.loc8_43.2 (constants.%Interface.type.2)]
+// CHECK:STDOUT:   %I.loc8_28.2: %Interface.type.2 = bind_symbolic_name I, 1 [symbolic = %I.loc8_28.2 (constants.%I.1)]
+// CHECK:STDOUT:   %I.patt.loc8_28.2: %Interface.type.2 = symbolic_binding_pattern I, 1 [symbolic = %I.patt.loc8_28.2 (constants.%I.patt.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %assoc_type: type = assoc_entity_type @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2), @AccessGeneric.%T.loc8_18.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.1)]
+// CHECK:STDOUT:   %assoc0: @AccessGeneric.%assoc_type (%assoc_type.1) = assoc_entity element0, @Interface.%X [symbolic = %assoc0 (constants.%assoc0.1)]
+// CHECK:STDOUT:   %I.as_wit.loc9_11.2: <witness> = facet_access_witness %I.loc8_28.2 [symbolic = %I.as_wit.loc9_11.2 (constants.%I.as_wit.1)]
+// CHECK:STDOUT:   %impl.elem0.loc9_11.2: @AccessGeneric.%T.loc8_18.2 (%T) = interface_witness_access %I.as_wit.loc9_11.2, element0 [symbolic = %impl.elem0.loc9_11.2 (constants.%impl.elem0.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn[%T.param_patt: type](%I.param_patt: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2)) -> @AccessGeneric.%T.loc8_18.2 (%T) {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %I.ref: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.2) = name_ref I, %I.loc8_28.1 [symbolic = %I.loc8_28.2 (constants.%I.1)]
+// CHECK:STDOUT:     %.loc9: @AccessGeneric.%assoc_type (%assoc_type.1) = specific_constant @Interface.%assoc0.loc5_12.1, @Interface(constants.%T) [symbolic = %assoc0 (constants.%assoc0.1)]
+// CHECK:STDOUT:     %X.ref: @AccessGeneric.%assoc_type (%assoc_type.1) = name_ref X, %.loc9 [symbolic = %assoc0 (constants.%assoc0.1)]
+// CHECK:STDOUT:     %I.as_wit.loc9_11.1: <witness> = facet_access_witness %I.ref [symbolic = %I.as_wit.loc9_11.2 (constants.%I.as_wit.1)]
+// CHECK:STDOUT:     %impl.elem0.loc9_11.1: @AccessGeneric.%T.loc8_18.2 (%T) = interface_witness_access %I.as_wit.loc9_11.1, element0 [symbolic = %impl.elem0.loc9_11.2 (constants.%impl.elem0.1)]
+// CHECK:STDOUT:     return %impl.elem0.loc9_11.1
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessConcrete(%I.loc12_19.1: %Interface.type.3) {
+// CHECK:STDOUT:   %I.loc12_19.2: %Interface.type.3 = bind_symbolic_name I, 0 [symbolic = %I.loc12_19.2 (constants.%I.2)]
+// CHECK:STDOUT:   %I.patt.loc12_19.2: %Interface.type.3 = symbolic_binding_pattern I, 0 [symbolic = %I.patt.loc12_19.2 (constants.%I.patt.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %I.as_wit.loc13_11.2: <witness> = facet_access_witness %I.loc12_19.2 [symbolic = %I.as_wit.loc13_11.2 (constants.%I.as_wit.2)]
+// CHECK:STDOUT:   %impl.elem0.loc13_11.2: %i32 = interface_witness_access %I.as_wit.loc13_11.2, element0 [symbolic = %impl.elem0.loc13_11.2 (constants.%impl.elem0.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn(%I.param_patt: %Interface.type.3) -> %i32 {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %I.ref: %Interface.type.3 = name_ref I, %I.loc12_19.1 [symbolic = %I.loc12_19.2 (constants.%I.2)]
+// CHECK:STDOUT:     %.loc13: %assoc_type.2 = specific_constant @Interface.%assoc0.loc5_12.1, @Interface(constants.%i32) [template = constants.%assoc0.2]
+// CHECK:STDOUT:     %X.ref: %assoc_type.2 = name_ref X, %.loc13 [template = constants.%assoc0.2]
+// CHECK:STDOUT:     %I.as_wit.loc13_11.1: <witness> = facet_access_witness %I.ref [symbolic = %I.as_wit.loc13_11.2 (constants.%I.as_wit.2)]
+// CHECK:STDOUT:     %impl.elem0.loc13_11.1: %i32 = interface_witness_access %I.as_wit.loc13_11.1, element0 [symbolic = %impl.elem0.loc13_11.2 (constants.%impl.elem0.2)]
+// CHECK:STDOUT:     return %impl.elem0.loc13_11.1
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(constants.%T) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%T
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Interface.type => constants.%Interface.type.2
+// CHECK:STDOUT:   %Self.2 => constants.%Self
+// CHECK:STDOUT:   %assoc_type => constants.%assoc_type.1
+// CHECK:STDOUT:   %assoc0.loc5_12.2 => constants.%assoc0.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(%T.loc4_21.2) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(@AccessGeneric.%T.loc8_18.2) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessGeneric(constants.%T, constants.%I.1) {
+// CHECK:STDOUT:   %T.loc8_18.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_18.2 => constants.%T
+// CHECK:STDOUT:   %Interface.type.loc8_43.2 => constants.%Interface.type.2
+// CHECK:STDOUT:   %I.loc8_28.2 => constants.%I.1
+// CHECK:STDOUT:   %I.patt.loc8_28.2 => constants.%I.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(constants.%i32) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%i32
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%i32
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Interface.type => constants.%Interface.type.3
+// CHECK:STDOUT:   %Self.2 => constants.%Self
+// CHECK:STDOUT:   %assoc_type => constants.%assoc_type.2
+// CHECK:STDOUT:   %assoc0.loc5_12.2 => constants.%assoc0.2
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessConcrete(constants.%I.2) {
+// CHECK:STDOUT:   %I.loc12_19.2 => constants.%I.2
+// CHECK:STDOUT:   %I.patt.loc12_19.2 => constants.%I.2
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: --- fail_no_member.carbon
+// CHECK:STDOUT:
+// CHECK:STDOUT: constants {
+// CHECK:STDOUT:   %T: type = bind_symbolic_name T, 0 [symbolic]
+// CHECK:STDOUT:   %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
+// CHECK:STDOUT:   %Interface.type.1: type = generic_interface_type @Interface [template]
+// CHECK:STDOUT:   %Interface.generic: %Interface.type.1 = struct_value () [template]
+// CHECK:STDOUT:   %Interface.type.2: type = facet_type <@Interface, @Interface(%T)> [symbolic]
+// CHECK:STDOUT:   %Self: %Interface.type.2 = bind_symbolic_name Self, 1 [symbolic]
+// CHECK:STDOUT:   %assoc_type.1: type = assoc_entity_type %Interface.type.2, %T [symbolic]
+// CHECK:STDOUT:   %assoc0.1: %assoc_type.1 = assoc_entity element0, @Interface.%X [symbolic]
+// CHECK:STDOUT:   %I.1: %Interface.type.2 = bind_symbolic_name I, 1 [symbolic]
+// CHECK:STDOUT:   %I.patt.1: %Interface.type.2 = symbolic_binding_pattern I, 1 [symbolic]
+// CHECK:STDOUT:   %AccessMissingGeneric.type: type = fn_type @AccessMissingGeneric [template]
+// CHECK:STDOUT:   %AccessMissingGeneric: %AccessMissingGeneric.type = struct_value () [template]
+// CHECK:STDOUT:   %int_32: Core.IntLiteral = int_value 32 [template]
+// CHECK:STDOUT:   %Int.type: type = fn_type @Int [template]
+// CHECK:STDOUT:   %Int: %Int.type = struct_value () [template]
+// CHECK:STDOUT:   %i32: type = int_type signed, %int_32 [template]
+// CHECK:STDOUT:   %Interface.type.3: type = facet_type <@Interface, @Interface(%i32)> [template]
+// CHECK:STDOUT:   %I.2: %Interface.type.3 = bind_symbolic_name I, 0 [symbolic]
+// CHECK:STDOUT:   %I.patt.2: %Interface.type.3 = symbolic_binding_pattern I, 0 [symbolic]
+// CHECK:STDOUT:   %AccessMissingConcrete.type: type = fn_type @AccessMissingConcrete [template]
+// CHECK:STDOUT:   %AccessMissingConcrete: %AccessMissingConcrete.type = struct_value () [template]
+// CHECK:STDOUT:   %assoc_type.2: type = assoc_entity_type %Interface.type.3, %i32 [template]
+// CHECK:STDOUT:   %assoc0.2: %assoc_type.2 = assoc_entity element0, @Interface.%X [template]
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: imports {
+// CHECK:STDOUT:   %Core: <namespace> = namespace file.%Core.import, [template] {
+// CHECK:STDOUT:     .Int = %import_ref
+// CHECK:STDOUT:     import Core//prelude
+// CHECK:STDOUT:     import Core//prelude/...
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace [template] {
+// CHECK:STDOUT:     .Core = imports.%Core
+// CHECK:STDOUT:     .Interface = %Interface.decl
+// CHECK:STDOUT:     .AccessMissingGeneric = %AccessMissingGeneric.decl
+// CHECK:STDOUT:     .AccessMissingConcrete = %AccessMissingConcrete.decl
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Core.import = import Core
+// CHECK:STDOUT:   %Interface.decl: %Interface.type.1 = interface_decl @Interface [template = constants.%Interface.generic] {
+// CHECK:STDOUT:     %T.patt.loc4_21.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_21.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc4_21.1, runtime_param<invalid> [symbolic = %T.patt.loc4_21.2 (constants.%T.patt)]
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc4_21.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_21.2 (constants.%T)]
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessMissingGeneric.decl: %AccessMissingGeneric.type = fn_decl @AccessMissingGeneric [template = constants.%AccessMissingGeneric] {
+// CHECK:STDOUT:     %T.patt.loc8_25.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_25.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %T.param_patt: type = value_param_pattern %T.patt.loc8_25.1, runtime_param<invalid> [symbolic = %T.patt.loc8_25.2 (constants.%T.patt)]
+// CHECK:STDOUT:     %I.patt.loc8_35.1: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2) = symbolic_binding_pattern I, 1 [symbolic = %I.patt.loc8_35.2 (constants.%I.patt.1)]
+// CHECK:STDOUT:     %I.param_patt: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2) = value_param_pattern %I.patt.loc8_35.1, runtime_param<invalid> [symbolic = %I.patt.loc8_35.2 (constants.%I.patt.1)]
+// CHECK:STDOUT:     %return.patt: @AccessMissingGeneric.%T.loc8_25.2 (%T) = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: @AccessMissingGeneric.%T.loc8_25.2 (%T) = out_param_pattern %return.patt, runtime_param0
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Interface.ref: %Interface.type.1 = name_ref Interface, file.%Interface.decl [template = constants.%Interface.generic]
+// CHECK:STDOUT:     %T.ref.loc8_49: type = name_ref T, %T.loc8_25.1 [symbolic = %T.loc8_25.2 (constants.%T)]
+// CHECK:STDOUT:     %Interface.type.loc8_50.1: type = facet_type <@Interface, @Interface(constants.%T)> [symbolic = %Interface.type.loc8_50.2 (constants.%Interface.type.2)]
+// CHECK:STDOUT:     %T.ref.loc8_56: type = name_ref T, %T.loc8_25.1 [symbolic = %T.loc8_25.2 (constants.%T)]
+// CHECK:STDOUT:     %T.param: type = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %T.loc8_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_25.2 (constants.%T)]
+// CHECK:STDOUT:     %I.param: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2) = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %I.loc8_35.1: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2) = bind_symbolic_name I, 1, %I.param [symbolic = %I.loc8_35.2 (constants.%I.1)]
+// CHECK:STDOUT:     %return.param: ref @AccessMissingGeneric.%T.loc8_25.2 (%T) = out_param runtime_param0
+// CHECK:STDOUT:     %return: ref @AccessMissingGeneric.%T.loc8_25.2 (%T) = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %AccessMissingConcrete.decl: %AccessMissingConcrete.type = fn_decl @AccessMissingConcrete [template = constants.%AccessMissingConcrete] {
+// CHECK:STDOUT:     %I.patt.loc16_26.1: %Interface.type.3 = symbolic_binding_pattern I, 0 [symbolic = %I.patt.loc16_26.2 (constants.%I.patt.2)]
+// CHECK:STDOUT:     %I.param_patt: %Interface.type.3 = value_param_pattern %I.patt.loc16_26.1, runtime_param<invalid> [symbolic = %I.patt.loc16_26.2 (constants.%I.patt.2)]
+// CHECK:STDOUT:     %return.patt: %i32 = return_slot_pattern
+// CHECK:STDOUT:     %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
+// CHECK:STDOUT:   } {
+// CHECK:STDOUT:     %Interface.ref: %Interface.type.1 = name_ref Interface, file.%Interface.decl [template = constants.%Interface.generic]
+// CHECK:STDOUT:     %int_32.loc16_40: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc16_40: init type = call constants.%Int(%int_32.loc16_40) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc16_43.1: type = value_of_initializer %int.make_type_signed.loc16_40 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc16_43.2: type = converted %int.make_type_signed.loc16_40, %.loc16_43.1 [template = constants.%i32]
+// CHECK:STDOUT:     %Interface.type: type = facet_type <@Interface, @Interface(constants.%i32)> [template = constants.%Interface.type.3]
+// CHECK:STDOUT:     %int_32.loc16_49: Core.IntLiteral = int_value 32 [template = constants.%int_32]
+// CHECK:STDOUT:     %int.make_type_signed.loc16_49: init type = call constants.%Int(%int_32.loc16_49) [template = constants.%i32]
+// CHECK:STDOUT:     %.loc16_49.1: type = value_of_initializer %int.make_type_signed.loc16_49 [template = constants.%i32]
+// CHECK:STDOUT:     %.loc16_49.2: type = converted %int.make_type_signed.loc16_49, %.loc16_49.1 [template = constants.%i32]
+// CHECK:STDOUT:     %I.param: %Interface.type.3 = value_param runtime_param<invalid>
+// CHECK:STDOUT:     %I.loc16_26.1: %Interface.type.3 = bind_symbolic_name I, 0, %I.param [symbolic = %I.loc16_26.2 (constants.%I.2)]
+// CHECK:STDOUT:     %return.param: ref %i32 = out_param runtime_param0
+// CHECK:STDOUT:     %return: ref %i32 = return_slot %return.param
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic interface @Interface(%T.loc4_21.1: type) {
+// CHECK:STDOUT:   %T.loc4_21.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_21.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc4_21.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_21.2 (constants.%T.patt)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Interface.type: type = facet_type <@Interface, @Interface(%T.loc4_21.2)> [symbolic = %Interface.type (constants.%Interface.type.2)]
+// CHECK:STDOUT:   %Self.2: %Interface.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
+// CHECK:STDOUT:   %assoc_type: type = assoc_entity_type @Interface.%Interface.type (%Interface.type.2), @Interface.%T.loc4_21.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.1)]
+// CHECK:STDOUT:   %assoc0.loc5_12.2: @Interface.%assoc_type (%assoc_type.1) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   interface {
+// CHECK:STDOUT:     %Self.1: @Interface.%Interface.type (%Interface.type.2) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
+// CHECK:STDOUT:     %T.ref: type = name_ref T, %T.loc4_21.1 [symbolic = %T.loc4_21.2 (constants.%T)]
+// CHECK:STDOUT:     %X: @Interface.%T.loc4_21.2 (%T) = assoc_const_decl X [template]
+// CHECK:STDOUT:     %assoc0.loc5_12.1: @Interface.%assoc_type (%assoc_type.1) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT:   !members:
+// CHECK:STDOUT:     .Self = %Self.1
+// CHECK:STDOUT:     .X = %assoc0.loc5_12.1
+// CHECK:STDOUT:     witness = (%X)
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessMissingGeneric(%T.loc8_25.1: type, %I.loc8_35.1: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2)) {
+// CHECK:STDOUT:   %T.loc8_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_25.2 (constants.%T)]
+// CHECK:STDOUT:   %T.patt.loc8_25.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_25.2 (constants.%T.patt)]
+// CHECK:STDOUT:   %Interface.type.loc8_50.2: type = facet_type <@Interface, @Interface(%T.loc8_25.2)> [symbolic = %Interface.type.loc8_50.2 (constants.%Interface.type.2)]
+// CHECK:STDOUT:   %I.loc8_35.2: %Interface.type.2 = bind_symbolic_name I, 1 [symbolic = %I.loc8_35.2 (constants.%I.1)]
+// CHECK:STDOUT:   %I.patt.loc8_35.2: %Interface.type.2 = symbolic_binding_pattern I, 1 [symbolic = %I.patt.loc8_35.2 (constants.%I.patt.1)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn[%T.param_patt: type](%I.param_patt: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2)) -> @AccessMissingGeneric.%T.loc8_25.2 (%T) {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %I.ref: @AccessMissingGeneric.%Interface.type.loc8_50.2 (%Interface.type.2) = name_ref I, %I.loc8_35.1 [symbolic = %I.loc8_35.2 (constants.%I.1)]
+// CHECK:STDOUT:     %nonesuch.ref: <error> = name_ref nonesuch, <error> [template = <error>]
+// CHECK:STDOUT:     return <error>
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: generic fn @AccessMissingConcrete(%I.loc16_26.1: %Interface.type.3) {
+// CHECK:STDOUT:   %I.loc16_26.2: %Interface.type.3 = bind_symbolic_name I, 0 [symbolic = %I.loc16_26.2 (constants.%I.2)]
+// CHECK:STDOUT:   %I.patt.loc16_26.2: %Interface.type.3 = symbolic_binding_pattern I, 0 [symbolic = %I.patt.loc16_26.2 (constants.%I.patt.2)]
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:
+// CHECK:STDOUT:   fn(%I.param_patt: %Interface.type.3) -> %i32 {
+// CHECK:STDOUT:   !entry:
+// CHECK:STDOUT:     %I.ref: %Interface.type.3 = name_ref I, %I.loc16_26.1 [symbolic = %I.loc16_26.2 (constants.%I.2)]
+// CHECK:STDOUT:     %nonesuch.ref: <error> = name_ref nonesuch, <error> [template = <error>]
+// CHECK:STDOUT:     return <error>
+// CHECK:STDOUT:   }
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(constants.%T) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%T
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Interface.type => constants.%Interface.type.2
+// CHECK:STDOUT:   %Self.2 => constants.%Self
+// CHECK:STDOUT:   %assoc_type => constants.%assoc_type.1
+// CHECK:STDOUT:   %assoc0.loc5_12.2 => constants.%assoc0.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(%T.loc4_21.2) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(@AccessMissingGeneric.%T.loc8_25.2) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%T
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessMissingGeneric(constants.%T, constants.%I.1) {
+// CHECK:STDOUT:   %T.loc8_25.2 => constants.%T
+// CHECK:STDOUT:   %T.patt.loc8_25.2 => constants.%T
+// CHECK:STDOUT:   %Interface.type.loc8_50.2 => constants.%Interface.type.2
+// CHECK:STDOUT:   %I.loc8_35.2 => constants.%I.1
+// CHECK:STDOUT:   %I.patt.loc8_35.2 => constants.%I.1
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @Interface(constants.%i32) {
+// CHECK:STDOUT:   %T.loc4_21.2 => constants.%i32
+// CHECK:STDOUT:   %T.patt.loc4_21.2 => constants.%i32
+// CHECK:STDOUT:
+// CHECK:STDOUT: !definition:
+// CHECK:STDOUT:   %Interface.type => constants.%Interface.type.3
+// CHECK:STDOUT:   %Self.2 => constants.%Self
+// CHECK:STDOUT:   %assoc_type => constants.%assoc_type.2
+// CHECK:STDOUT:   %assoc0.loc5_12.2 => constants.%assoc0.2
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: specific @AccessMissingConcrete(constants.%I.2) {
+// CHECK:STDOUT:   %I.loc16_26.2 => constants.%I.2
+// CHECK:STDOUT:   %I.patt.loc16_26.2 => constants.%I.2
+// CHECK:STDOUT: }
+// CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/interface/no_prelude/fail_lookup_in_type_type.carbon

@@ -22,7 +22,7 @@ let T: type.not_found = {};
 
 library "[[@TEST_NAME]]";
 
-// CHECK:STDERR: fail_lookup_type_where.carbon:[[@LINE+3]]:8: error: name `missing` not found [NameNotFound]
+// CHECK:STDERR: fail_lookup_type_where.carbon:[[@LINE+3]]:8: error: member name `missing` not found [MemberNameNotFound]
 // CHECK:STDERR: let U: (type where .Self impls type).missing = {};
 // CHECK:STDERR:        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 let U: (type where .Self impls type).missing = {};

+ 1 - 1
toolchain/check/testdata/interface/no_prelude/fail_lookup_undefined.carbon

@@ -38,7 +38,7 @@ interface BeingDefined {
   // CHECK:STDERR: interface BeingDefined {
   // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
   // CHECK:STDERR:
-  // CHECK:STDERR: fail_lookup_undefined.carbon:[[@LINE+4]]:13: error: name `T` not found [NameNotFound]
+  // CHECK:STDERR: fail_lookup_undefined.carbon:[[@LINE+4]]:13: error: member name `T` not found in `BeingDefined` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   fn H() -> BeingDefined.T;
   // CHECK:STDERR:             ^~~~~~~~~~~~~~
   // CHECK:STDERR:

+ 2 - 2
toolchain/check/testdata/interface/no_prelude/import_access.carbon

@@ -61,7 +61,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "def";
 
-// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:9: error: name `Def` not found [NameNotFound]
+// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:9: error: member name `Def` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: fn F(i: Test.Def) {}
 // CHECK:STDERR:         ^~~~~~~~
 // CHECK:STDERR:
@@ -91,7 +91,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "forward_with_def";
 
-// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:9: error: name `ForwardWithDef` not found [NameNotFound]
+// CHECK:STDERR: fail_other_forward_with_def.carbon:[[@LINE+4]]:9: error: member name `ForwardWithDef` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: fn F(i: Test.ForwardWithDef) {}
 // CHECK:STDERR:         ^~~~~~~~~~~~~~~~~~~
 // CHECK:STDERR:

+ 1 - 1
toolchain/check/testdata/let/no_prelude/import_access.carbon

@@ -46,7 +46,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "def";
 
-// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:14: error: name `v` not found [NameNotFound]
+// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:14: error: member name `v` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: let v2: () = Test.v;
 // CHECK:STDERR:              ^~~~~~
 let v2: () = Test.v;

+ 1 - 1
toolchain/check/testdata/package_expr/fail_not_found.carbon

@@ -9,7 +9,7 @@
 // TIP:   bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/package_expr/fail_not_found.carbon
 
 fn Main() {
-  // CHECK:STDERR: fail_not_found.carbon:[[@LINE+3]]:16: error: name `x` not found [NameNotFound]
+  // CHECK:STDERR: fail_not_found.carbon:[[@LINE+3]]:16: error: member name `x` not found in `package` [MemberNameNotFoundInScope]
   // CHECK:STDERR:   var y: i32 = package.x;
   // CHECK:STDERR:                ^~~~~~~~~
   var y: i32 = package.x;

+ 1 - 1
toolchain/check/testdata/packages/no_prelude/cross_package_import.carbon

@@ -201,7 +201,7 @@ library "[[@TEST_NAME]]";
 
 import Other library "other_fn_use";
 
-// CHECK:STDERR: fail_use_other_fn_use.carbon:[[@LINE+3]]:13: error: name `F` not found [NameNotFound]
+// CHECK:STDERR: fail_use_other_fn_use.carbon:[[@LINE+3]]:13: error: member name `F` not found in `Other` [MemberNameNotFoundInScope]
 // CHECK:STDERR: fn UseF() { Other.F(); }
 // CHECK:STDERR:             ^~~~~~~
 fn UseF() { Other.F(); }

+ 1 - 1
toolchain/check/testdata/var/no_prelude/import_access.carbon

@@ -46,7 +46,7 @@ package Other library "[[@TEST_NAME]]";
 
 import Test library "def";
 
-// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:14: error: name `v` not found [NameNotFound]
+// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:14: error: member name `v` not found in `Test` [MemberNameNotFoundInScope]
 // CHECK:STDERR: var v2: () = Test.v;
 // CHECK:STDERR:              ^~~~~~
 var v2: () = Test.v;

+ 1 - 1
toolchain/check/testdata/where_expr/designator.carbon

@@ -30,7 +30,7 @@ interface J {
   let Member:! type;
 }
 
-// CHECK:STDERR: fail_wrong_member.carbon:[[@LINE+4]]:31: error: name `Mismatch` not found [NameNotFound]
+// CHECK:STDERR: fail_wrong_member.carbon:[[@LINE+4]]:31: error: member name `Mismatch` not found in `J` [MemberNameNotFoundInScope]
 // CHECK:STDERR: fn PeriodMismatch(W:! J where .Mismatch = {});
 // CHECK:STDERR:                               ^~~~~~~~~
 // CHECK:STDERR:

+ 2 - 0
toolchain/diagnostics/diagnostic_kind.def

@@ -280,6 +280,8 @@ CARBON_DIAGNOSTIC_KIND(FromExtendHere)
 CARBON_DIAGNOSTIC_KIND(InNameLookup)
 CARBON_DIAGNOSTIC_KIND(NameAmbiguousDueToExtend)
 CARBON_DIAGNOSTIC_KIND(NameNotFound)
+CARBON_DIAGNOSTIC_KIND(MemberNameNotFound)
+CARBON_DIAGNOSTIC_KIND(MemberNameNotFoundInScope)
 CARBON_DIAGNOSTIC_KIND(NoPeriodSelfForDesignator)
 
 CARBON_DIAGNOSTIC_KIND(AbstractTypeInAdaptDecl)

+ 5 - 1
toolchain/sem_ir/stringify_type.cpp

@@ -372,6 +372,11 @@ auto StringifyTypeExpr(const SemIR::File& sem_ir, InstId outer_inst_id)
         out << sem_ir.names().GetFormatted(inst.name_id);
         break;
       }
+      case CARBON_KIND(Namespace inst): {
+        out << sem_ir.names().GetFormatted(
+            sem_ir.name_scopes().Get(inst.name_scope_id).name_id());
+        break;
+      }
       case CARBON_KIND(PointerType inst): {
         step_stack.PushString("*");
         step_stack.PushTypeId(inst.pointee_id);
@@ -463,7 +468,6 @@ auto StringifyTypeExpr(const SemIR::File& sem_ir, InstId outer_inst_id)
       case InitializeFrom::Kind:
       case InterfaceDecl::Kind:
       case InterfaceWitness::Kind:
-      case Namespace::Kind:
       case OutParam::Kind:
       case OutParamPattern::Kind:
       case RequirementEquivalent::Kind: