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

Add imports of enclosing scopes. (#3575)

Namespaces are copied, which means also adding their name to the
underlying instruction. It happened not to be done previously; the name
was only in name lookup.

Since the only import supported right now is the default import,
functionality is limited; in the future I'll need to deal with namespace
vs package conflicts.

Tests of namespace imports are under "namespace" -- I figured this would
be best for scaling as more instructions get support.

This also improves some debugging-related output that I was trying to
use while trying to build the support.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Jon Ross-Perkins 2 лет назад
Родитель
Сommit
cad4605dad
100 измененных файлов с 339 добавлено и 165 удалено
  1. 2 2
      toolchain/base/value_store.h
  2. 1 0
      toolchain/check/BUILD
  3. 185 42
      toolchain/check/check.cpp
  4. 1 0
      toolchain/check/context.cpp
  5. 16 0
      toolchain/check/decl_name_stack.h
  6. 3 3
      toolchain/check/handle_binding_pattern.cpp
  7. 4 5
      toolchain/check/handle_class.cpp
  8. 4 4
      toolchain/check/handle_function.cpp
  9. 4 5
      toolchain/check/handle_interface.cpp
  10. 3 2
      toolchain/check/handle_namespace.cpp
  11. 1 1
      toolchain/check/testdata/array/array_in_place.carbon
  12. 1 1
      toolchain/check/testdata/array/assign_return_value.carbon
  13. 1 1
      toolchain/check/testdata/array/assign_var.carbon
  14. 1 1
      toolchain/check/testdata/array/base.carbon
  15. 1 1
      toolchain/check/testdata/array/fail_bound_overflow.carbon
  16. 1 1
      toolchain/check/testdata/array/fail_incomplete_element.carbon
  17. 1 1
      toolchain/check/testdata/array/fail_invalid_type.carbon
  18. 1 1
      toolchain/check/testdata/array/fail_out_of_bound.carbon
  19. 1 1
      toolchain/check/testdata/array/fail_type_mismatch.carbon
  20. 1 1
      toolchain/check/testdata/array/function_param.carbon
  21. 1 1
      toolchain/check/testdata/array/nine_elements.carbon
  22. 1 1
      toolchain/check/testdata/as/as_type.carbon
  23. 1 1
      toolchain/check/testdata/as/basic.carbon
  24. 1 1
      toolchain/check/testdata/as/fail_no_conversion.carbon
  25. 1 1
      toolchain/check/testdata/as/fail_not_type.carbon
  26. 1 1
      toolchain/check/testdata/as/identity.carbon
  27. 1 1
      toolchain/check/testdata/as/tuple.carbon
  28. 3 1
      toolchain/check/testdata/basics/builtin_insts.carbon
  29. 1 1
      toolchain/check/testdata/basics/builtin_types.carbon
  30. 1 1
      toolchain/check/testdata/basics/empty.carbon
  31. 1 1
      toolchain/check/testdata/basics/empty_decl.carbon
  32. 1 1
      toolchain/check/testdata/basics/fail_bad_run.carbon
  33. 1 1
      toolchain/check/testdata/basics/fail_bad_run_2.carbon
  34. 1 1
      toolchain/check/testdata/basics/fail_name_lookup.carbon
  35. 1 1
      toolchain/check/testdata/basics/fail_non_type_as_type.carbon
  36. 1 1
      toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon
  37. 2 2
      toolchain/check/testdata/basics/multifile.carbon
  38. 10 6
      toolchain/check/testdata/basics/multifile_raw_and_textual_ir.carbon
  39. 8 4
      toolchain/check/testdata/basics/multifile_raw_ir.carbon
  40. 1 1
      toolchain/check/testdata/basics/numeric_literals.carbon
  41. 1 1
      toolchain/check/testdata/basics/parens.carbon
  42. 5 3
      toolchain/check/testdata/basics/raw_and_textual_ir.carbon
  43. 1 1
      toolchain/check/testdata/basics/raw_identifier.carbon
  44. 4 2
      toolchain/check/testdata/basics/raw_ir.carbon
  45. 1 1
      toolchain/check/testdata/basics/run.carbon
  46. 1 1
      toolchain/check/testdata/basics/run_i32.carbon
  47. 1 1
      toolchain/check/testdata/basics/textual_ir.carbon
  48. 1 1
      toolchain/check/testdata/class/base.carbon
  49. 1 1
      toolchain/check/testdata/class/base_field.carbon
  50. 1 1
      toolchain/check/testdata/class/base_function_unqualified.carbon
  51. 1 1
      toolchain/check/testdata/class/base_method.carbon
  52. 1 1
      toolchain/check/testdata/class/base_method_shadow.carbon
  53. 1 1
      toolchain/check/testdata/class/basic.carbon
  54. 1 1
      toolchain/check/testdata/class/derived_to_base.carbon
  55. 1 1
      toolchain/check/testdata/class/fail_abstract.carbon
  56. 1 1
      toolchain/check/testdata/class/fail_addr_not_self.carbon
  57. 1 1
      toolchain/check/testdata/class/fail_addr_self.carbon
  58. 1 1
      toolchain/check/testdata/class/fail_base_bad_type.carbon
  59. 1 1
      toolchain/check/testdata/class/fail_base_method_define.carbon
  60. 1 1
      toolchain/check/testdata/class/fail_base_modifiers.carbon
  61. 1 1
      toolchain/check/testdata/class/fail_base_no_extend.carbon
  62. 1 1
      toolchain/check/testdata/class/fail_base_repeated.carbon
  63. 1 1
      toolchain/check/testdata/class/fail_base_unbound.carbon
  64. 1 1
      toolchain/check/testdata/class/fail_derived_to_base.carbon
  65. 1 1
      toolchain/check/testdata/class/fail_field_modifiers.carbon
  66. 1 1
      toolchain/check/testdata/class/fail_incomplete.carbon
  67. 1 1
      toolchain/check/testdata/class/fail_init.carbon
  68. 1 1
      toolchain/check/testdata/class/fail_init_as_inplace.carbon
  69. 1 1
      toolchain/check/testdata/class/fail_memaccess_category.carbon
  70. 1 1
      toolchain/check/testdata/class/fail_member_of_let.carbon
  71. 1 1
      toolchain/check/testdata/class/fail_method.carbon
  72. 1 1
      toolchain/check/testdata/class/fail_method_modifiers.carbon
  73. 1 1
      toolchain/check/testdata/class/fail_modifiers.carbon
  74. 1 1
      toolchain/check/testdata/class/fail_out_of_line_decl.carbon
  75. 1 1
      toolchain/check/testdata/class/fail_redeclaration_introducer.carbon
  76. 1 1
      toolchain/check/testdata/class/fail_redeclaration_scope.carbon
  77. 1 1
      toolchain/check/testdata/class/fail_redefinition.carbon
  78. 1 1
      toolchain/check/testdata/class/fail_reorder.carbon
  79. 1 1
      toolchain/check/testdata/class/fail_scope.carbon
  80. 1 1
      toolchain/check/testdata/class/fail_self.carbon
  81. 1 1
      toolchain/check/testdata/class/fail_todo_modifiers.carbon
  82. 1 1
      toolchain/check/testdata/class/fail_unbound_field.carbon
  83. 1 1
      toolchain/check/testdata/class/fail_unknown_member.carbon
  84. 1 1
      toolchain/check/testdata/class/field_access.carbon
  85. 1 1
      toolchain/check/testdata/class/field_access_in_value.carbon
  86. 1 1
      toolchain/check/testdata/class/forward_declared.carbon
  87. 1 1
      toolchain/check/testdata/class/init.carbon
  88. 1 1
      toolchain/check/testdata/class/init_as.carbon
  89. 1 1
      toolchain/check/testdata/class/init_nested.carbon
  90. 1 1
      toolchain/check/testdata/class/method.carbon
  91. 1 1
      toolchain/check/testdata/class/nested.carbon
  92. 1 1
      toolchain/check/testdata/class/nested_name.carbon
  93. 1 1
      toolchain/check/testdata/class/raw_self.carbon
  94. 1 1
      toolchain/check/testdata/class/raw_self_type.carbon
  95. 1 1
      toolchain/check/testdata/class/redeclaration.carbon
  96. 1 1
      toolchain/check/testdata/class/redeclaration_introducer.carbon
  97. 1 1
      toolchain/check/testdata/class/reenter_scope.carbon
  98. 1 1
      toolchain/check/testdata/class/scope.carbon
  99. 1 1
      toolchain/check/testdata/class/self.carbon
  100. 1 1
      toolchain/check/testdata/class/self_conversion.carbon

+ 2 - 2
toolchain/base/value_store.h

@@ -146,13 +146,13 @@ class ValueStore
 
   // Returns a mutable value for an ID.
   auto Get(IdT id) -> ValueType& {
-    CARBON_CHECK(id.index >= 0) << id.index;
+    CARBON_CHECK(id.index >= 0) << id;
     return values_[id.index];
   }
 
   // Returns the value for an ID.
   auto Get(IdT id) const -> const ValueType& {
-    CARBON_CHECK(id.index >= 0) << id.index;
+    CARBON_CHECK(id.index >= 0) << id;
     return values_[id.index];
   }
 

+ 1 - 0
toolchain/check/BUILD

@@ -89,6 +89,7 @@ cc_library(
         "//toolchain/sem_ir:ids",
         "//toolchain/sem_ir:inst",
         "//toolchain/sem_ir:inst_kind",
+        "//toolchain/sem_ir:value_stores",
         "@llvm-project//llvm:Support",
     ],
 )

+ 185 - 42
toolchain/check/check.cpp

@@ -10,11 +10,14 @@
 #include "toolchain/check/context.h"
 #include "toolchain/diagnostics/diagnostic_emitter.h"
 #include "toolchain/lex/token_kind.h"
+#include "toolchain/parse/node_ids.h"
 #include "toolchain/parse/tree.h"
 #include "toolchain/parse/tree_node_location_translator.h"
 #include "toolchain/sem_ir/file.h"
 #include "toolchain/sem_ir/ids.h"
+#include "toolchain/sem_ir/inst.h"
 #include "toolchain/sem_ir/typed_insts.h"
+#include "toolchain/sem_ir/value_stores.h"
 
 namespace Carbon::Check {
 
@@ -74,46 +77,169 @@ struct UnitInfo {
   llvm::SmallVector<UnitInfo*> incoming_imports;
 };
 
-// Returns the NameId for the entity. May return Invalid for a TODO.
-// TODO: This will need to handle enclosing namespaces.
-static auto GetImportNameId(Parse::NodeId parse_node, Context& context,
-                            const SemIR::File& import_sem_ir,
-                            SemIR::InstId import_inst_id) -> SemIR::NameId {
-  auto import_inst = import_sem_ir.insts().Get(import_inst_id);
-
+// Returns name information for the entity, corresponding to IDs in the import
+// IR rather than the current IR. May return Invalid for a TODO.
+static auto GetImportName(Parse::NodeId parse_node, Context& context,
+                          const SemIR::File& import_sem_ir,
+                          SemIR::Inst import_inst)
+    -> std::pair<SemIR::NameId, SemIR::NameScopeId> {
   switch (import_inst.kind()) {
     case SemIR::InstKind::BindName: {
-      auto bind_name = import_inst.As<SemIR::BindName>();
-      return import_sem_ir.bind_names().Get(bind_name.bind_name_id).name_id;
+      const auto& bind_name = import_sem_ir.bind_names().Get(
+          import_inst.As<SemIR::BindName>().bind_name_id);
+      return {bind_name.name_id, bind_name.enclosing_scope_id};
     }
 
     case SemIR::InstKind::FunctionDecl: {
-      auto bind_name = import_inst.As<SemIR::FunctionDecl>();
-      return import_sem_ir.functions().Get(bind_name.function_id).name_id;
+      const auto& function = import_sem_ir.functions().Get(
+          import_inst.As<SemIR::FunctionDecl>().function_id);
+      return {function.name_id, function.enclosing_scope_id};
+    }
+
+    case SemIR::InstKind::Namespace: {
+      auto namespace_inst = import_inst.As<SemIR::Namespace>();
+      const auto& scope =
+          import_sem_ir.name_scopes().Get(namespace_inst.name_scope_id);
+      return {namespace_inst.name_id, scope.enclosing_scope_id};
     }
 
     default:
-      context.TODO(parse_node, (llvm::Twine("Support GetImportNameId of ") +
+      context.TODO(parse_node, (llvm::Twine("Support GetImportName of ") +
                                 import_inst.kind().name())
                                    .str());
-      return SemIR::NameId::Invalid;
+      return {SemIR::NameId::Invalid, SemIR::NameScopeId::Invalid};
+  }
+}
+
+// Translate the name to the current IR. It will usually be an identifier, but
+// could also be a builtin name ID which is equivalent cross-IR.
+static auto CopyNameFromImportIR(Context& context,
+                                 const SemIR::File& import_sem_ir,
+                                 SemIR::NameId import_name_id) {
+  if (auto import_identifier_id = import_name_id.AsIdentifierId();
+      import_identifier_id.is_valid()) {
+    auto name = import_sem_ir.identifiers().Get(import_identifier_id);
+    return SemIR::NameId::ForIdentifier(context.identifiers().Add(name));
+  }
+  return import_name_id;
+}
+
+// Creates a namespace. The type ID is builtin, and reused to avoid duplicative
+// canonicalization.
+static auto AddNamespace(Context& context,
+                         SemIR::NameScopeId enclosing_scope_id,
+                         SemIR::NameId name_id, SemIR::TypeId namespace_type_id)
+    -> std::pair<SemIR::InstId, SemIR::NameScopeId> {
+  // Use the invalid node because there's no node to associate with.
+  auto inst = SemIR::Namespace{Parse::NodeId::Invalid, namespace_type_id,
+                               name_id, SemIR::NameScopeId::Invalid};
+  auto id = context.AddInst(inst);
+  inst.name_scope_id = context.name_scopes().Add(id, enclosing_scope_id);
+  context.insts().Set(id, inst);
+  return {id, inst.name_scope_id};
+}
+
+static auto CacheCopiedNamespace(
+    llvm::DenseMap<SemIR::NameScopeId, SemIR::NameScopeId>& copied_namespaces,
+    SemIR::NameScopeId import_scope_id, SemIR::NameScopeId to_scope_id)
+    -> void {
+  auto [it, success] = copied_namespaces.insert({import_scope_id, to_scope_id});
+  CARBON_CHECK(success || it->second == to_scope_id)
+      << "Copy result for namespace changed from " << import_scope_id << " to "
+      << to_scope_id;
+}
+
+// Copies enclosing name scopes from the import IR. Handles the parent
+// traversal. Returns the NameScope corresponding to the copied
+// import_enclosing_scope_id.
+static auto CopyEnclosingNameScopeFromImportIR(
+    Context& context, SemIR::TypeId namespace_type_id,
+    const SemIR::File& import_sem_ir,
+    SemIR::NameScopeId import_enclosing_scope_id,
+    llvm::DenseMap<SemIR::NameScopeId, SemIR::NameScopeId>& copied_namespaces)
+    -> SemIR::NameScopeId {
+  // Package-level names don't need work.
+  if (import_enclosing_scope_id == SemIR::NameScopeId::Package) {
+    return import_enclosing_scope_id;
   }
+
+  // The scope to add namespaces to. Note this may change while looking at
+  // enclosing scopes, if we encounter a namespace that's already added.
+  auto scope_cursor = SemIR::NameScopeId::Package;
+
+  // Build a stack of enclosing namespace names, with innermost first.
+  llvm::SmallVector<std::pair<SemIR::NameScopeId, SemIR::NameId>>
+      new_namespaces;
+  while (import_enclosing_scope_id != SemIR::NameScopeId::Package) {
+    // If the namespace was already copied, reuse the results.
+    if (auto it = copied_namespaces.find(import_enclosing_scope_id);
+        it != copied_namespaces.end()) {
+      // We inject names at the provided scope, and don't need to keep
+      // traversing parents.
+      scope_cursor = it->second;
+      break;
+    }
+
+    // The namespace hasn't been copied yet, so add it to our list.
+    const auto& scope =
+        import_sem_ir.name_scopes().Get(import_enclosing_scope_id);
+    auto scope_inst =
+        import_sem_ir.insts().GetAs<SemIR::Namespace>(scope.inst_id);
+    new_namespaces.push_back({scope_inst.name_scope_id, scope_inst.name_id});
+    import_enclosing_scope_id = scope.enclosing_scope_id;
+  }
+
+  // Add enclosing namespace names, starting with the outermost.
+  for (auto import_namespace : llvm::reverse(new_namespaces)) {
+    auto name_id =
+        CopyNameFromImportIR(context, import_sem_ir, import_namespace.second);
+    auto& scope = context.name_scopes().Get(scope_cursor);
+    auto [it, success] = scope.names.insert({name_id, SemIR::InstId::Invalid});
+    if (!success) {
+      auto inst = context.insts().Get(it->second);
+      if (auto namespace_inst = inst.TryAs<SemIR::Namespace>()) {
+        // Namespaces are open, so we can append to the existing one even if it
+        // comes from a different file.
+        scope_cursor = namespace_inst->name_scope_id;
+        CacheCopiedNamespace(copied_namespaces, import_namespace.first,
+                             scope_cursor);
+        continue;
+      }
+      // Produce a diagnostic, but still produce the namespace to supersede the
+      // name conflict in order to avoid repeat diagnostics.
+      // TODO: Produce a diagnostic.
+    }
+
+    // Produce the namespace for the entry.
+    auto [namespace_id, name_scope_id] =
+        AddNamespace(context, scope_cursor, name_id, namespace_type_id);
+
+    it->second = namespace_id;
+    scope_cursor = name_scope_id;
+    CacheCopiedNamespace(copied_namespaces, import_namespace.first,
+                         scope_cursor);
+  }
+
+  return scope_cursor;
 }
 
 // Add imports to the root block.
 static auto InitPackageScopeAndImports(Context& context, UnitInfo& unit_info)
     -> void {
+  // Importing makes many namespaces, so only canonicalize the type once.
+  auto namespace_type_id =
+      context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType);
+
   // Define the package scope, with an instruction for `package` expressions to
   // reference.
-  auto package_scope_id =
-      context.name_scopes().Add(SemIR::InstId::PackageNamespace);
+  auto package_scope_id = context.name_scopes().Add(
+      SemIR::InstId::PackageNamespace, SemIR::NameScopeId::Invalid);
   CARBON_CHECK(package_scope_id == SemIR::NameScopeId::Package);
 
-  auto package_inst = context.AddInst(SemIR::Namespace{
-      Parse::NodeId::Invalid,
-      context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType),
-      SemIR::NameScopeId::Package});
-  CARBON_CHECK(package_inst == SemIR::InstId::PackageNamespace);
+  auto package_inst_id = context.AddInst(SemIR::Namespace{
+      Parse::NodeId::Invalid, namespace_type_id,
+      SemIR::NameId::PackageNamespace, SemIR::NameScopeId::Package});
+  CARBON_CHECK(package_inst_id == SemIR::InstId::PackageNamespace);
 
   // Add imports from the current package.
   auto self_import = unit_info.package_imports_map.find(IdentifierId::Invalid);
@@ -133,39 +259,56 @@ static auto InitPackageScopeAndImports(Context& context, UnitInfo& unit_info)
 
       auto ir_id = context.sem_ir().cross_ref_irs().Add(&import_sem_ir);
 
+      llvm::DenseMap<SemIR::NameScopeId, SemIR::NameScopeId> copied_namespaces;
       for (const auto import_inst_id :
            import_sem_ir.inst_blocks().Get(SemIR::InstBlockId::Exports)) {
-        // TODO: Handle enclosing namespaces.
-        auto name_id = GetImportNameId(self_import->second.node, context,
-                                       import_sem_ir, import_inst_id);
-
-        // Translate the name to the current IR. It will usually be an
-        // identifier, but could also be a builtin name ID which is
-        // equivalent cross-IR.
-        if (auto import_identifier_id = name_id.AsIdentifierId();
-            import_identifier_id.is_valid()) {
-          auto name = import_sem_ir.identifiers().Get(import_identifier_id);
-          name_id =
-              SemIR::NameId::ForIdentifier(context.identifiers().Add(name));
+        auto import_inst = import_sem_ir.insts().Get(import_inst_id);
+        auto [import_name_id, import_enclosing_scope_id] = GetImportName(
+            self_import->second.node, context, import_sem_ir, import_inst);
+        // TODO: This should only be invalid when GetImportName for an inst
+        // isn't yet implemented. Long-term this should be removed.
+        if (!import_name_id.is_valid()) {
+          continue;
         }
 
-        // Leave a placeholder that the inst comes from the other IR.
-        auto target_id = context.AddInst(
-            SemIR::LazyImportRef{.ir_id = ir_id, .inst_id = import_inst_id});
-        // TODO: When importing from other packages, the scope's names should be
-        // changed to allow for ambiguous names. When importing from the current
-        // package, as is currently being done, we should issue a diagnostic on
-        // conflicts.
-        package_scope.names.insert({name_id, target_id});
+        auto name_id =
+            CopyNameFromImportIR(context, import_sem_ir, import_name_id);
+        SemIR::NameScopeId enclosing_scope_id =
+            CopyEnclosingNameScopeFromImportIR(
+                context, namespace_type_id, import_sem_ir,
+                import_enclosing_scope_id, copied_namespaces);
+
+        if (auto import_namespace_inst =
+                import_inst.TryAs<SemIR::Namespace>()) {
+          // Namespaces are always imported because they're essential for
+          // qualifiers, and the type is simple.
+          auto [namespace_id, name_scope_id] = AddNamespace(
+              context, enclosing_scope_id, name_id, namespace_type_id);
+          context.name_scopes().AddEntry(enclosing_scope_id, name_id,
+                                         namespace_id);
+          CacheCopiedNamespace(copied_namespaces,
+                               import_namespace_inst->name_scope_id,
+                               name_scope_id);
+        } else {
+          // Leave a placeholder that the inst comes from the other IR.
+          auto target_id = context.AddInst(
+              SemIR::LazyImportRef{.ir_id = ir_id, .inst_id = import_inst_id});
+          // TODO: When importing from other packages, the scope's names should
+          // be changed to allow for ambiguous names. When importing from the
+          // current package, as is currently being done, we should issue a
+          // diagnostic on conflicts.
+          context.name_scopes().AddEntry(enclosing_scope_id, name_id,
+                                         target_id);
+        }
       }
     }
 
     // Push the scope.
-    context.PushScope(package_inst, SemIR::NameScopeId::Package,
+    context.PushScope(package_inst_id, SemIR::NameScopeId::Package,
                       package_scope.has_error);
   } else {
     // Push the scope; there are no names to add.
-    context.PushScope(package_inst, SemIR::NameScopeId::Package);
+    context.PushScope(package_inst_id, SemIR::NameScopeId::Package);
   }
 
   for (auto& [package_id, package_imports] : unit_info.package_imports_map) {

+ 1 - 0
toolchain/check/context.cpp

@@ -181,6 +181,7 @@ auto Context::ResolveIfLazyImportRef(SemIR::InstId inst_id) -> void {
       // TODO: Fill this in better.
       auto function_id =
           functions().Add({.name_id = SemIR::NameId::Invalid,
+                           .enclosing_scope_id = SemIR::NameScopeId::Invalid,
                            .decl_id = inst_id,
                            .implicit_param_refs_id = SemIR::InstBlockId::Empty,
                            .param_refs_id = SemIR::InstBlockId::Empty,

+ 16 - 0
toolchain/check/decl_name_stack.h

@@ -104,6 +104,22 @@ class DeclNameStack {
       Error,
     };
 
+    // Returns the name_id for a new instruction. This is invalid when the name
+    // resolved.
+    auto name_id_for_new_inst() -> SemIR::NameId {
+      return state == State::Unresolved ? unresolved_name_id
+                                        : SemIR::NameId::Invalid;
+    }
+
+    // Returns the enclosing_scope_id for a new instruction. This is invalid
+    // when the name resolved. Note this is distinct from the enclosing_scope of
+    // the NameContext, which refers to the scope of the introducer rather than
+    // the scope of the name.
+    auto enclosing_scope_id_for_new_inst() -> SemIR::NameScopeId {
+      return state == State::Unresolved ? target_scope_id
+                                        : SemIR::NameScopeId::Invalid;
+    }
+
     // The current scope when this name began. This is the scope that we will
     // return to at the end of the declaration.
     ScopeIndex enclosing_scope;

+ 3 - 3
toolchain/check/handle_binding_pattern.cpp

@@ -25,10 +25,10 @@ auto HandleAnyBindingPattern(Context& context, Parse::NodeId parse_node,
   auto make_bind_name = [&, name_node = name_node, name_id = name_id](
                             SemIR::TypeId type_id,
                             SemIR::InstId value_id) -> SemIR::Inst {
-    // TODO: Set the correct enclosing_scope_id.
+    // TODO: Eventually the name will need to support associations with other
+    // scopes, but right now we don't support qualified names here.
     auto bind_name_id = context.bind_names().Add(
-        {.name_id = name_id,
-         .enclosing_scope_id = SemIR::NameScopeId::Invalid});
+        {.name_id = name_id, .enclosing_scope_id = context.current_scope_id()});
     if (is_generic) {
       // TODO: Create a `BindTemplateName` instead inside a `template` pattern.
       return SemIR::BindSymbolicName{name_node, type_id, bind_name_id,

+ 4 - 5
toolchain/check/handle_class.cpp

@@ -93,10 +93,8 @@ static auto BuildClassDecl(Context& context, Parse::AnyClassDeclId parse_node)
     // was an error in the qualifier, we will have lost track of the class name
     // here. We should keep track of it even if the name is invalid.
     class_decl.class_id = context.classes().Add(
-        {.name_id =
-             name_context.state == DeclNameStack::NameContext::State::Unresolved
-                 ? name_context.unresolved_name_id
-                 : SemIR::NameId::Invalid,
+        {.name_id = name_context.name_id_for_new_inst(),
+         .enclosing_scope_id = name_context.enclosing_scope_id_for_new_inst(),
          // `.self_type_id` depends on `class_id`, so is set below.
          .self_type_id = SemIR::TypeId::Invalid,
          .decl_id = class_decl_id,
@@ -142,7 +140,8 @@ auto HandleClassDefinitionStart(Context& context,
         .Emit();
   } else {
     class_info.definition_id = class_decl_id;
-    class_info.scope_id = context.name_scopes().Add(class_decl_id);
+    class_info.scope_id =
+        context.name_scopes().Add(class_decl_id, class_info.enclosing_scope_id);
   }
 
   // Enter the class scope.

+ 4 - 4
toolchain/check/handle_function.cpp

@@ -4,9 +4,11 @@
 
 #include "toolchain/check/context.h"
 #include "toolchain/check/convert.h"
+#include "toolchain/check/decl_name_stack.h"
 #include "toolchain/check/modifiers.h"
 #include "toolchain/parse/tree_node_location_translator.h"
 #include "toolchain/sem_ir/entry_point.h"
+#include "toolchain/sem_ir/ids.h"
 
 namespace Carbon::Check {
 
@@ -169,10 +171,8 @@ static auto BuildFunctionDecl(Context& context,
   // Create a new function if this isn't a valid redeclaration.
   if (!function_decl.function_id.is_valid()) {
     function_decl.function_id = context.functions().Add(
-        {.name_id =
-             name_context.state == DeclNameStack::NameContext::State::Unresolved
-                 ? name_context.unresolved_name_id
-                 : SemIR::NameId::Invalid,
+        {.name_id = name_context.name_id_for_new_inst(),
+         .enclosing_scope_id = name_context.enclosing_scope_id_for_new_inst(),
          .decl_id = function_decl_id,
          .implicit_param_refs_id = implicit_param_refs_id,
          .param_refs_id = param_refs_id,

+ 4 - 5
toolchain/check/handle_interface.cpp

@@ -76,10 +76,8 @@ static auto BuildInterfaceDecl(Context& context,
     // invalid.
     // TODO: should have a `Self` type id member
     interface_decl.interface_id = context.interfaces().Add(
-        {.name_id =
-             name_context.state == DeclNameStack::NameContext::State::Unresolved
-                 ? name_context.unresolved_name_id
-                 : SemIR::NameId::Invalid,
+        {.name_id = name_context.name_id_for_new_inst(),
+         .enclosing_scope_id = name_context.enclosing_scope_id_for_new_inst(),
          .decl_id = interface_decl_id});
   }
 
@@ -116,7 +114,8 @@ auto HandleInterfaceDefinitionStart(
         .Emit();
   } else {
     interface_info.definition_id = interface_decl_id;
-    interface_info.scope_id = context.name_scopes().Add(interface_decl_id);
+    interface_info.scope_id = context.name_scopes().Add(
+        interface_decl_id, interface_info.enclosing_scope_id);
   }
 
   // Enter the interface scope.

+ 3 - 2
toolchain/check/handle_namespace.cpp

@@ -24,9 +24,10 @@ auto HandleNamespace(Context& context, Parse::NamespaceId parse_node) -> bool {
                        Lex::TokenKind::Namespace);
   auto namespace_inst = SemIR::Namespace{
       parse_node, context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType),
-      SemIR::NameScopeId::Invalid};
+      name_context.name_id_for_new_inst(), SemIR::NameScopeId::Invalid};
   auto namespace_id = context.AddInst(namespace_inst);
-  namespace_inst.name_scope_id = context.name_scopes().Add(namespace_id);
+  namespace_inst.name_scope_id = context.name_scopes().Add(
+      namespace_id, name_context.enclosing_scope_id_for_new_inst());
   context.insts().Set(namespace_id, namespace_inst);
   context.decl_name_stack().AddNameToLookup(name_context, namespace_id);
 

+ 1 - 1
toolchain/check/testdata/array/array_in_place.carbon

@@ -21,7 +21,7 @@ fn G() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.F = %F, .G = %G}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.F = %F, .G = %G}
 // CHECK:STDOUT:   %F: <function> = fn_decl @F
 // CHECK:STDOUT:   %G: <function> = fn_decl @G
 // CHECK:STDOUT: }

+ 1 - 1
toolchain/check/testdata/array/assign_return_value.carbon

@@ -19,7 +19,7 @@ fn Run() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.F = %F, .Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.F = %F, .Run = %Run}
 // CHECK:STDOUT:   %F: <function> = fn_decl @F
 // CHECK:STDOUT:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }

+ 1 - 1
toolchain/check/testdata/array/assign_var.carbon

@@ -17,7 +17,7 @@ var b: [i32; 3] = a;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a, .b = %b}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a, .b = %b}
 // CHECK:STDOUT:   %.loc7_22.1: (type, type, type) = tuple_literal (i32, i32, i32)
 // CHECK:STDOUT:   %.loc7_22.2: type = converted %.loc7_22.1, constants.%.loc7_22.2
 // CHECK:STDOUT:   %a.var: ref (i32, i32, i32) = var a

+ 1 - 1
toolchain/check/testdata/array/base.carbon

@@ -21,7 +21,7 @@ var c: [(); 5] = ((), (), (), (), (),);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a, .b = %b, .c = %c}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a, .b = %b, .c = %c}
 // CHECK:STDOUT:   %.loc7_14: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc7_15: type = array_type %.loc7_14, i32
 // CHECK:STDOUT:   %a.var: ref [i32; 1] = var a

+ 1 - 1
toolchain/check/testdata/array/fail_bound_overflow.carbon

@@ -12,7 +12,7 @@ var a: [1; 39999999999999999993];
 // CHECK:STDOUT: --- fail_bound_overflow.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a}
 // CHECK:STDOUT:   %.loc10_9: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_12: i32 = int_literal 39999999999999999993
 // CHECK:STDOUT:   %a.var: ref <error> = var a

+ 1 - 1
toolchain/check/testdata/array/fail_incomplete_element.carbon

@@ -26,7 +26,7 @@ var p: Incomplete* = &a[0];
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Incomplete = %Incomplete.decl, .a = %a, .p = %p}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Incomplete = %Incomplete.decl, .a = %a, .p = %p}
 // CHECK:STDOUT:   %Incomplete.decl = class_decl @Incomplete, ()
 // CHECK:STDOUT:   %Incomplete: type = class_type @Incomplete
 // CHECK:STDOUT:   %Incomplete.ref.loc15: type = name_ref Incomplete, %Incomplete

+ 1 - 1
toolchain/check/testdata/array/fail_invalid_type.carbon

@@ -16,7 +16,7 @@ var a: [1; 1];
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a}
 // CHECK:STDOUT:   %.loc10_9: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_12: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_13: type = array_type %.loc10_12, <error>

+ 1 - 1
toolchain/check/testdata/array/fail_out_of_bound.carbon

@@ -17,7 +17,7 @@ var a: [i32; 1] = (1, 2, 3);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a}
 // CHECK:STDOUT:   %.loc10_14: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_15: type = array_type %.loc10_14, i32
 // CHECK:STDOUT:   %a.var: ref [i32; 1] = var a

+ 1 - 1
toolchain/check/testdata/array/fail_type_mismatch.carbon

@@ -41,7 +41,7 @@ var d: [i32; 3] = t2;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a, .t1 = %t1, .b = %b, .c = %c, .t2 = %t2, .d = %d}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a, .t1 = %t1, .b = %b, .c = %c, .t2 = %t2, .d = %d}
 // CHECK:STDOUT:   %.loc10_14: i32 = int_literal 3
 // CHECK:STDOUT:   %.loc10_15: type = array_type %.loc10_14, i32
 // CHECK:STDOUT:   %a.var: ref [i32; 3] = var a

+ 1 - 1
toolchain/check/testdata/array/function_param.carbon

@@ -20,7 +20,7 @@ fn G() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.F = %F, .G = %G}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.F = %F, .G = %G}
 // CHECK:STDOUT:   %F: <function> = fn_decl @F
 // CHECK:STDOUT:   %G: <function> = fn_decl @G
 // CHECK:STDOUT: }

+ 1 - 1
toolchain/check/testdata/array/nine_elements.carbon

@@ -14,7 +14,7 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a}
 // CHECK:STDOUT:   %.loc7_14: i32 = int_literal 9
 // CHECK:STDOUT:   %.loc7_15: type = array_type %.loc7_14, i32
 // CHECK:STDOUT:   %a.var: ref [i32; 9] = var a

+ 1 - 1
toolchain/check/testdata/as/as_type.carbon

@@ -14,7 +14,7 @@ let t: type = (i32, i32) as type;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {}
 // CHECK:STDOUT:   %.loc7_24: (type, type) = tuple_literal (i32, i32)
 // CHECK:STDOUT:   %.loc7_26: type = converted %.loc7_24, constants.%.loc7_26
 // CHECK:STDOUT:   %t: type = bind_name t, %.loc7_26

+ 1 - 1
toolchain/check/testdata/as/basic.carbon

@@ -11,7 +11,7 @@ fn Main() -> i32 {
 // CHECK:STDOUT: --- basic.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Main = %Main}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Main = %Main}
 // CHECK:STDOUT:   %Main: <function> = fn_decl @Main
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/as/fail_no_conversion.carbon

@@ -18,7 +18,7 @@ let n: (i32, i32) = 1 as (i32, i32);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {}
 // CHECK:STDOUT:   %.loc10_17.1: (type, type) = tuple_literal (i32, i32)
 // CHECK:STDOUT:   %.loc10_17.2: type = converted %.loc10_17.1, constants.%.loc10_17.2
 // CHECK:STDOUT:   %.loc10_21: i32 = int_literal 1

+ 1 - 1
toolchain/check/testdata/as/fail_not_type.carbon

@@ -12,7 +12,7 @@ let n: i32 = 1 as 2;
 // CHECK:STDOUT: --- fail_not_type.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {}
 // CHECK:STDOUT:   %.loc10_14: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_19: i32 = int_literal 2
 // CHECK:STDOUT:   %n: i32 = bind_name n, <error>

+ 1 - 1
toolchain/check/testdata/as/identity.carbon

@@ -33,7 +33,7 @@ fn Initializing() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.X = %X.decl, .Value = %Value, .Reference = %Reference, .Make = %Make, .Initializing = %Initializing}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.X = %X.decl, .Value = %Value, .Reference = %Reference, .Make = %Make, .Initializing = %Initializing}
 // CHECK:STDOUT:   %X.decl = class_decl @X, ()
 // CHECK:STDOUT:   %X: type = class_type @X
 // CHECK:STDOUT:   %Value: <function> = fn_decl @Value

+ 1 - 1
toolchain/check/testdata/as/tuple.carbon

@@ -33,7 +33,7 @@ fn Var() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.X = %X.decl, .Make = %Make, .Let = %Let, .Var = %Var}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.X = %X.decl, .Make = %Make, .Let = %Let, .Var = %Var}
 // CHECK:STDOUT:   %X.decl = class_decl @X, ()
 // CHECK:STDOUT:   %X: type = class_type @X
 // CHECK:STDOUT:   %Make: <function> = fn_decl @Make

+ 3 - 1
toolchain/check/testdata/basics/builtin_insts.carbon

@@ -10,6 +10,8 @@
 // CHECK:STDOUT: filename:        builtin_insts.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {}}
 // CHECK:STDOUT:   bind_names:      {}
 // CHECK:STDOUT:   functions:       {}
 // CHECK:STDOUT:   classes:         {}
@@ -26,7 +28,7 @@
 // CHECK:STDOUT:     instFunctionType: {kind: CrossRef, arg0: ir0, arg1: instFunctionType, type: typeTypeType}
 // CHECK:STDOUT:     instBoundMethodType: {kind: CrossRef, arg0: ir0, arg1: instBoundMethodType, type: typeTypeType}
 // CHECK:STDOUT:     instNamespaceType: {kind: CrossRef, arg0: ir0, arg1: instNamespaceType, type: typeTypeType}
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     empty:           {}
 // CHECK:STDOUT:     exports:         {}

+ 1 - 1
toolchain/check/testdata/basics/builtin_types.carbon

@@ -16,7 +16,7 @@ var test_type: type = i32;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.test_i32 = %test_i32, .test_f64 = %test_f64, .test_type = %test_type}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.test_i32 = %test_i32, .test_f64 = %test_f64, .test_type = %test_type}
 // CHECK:STDOUT:   %test_i32.var: ref i32 = var test_i32
 // CHECK:STDOUT:   %test_i32: ref i32 = bind_name test_i32, %test_i32.var
 // CHECK:STDOUT:   %.loc7: i32 = int_literal 0

+ 1 - 1
toolchain/check/testdata/basics/empty.carbon

@@ -7,6 +7,6 @@
 // CHECK:STDOUT: --- empty.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/empty_decl.carbon

@@ -9,6 +9,6 @@
 // CHECK:STDOUT: --- empty_decl.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/fail_bad_run.carbon

@@ -20,7 +20,7 @@ fn Run() -> String {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Run = %Run}
 // CHECK:STDOUT:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/fail_bad_run_2.carbon

@@ -12,7 +12,7 @@ fn Run(n: i32) {}
 // CHECK:STDOUT: --- fail_bad_run_2.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Run = %Run}
 // CHECK:STDOUT:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/fail_name_lookup.carbon

@@ -14,7 +14,7 @@ fn Main() {
 // CHECK:STDOUT: --- fail_name_lookup.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Main = %Main}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Main = %Main}
 // CHECK:STDOUT:   %Main: <function> = fn_decl @Main
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/fail_non_type_as_type.carbon

@@ -12,7 +12,7 @@ var x: type = 42;
 // CHECK:STDOUT: --- fail_non_type_as_type.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.x = %x}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.x = %x}
 // CHECK:STDOUT:   %x.var: ref type = var x
 // CHECK:STDOUT:   %x: ref type = bind_name x, %x.var
 // CHECK:STDOUT:   %.loc10: i32 = int_literal 42

+ 1 - 1
toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon

@@ -13,7 +13,7 @@ var y: i32 = x.b;
 // CHECK:STDOUT: --- fail_qualifier_unsupported.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.x = %x, .y = %y}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.x = %x, .y = %y}
 // CHECK:STDOUT:   %x.var: ref i32 = var x
 // CHECK:STDOUT:   %x: ref i32 = bind_name x, %x.var
 // CHECK:STDOUT:   %y.var: ref i32 = var y

+ 2 - 2
toolchain/check/testdata/basics/multifile.carbon

@@ -17,7 +17,7 @@ fn B() {}
 // CHECK:STDOUT: --- a.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A}
 // CHECK:STDOUT:   %A: <function> = fn_decl @A
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -29,7 +29,7 @@ fn B() {}
 // CHECK:STDOUT: --- b.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B = %B}
 // CHECK:STDOUT:   %B: <function> = fn_decl @B
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 10 - 6
toolchain/check/testdata/basics/multifile_raw_and_textual_ir.carbon

@@ -22,16 +22,18 @@ fn B() {}
 // CHECK:STDOUT: filename:        a.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
 // CHECK:STDOUT:   bind_names:      {}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: empty, body: [block2]}
+// CHECK:STDOUT:     function0:       {name: name0, enclosing_scope: name_scope0, param_refs: empty, body: [block2]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
 // CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
 // CHECK:STDOUT:     type1:           {inst: instFunctionType, value_rep: {kind: copy, type: type1}}
 // CHECK:STDOUT:   type_blocks:     {}
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
 // CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
@@ -48,7 +50,7 @@ fn B() {}
 // CHECK:STDOUT: --- a.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A}
 // CHECK:STDOUT:   %A: <function> = fn_decl @A
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -61,16 +63,18 @@ fn B() {}
 // CHECK:STDOUT: filename:        b.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
 // CHECK:STDOUT:   bind_names:      {}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: empty, body: [block2]}
+// CHECK:STDOUT:     function0:       {name: name0, enclosing_scope: name_scope0, param_refs: empty, body: [block2]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
 // CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
 // CHECK:STDOUT:     type1:           {inst: instFunctionType, value_rep: {kind: copy, type: type1}}
 // CHECK:STDOUT:   type_blocks:     {}
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
 // CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
@@ -87,7 +91,7 @@ fn B() {}
 // CHECK:STDOUT: --- b.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B = %B}
 // CHECK:STDOUT:   %B: <function> = fn_decl @B
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 8 - 4
toolchain/check/testdata/basics/multifile_raw_ir.carbon

@@ -22,16 +22,18 @@ fn B() {}
 // CHECK:STDOUT: filename:        a.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
 // CHECK:STDOUT:   bind_names:      {}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: empty, body: [block2]}
+// CHECK:STDOUT:     function0:       {name: name0, enclosing_scope: name_scope0, param_refs: empty, body: [block2]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
 // CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
 // CHECK:STDOUT:     type1:           {inst: instFunctionType, value_rep: {kind: copy, type: type1}}
 // CHECK:STDOUT:   type_blocks:     {}
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
 // CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
@@ -48,16 +50,18 @@ fn B() {}
 // CHECK:STDOUT: filename:        b.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+1}}
 // CHECK:STDOUT:   bind_names:      {}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: empty, body: [block2]}
+// CHECK:STDOUT:     function0:       {name: name0, enclosing_scope: name_scope0, param_refs: empty, body: [block2]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
 // CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
 // CHECK:STDOUT:     type1:           {inst: instFunctionType, value_rep: {kind: copy, type: type1}}
 // CHECK:STDOUT:   type_blocks:     {}
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
 // CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:

+ 1 - 1
toolchain/check/testdata/basics/numeric_literals.carbon

@@ -35,7 +35,7 @@ fn F() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.F = %F}
 // CHECK:STDOUT:   %F: <function> = fn_decl @F
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/parens.carbon

@@ -10,7 +10,7 @@ var b: i32 = ((2));
 // CHECK:STDOUT: --- parens.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.a = %a, .b = %b}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.a = %a, .b = %b}
 // CHECK:STDOUT:   %a.var: ref i32 = var a
 // CHECK:STDOUT:   %a: ref i32 = bind_name a, %a.var
 // CHECK:STDOUT:   %.loc7: i32 = int_literal 1

+ 5 - 3
toolchain/check/testdata/basics/raw_and_textual_ir.carbon

@@ -16,10 +16,12 @@ fn Foo(n: i32) -> (i32, i32, f64) {
 // CHECK:STDOUT: filename:        raw_and_textual_ir.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+9}}
 // CHECK:STDOUT:   bind_names:
 // CHECK:STDOUT:     bindName0:       {name: name1, enclosing_scope: name_scope<invalid>}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: block2, return_type: type4, return_slot: inst+7, body: [block5]}
+// CHECK:STDOUT:     function0:       {name: name0, enclosing_scope: name_scope0, param_refs: block2, return_type: type4, return_slot: inst+7, body: [block5]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
 // CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
@@ -39,7 +41,7 @@ fn Foo(n: i32) -> (i32, i32, f64) {
 // CHECK:STDOUT:       1:               type1
 // CHECK:STDOUT:       2:               type3
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:     inst+1:          {kind: Param, arg0: name1, type: type1}
 // CHECK:STDOUT:     inst+2:          {kind: BindName, arg0: bindName0, arg1: inst+1, type: type1}
 // CHECK:STDOUT:     inst+3:          {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
@@ -114,7 +116,7 @@ fn Foo(n: i32) -> (i32, i32, f64) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/raw_identifier.carbon

@@ -23,7 +23,7 @@ fn C(r#if: i32) -> i32 {
 // CHECK:STDOUT: --- raw_identifier.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A, .B = %B, .C = %C}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A, .B = %B, .C = %C}
 // CHECK:STDOUT:   %A: <function> = fn_decl @A
 // CHECK:STDOUT:   %B: <function> = fn_decl @B
 // CHECK:STDOUT:   %C: <function> = fn_decl @C

+ 4 - 2
toolchain/check/testdata/basics/raw_ir.carbon

@@ -16,10 +16,12 @@ fn Foo(n: i32) -> (i32, i32, f64) {
 // CHECK:STDOUT: filename:        raw_ir.carbon
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
+// CHECK:STDOUT:   name_scopes:
+// CHECK:STDOUT:     name_scope0:     {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+9}}
 // CHECK:STDOUT:   bind_names:
 // CHECK:STDOUT:     bindName0:       {name: name1, enclosing_scope: name_scope<invalid>}
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: block2, return_type: type4, return_slot: inst+7, body: [block5]}
+// CHECK:STDOUT:     function0:       {name: name0, enclosing_scope: name_scope0, param_refs: block2, return_type: type4, return_slot: inst+7, body: [block5]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
 // CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
@@ -39,7 +41,7 @@ fn Foo(n: i32) -> (i32, i32, f64) {
 // CHECK:STDOUT:       1:               type1
 // CHECK:STDOUT:       2:               type3
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: namePackageNamespace, arg1: name_scope0, type: type0}
 // CHECK:STDOUT:     inst+1:          {kind: Param, arg0: name1, type: type1}
 // CHECK:STDOUT:     inst+2:          {kind: BindName, arg0: bindName0, arg1: inst+1, type: type1}
 // CHECK:STDOUT:     inst+3:          {kind: TupleType, arg0: typeBlock0, type: typeTypeType}

+ 1 - 1
toolchain/check/testdata/basics/run.carbon

@@ -9,7 +9,7 @@ fn Run() {}
 // CHECK:STDOUT: --- run.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Run = %Run}
 // CHECK:STDOUT:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/run_i32.carbon

@@ -9,7 +9,7 @@ fn Run() -> i32 { return 0; }
 // CHECK:STDOUT: --- run_i32.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Run = %Run}
 // CHECK:STDOUT:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 1
toolchain/check/testdata/basics/textual_ir.carbon

@@ -21,7 +21,7 @@ fn Foo(n: i32) -> (i32, i32, f64) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

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

@@ -38,7 +38,7 @@ fn Access(d: Derived) -> (i32, i32) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Base = %Base.decl, .Derived = %Derived.decl, .Make = %Make, .Access = %Access}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Base = %Base.decl, .Derived = %Derived.decl, .Make = %Make, .Access = %Access}
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()
 // CHECK:STDOUT:   %Base: type = class_type @Base
 // CHECK:STDOUT:   %Derived.decl = class_decl @Derived, ()

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

@@ -33,7 +33,7 @@ fn Access(p: Derived*) -> i32* {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Base = %Base.decl, .Derived = %Derived.decl, .Access = %Access}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Base = %Base.decl, .Derived = %Derived.decl, .Access = %Access}
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()
 // CHECK:STDOUT:   %Base: type = class_type @Base
 // CHECK:STDOUT:   %Derived.decl = class_decl @Derived, ()

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

@@ -29,7 +29,7 @@ fn Derived.H() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Base = %Base.decl, .Derived = %Derived.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Base = %Base.decl, .Derived = %Derived.decl}
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()
 // CHECK:STDOUT:   %Base: type = class_type @Base
 // CHECK:STDOUT:   %Derived.decl = class_decl @Derived, ()

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

@@ -34,7 +34,7 @@ fn Call(p: Derived*) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Base = %Base.decl, .Derived = %Derived.decl, .Call = %Call}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Base = %Base.decl, .Derived = %Derived.decl, .Call = %Call}
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()
 // CHECK:STDOUT:   %Base: type = class_type @Base
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -44,7 +44,7 @@ fn Call(a: A*, b: B*, c: C*, d: D*) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A.decl, .B = %B.decl, .C = %C.decl, .D = %D.decl, .Call = %Call}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A.decl, .B = %B.decl, .C = %C.decl, .D = %D.decl, .Call = %Call}
 // CHECK:STDOUT:   %A.decl = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()

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

@@ -29,7 +29,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .Run = %Run}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -52,7 +52,7 @@ fn ConvertInit() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A.decl, .B = %B.decl, .C = %C.decl, .ConvertCToB = %ConvertCToB, .ConvertBToA = %ConvertBToA, .ConvertCToA = %ConvertCToA, .ConvertValue = %ConvertValue, .ConvertRef = %ConvertRef, .ConvertInit = %ConvertInit}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A.decl, .B = %B.decl, .C = %C.decl, .ConvertCToB = %ConvertCToB, .ConvertBToA = %ConvertBToA, .ConvertCToA = %ConvertCToA, .ConvertValue = %ConvertValue, .ConvertRef = %ConvertRef, .ConvertInit = %ConvertInit}
 // CHECK:STDOUT:   %A.decl = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()

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

@@ -42,7 +42,7 @@ fn Access(d: Derived) -> (i32, i32) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Abstract = %Abstract.decl, .Derived = %Derived.decl, .Make = %Make, .Access = %Access}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Abstract = %Abstract.decl, .Derived = %Derived.decl, .Make = %Make, .Access = %Access}
 // CHECK:STDOUT:   %Abstract.decl = class_decl @Abstract, ()
 // CHECK:STDOUT:   %Abstract: type = class_type @Abstract
 // CHECK:STDOUT:   %Derived.decl = class_decl @Derived, ()

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

@@ -23,7 +23,7 @@ class Class {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT: }

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

@@ -47,7 +47,7 @@ fn F(c: Class, p: Class*) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .F = %F}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F.2

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

@@ -137,7 +137,7 @@ fn AccessMemberWithInvalidBaseFinal_NoMember(p: DeriveFromFinal*) -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Base = %Base.decl, .Final = %Final.decl, .DeriveFromError = %DeriveFromError.decl, .AccessMemberWithInvalidBaseError = %AccessMemberWithInvalidBaseError, .DeriveFromNonType = %DeriveFromNonType.decl, .AccessMemberWithInvalidBasNonType = %AccessMemberWithInvalidBasNonType, .DeriveFromi32 = %DeriveFromi32.decl, .ConvertToBadBasei32 = %ConvertToBadBasei32, .AccessMemberWithInvalidBasei32 = %AccessMemberWithInvalidBasei32, .DeriveFromTuple = %DeriveFromTuple.decl, .ConvertToBadBaseTuple = %ConvertToBadBaseTuple, .AccessMemberWithInvalidBaseTuple = %AccessMemberWithInvalidBaseTuple, .DeriveFromStruct = %DeriveFromStruct.decl, .ConvertToBadBaseStruct = %ConvertToBadBaseStruct, .AccessMemberWithInvalidBaseStruct = %AccessMemberWithInvalidBaseStruct, .Incomplete = %Incomplete.decl, .DeriveFromIncomplete = %DeriveFromIncomplete.decl, .ConvertToBadBaseIncomplete = %ConvertToBadBaseIncomplete, .AccessMemberWithInvalidBaseIncomplete = %AccessMemberWithInvalidBaseIncomplete, .DeriveFromFinal = %DeriveFromFinal.decl, .ConvertToBadBaseFinal = %ConvertToBadBaseFinal, .AccessMemberWithInvalidBaseFinal_WithMember = %AccessMemberWithInvalidBaseFinal_WithMember, .AccessMemberWithInvalidBaseFinal_NoMember = %AccessMemberWithInvalidBaseFinal_NoMember}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Base = %Base.decl, .Final = %Final.decl, .DeriveFromError = %DeriveFromError.decl, .AccessMemberWithInvalidBaseError = %AccessMemberWithInvalidBaseError, .DeriveFromNonType = %DeriveFromNonType.decl, .AccessMemberWithInvalidBasNonType = %AccessMemberWithInvalidBasNonType, .DeriveFromi32 = %DeriveFromi32.decl, .ConvertToBadBasei32 = %ConvertToBadBasei32, .AccessMemberWithInvalidBasei32 = %AccessMemberWithInvalidBasei32, .DeriveFromTuple = %DeriveFromTuple.decl, .ConvertToBadBaseTuple = %ConvertToBadBaseTuple, .AccessMemberWithInvalidBaseTuple = %AccessMemberWithInvalidBaseTuple, .DeriveFromStruct = %DeriveFromStruct.decl, .ConvertToBadBaseStruct = %ConvertToBadBaseStruct, .AccessMemberWithInvalidBaseStruct = %AccessMemberWithInvalidBaseStruct, .Incomplete = %Incomplete.decl, .DeriveFromIncomplete = %DeriveFromIncomplete.decl, .ConvertToBadBaseIncomplete = %ConvertToBadBaseIncomplete, .AccessMemberWithInvalidBaseIncomplete = %AccessMemberWithInvalidBaseIncomplete, .DeriveFromFinal = %DeriveFromFinal.decl, .ConvertToBadBaseFinal = %ConvertToBadBaseFinal, .AccessMemberWithInvalidBaseFinal_WithMember = %AccessMemberWithInvalidBaseFinal_WithMember, .AccessMemberWithInvalidBaseFinal_NoMember = %AccessMemberWithInvalidBaseFinal_NoMember}
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()
 // CHECK:STDOUT:   %Base: type = class_type @Base
 // CHECK:STDOUT:   %Final.decl = class_decl @Final, ()

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

@@ -36,7 +36,7 @@ fn D.C.F() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B.decl, .D = %D.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B = %B.decl, .D = %D.decl}
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()
 // CHECK:STDOUT:   %B: type = class_type @B
 // CHECK:STDOUT:   %D.decl = class_decl @D, ()

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

@@ -53,7 +53,7 @@ class C4 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B.decl, .C1 = %C1.decl, .C2 = %C2.decl, .C3 = %C3.decl, .C4 = %C4.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B = %B.decl, .C1 = %C1.decl, .C2 = %C2.decl, .C3 = %C3.decl, .C4 = %C4.decl}
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()
 // CHECK:STDOUT:   %B: type = class_type @B
 // CHECK:STDOUT:   %C1.decl = class_decl @C1, ()

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

@@ -23,7 +23,7 @@ class C {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B.decl, .C = %C.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B = %B.decl, .C = %C.decl}
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()
 // CHECK:STDOUT:   %B: type = class_type @B
 // CHECK:STDOUT:   %C.decl = class_decl @C, ()

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

@@ -40,7 +40,7 @@ class D {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B1 = %B1.decl, .B2 = %B2.decl, .C = %C.decl, .D = %D.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B1 = %B1.decl, .B2 = %B2.decl, .C = %C.decl, .D = %D.decl}
 // CHECK:STDOUT:   %B1.decl = class_decl @B1, ()
 // CHECK:STDOUT:   %B1: type = class_type @B1
 // CHECK:STDOUT:   %B2.decl = class_decl @B2, ()

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

@@ -25,7 +25,7 @@ let b: B = C.base;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B.decl, .C = %C.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.B = %B.decl, .C = %C.decl}
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()
 // CHECK:STDOUT:   %B: type = class_type @B
 // CHECK:STDOUT:   %C.decl = class_decl @C, ()

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

@@ -41,7 +41,7 @@ fn ConvertIncomplete(p: Incomplete*) -> A2* { return p; }
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A1 = %A1.decl, .A2 = %A2.decl, .B2 = %B2.decl, .ConvertUnrelated = %ConvertUnrelated, .Incomplete = %Incomplete.decl, .ConvertIncomplete = %ConvertIncomplete}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A1 = %A1.decl, .A2 = %A2.decl, .B2 = %B2.decl, .ConvertUnrelated = %ConvertUnrelated, .Incomplete = %Incomplete.decl, .ConvertIncomplete = %ConvertIncomplete}
 // CHECK:STDOUT:   %A1.decl = class_decl @A1, ()
 // CHECK:STDOUT:   %A1: type = class_type @A1
 // CHECK:STDOUT:   %A2.decl = class_decl @A2, ()

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

@@ -34,7 +34,7 @@ class Class {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT: }

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

@@ -123,7 +123,7 @@ fn CallReturnIncomplete() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .CallClassFunction = %CallClassFunction, .global_var = %global_var, .ConvertFromStruct = %ConvertFromStruct, .MemberAccess = %MemberAccess, .Copy = %Copy, .Let = %Let, .TakeIncomplete = %TakeIncomplete, .ReturnIncomplete = %ReturnIncomplete, .CallTakeIncomplete = %CallTakeIncomplete, .CallReturnIncomplete = %CallReturnIncomplete}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .CallClassFunction = %CallClassFunction, .global_var = %global_var, .ConvertFromStruct = %ConvertFromStruct, .MemberAccess = %MemberAccess, .Copy = %Copy, .Let = %Let, .TakeIncomplete = %TakeIncomplete, .ReturnIncomplete = %ReturnIncomplete, .CallTakeIncomplete = %CallTakeIncomplete, .CallReturnIncomplete = %CallReturnIncomplete}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %.loc15: <function> = fn_decl @.1

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

@@ -35,7 +35,7 @@ fn F() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .F = %F}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -31,7 +31,7 @@ fn F() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .G = %G, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .G = %G, .F = %F}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -45,7 +45,7 @@ fn F(s: {.a: A}, b: B) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A.decl, .B = %B.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A.decl, .B = %B.decl, .F = %F}
 // CHECK:STDOUT:   %A.decl = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()

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

@@ -25,7 +25,7 @@ fn T.F() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Class.ref: type = name_ref Class, %Class

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

@@ -39,7 +39,7 @@ fn F(c: Class) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .F = %F}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -54,7 +54,7 @@ base class BaseClass {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.FinalClass = %FinalClass.decl, .AbstractClass = %AbstractClass.decl, .BaseClass = %BaseClass.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.FinalClass = %FinalClass.decl, .AbstractClass = %AbstractClass.decl, .BaseClass = %BaseClass.decl}
 // CHECK:STDOUT:   %FinalClass.decl = class_decl @FinalClass, ()
 // CHECK:STDOUT:   %FinalClass: type = class_type @FinalClass
 // CHECK:STDOUT:   %AbstractClass.decl = class_decl @AbstractClass, ()

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

@@ -71,7 +71,7 @@ abstract base class AbstractAndBase {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.DuplicatePrivate = %DuplicatePrivate.decl, .TwoAccess = %TwoAccess.decl, .TwoAbstract = %TwoAbstract.decl, .Virtual = %Virtual.decl, .WrongOrder = %WrongOrder.decl, .AbstractAndBase = %AbstractAndBase.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.DuplicatePrivate = %DuplicatePrivate.decl, .TwoAccess = %TwoAccess.decl, .TwoAbstract = %TwoAbstract.decl, .Virtual = %Virtual.decl, .WrongOrder = %WrongOrder.decl, .AbstractAndBase = %AbstractAndBase.decl}
 // CHECK:STDOUT:   %DuplicatePrivate.decl = class_decl @DuplicatePrivate, ()
 // CHECK:STDOUT:   %DuplicatePrivate: type = class_type @DuplicatePrivate
 // CHECK:STDOUT:   %TwoAccess.decl = class_decl @TwoAccess, ()

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

@@ -18,7 +18,7 @@ fn C.F() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.C = %C.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.C = %C.decl}
 // CHECK:STDOUT:   %C.decl = class_decl @C, ()
 // CHECK:STDOUT:   %C: type = class_type @C
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -81,7 +81,7 @@ base class G;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A.decl.loc7, .B = %B.decl.loc16, .C = %C.decl.loc25, .D = %D.decl.loc34, .E = %E.decl.loc43, .F = %F.decl.loc52, .G = %G.decl.loc61}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A.decl.loc7, .B = %B.decl.loc16, .C = %C.decl.loc25, .D = %D.decl.loc34, .E = %E.decl.loc43, .F = %F.decl.loc52, .G = %G.decl.loc61}
 // CHECK:STDOUT:   %A.decl.loc7 = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %A.decl.loc14 = class_decl @A, ()

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

@@ -28,7 +28,7 @@ class Y {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A.decl.loc7, .X = %X.decl, .Y = %Y.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A.decl.loc7, .X = %X.decl, .Y = %Y.decl}
 // CHECK:STDOUT:   %A.decl.loc7 = class_decl @A.1, ()
 // CHECK:STDOUT:   %A: type = class_type @A.1
 // CHECK:STDOUT:   %X.decl = class_decl @X, ()

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

@@ -31,7 +31,7 @@ fn Class.H() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl.loc7}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl.loc7}
 // CHECK:STDOUT:   %Class.decl.loc7 = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Class.decl.loc18 = class_decl @Class, ()

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

@@ -32,7 +32,7 @@ class Class {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT: }

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

@@ -24,7 +24,7 @@ fn G() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .G = %G}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .G = %G}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -59,7 +59,7 @@ fn CallWrongSelf(ws: WrongSelf) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .WrongSelf = %WrongSelf.decl, .CallWrongSelf = %CallWrongSelf}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .WrongSelf = %WrongSelf.decl, .CallWrongSelf = %CallWrongSelf}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F.1

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

@@ -66,7 +66,7 @@ abstract class Abstract {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Access = %Access.decl, .Base = %Base.decl, .Abstract = %Abstract.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Access = %Access.decl, .Base = %Base.decl, .Abstract = %Abstract.decl}
 // CHECK:STDOUT:   %Access.decl = class_decl @Access, ()
 // CHECK:STDOUT:   %Access: type = class_type @Access
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()

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

@@ -28,7 +28,7 @@ fn G() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .G = %G}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .G = %G}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -24,7 +24,7 @@ fn G(c: Class) -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .G = %G}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .G = %G}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -25,7 +25,7 @@ fn Run() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .Run = %Run}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Run: <function> = fn_decl @Run

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

@@ -26,7 +26,7 @@ fn Test() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .Test = %Test}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .Test = %Test}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Test: <function> = fn_decl @Test

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

@@ -11,7 +11,7 @@ fn F(p: Class*) -> Class* { return p; }
 // CHECK:STDOUT: --- forward_declared.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .F = %F}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -26,7 +26,7 @@ fn MakeReorder(n: i32, next: Class*) -> Class {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .Make = %Make, .MakeReorder = %MakeReorder}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .Make = %Make, .MakeReorder = %MakeReorder}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Make: <function> = fn_decl @Make

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

@@ -21,7 +21,7 @@ fn F() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .F = %F}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -32,7 +32,7 @@ fn MakeOuter() -> Outer {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Inner = %Inner.decl, .MakeInner = %MakeInner, .Outer = %Outer.decl, .MakeOuter = %MakeOuter}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Inner = %Inner.decl, .MakeInner = %MakeInner, .Outer = %Outer.decl, .MakeOuter = %MakeOuter}
 // CHECK:STDOUT:   %Inner.decl = class_decl @Inner, ()
 // CHECK:STDOUT:   %Inner: type = class_type @Inner
 // CHECK:STDOUT:   %MakeInner: <function> = fn_decl @MakeInner

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

@@ -52,7 +52,7 @@ fn CallGOnInitializingExpr() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .Call = %Call, .CallWithAddr = %CallWithAddr, .CallFThroughPointer = %CallFThroughPointer, .CallGThroughPointer = %CallGThroughPointer, .Make = %Make, .CallFOnInitializingExpr = %CallFOnInitializingExpr, .CallGOnInitializingExpr = %CallGOnInitializingExpr}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .Call = %Call, .CallWithAddr = %CallWithAddr, .CallFThroughPointer = %CallFThroughPointer, .CallGThroughPointer = %CallGThroughPointer, .Make = %Make, .CallFOnInitializingExpr = %CallFOnInitializingExpr, .CallGOnInitializingExpr = %CallGOnInitializingExpr}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -38,7 +38,7 @@ fn F(a: Outer*) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Outer = %Outer.decl, .F = %F}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Outer = %Outer.decl, .F = %F}
 // CHECK:STDOUT:   %Outer.decl = class_decl @Outer, ()
 // CHECK:STDOUT:   %Outer: type = class_type @Outer
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -29,7 +29,7 @@ fn G(o: Outer) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Outer = %Outer.decl, .F = %F, .G = %G}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Outer = %Outer.decl, .F = %F, .G = %G}
 // CHECK:STDOUT:   %Outer.decl = class_decl @Outer, ()
 // CHECK:STDOUT:   %Outer: type = class_type @Outer
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -29,7 +29,7 @@ fn Class.G[self: Class](r#self: i32) -> (i32, i32) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -18,7 +18,7 @@ class Class {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT: }

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

@@ -19,7 +19,7 @@ fn Class.F() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl.loc7}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl.loc7}
 // CHECK:STDOUT:   %Class.decl.loc7 = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Class.decl.loc9 = class_decl @Class, ()

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

@@ -19,7 +19,7 @@ abstract class C {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A.decl.loc7, .B = %B.decl.loc8, .C = %C.decl.loc9}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.A = %A.decl.loc7, .B = %B.decl.loc8, .C = %C.decl.loc9}
 // CHECK:STDOUT:   %A.decl.loc7 = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %B.decl.loc8 = class_decl @B, ()

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

@@ -20,7 +20,7 @@ fn Class.F() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -30,7 +30,7 @@ fn Run() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl, .F = %F, .Run = %Run}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl, .F = %F, .Run = %Run}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F.2

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

@@ -27,7 +27,7 @@ fn Class.G[addr self: Class*]() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Class = %Class.decl}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Class = %Class.decl}
 // CHECK:STDOUT:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -40,7 +40,7 @@ fn Call(p: Derived*) -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace {.Base = %Base.decl, .Derived = %Derived.decl, .Call = %Call}
+// CHECK:STDOUT:   package: <namespace> = namespace package, {.Base = %Base.decl, .Derived = %Derived.decl, .Call = %Call}
 // CHECK:STDOUT:   %Base.decl = class_decl @Base, ()
 // CHECK:STDOUT:   %Base: type = class_type @Base
 // CHECK:STDOUT:   %Derived.decl = class_decl @Derived, ()

Некоторые файлы не были показаны из-за большого количества измененных файлов