Parcourir la source

Add support for 'package' in expressions. (#3445)

This creates a namespace for `package` scope.

It looks like names of class_decls in namespaces lead to an unexpected
instref. This is already true, as best as I can tell. I'm not sure if
there's a preferred approach to address that, so I've left a TODO for
now.
Jon Ross-Perkins il y a 2 ans
Parent
commit
30155dbb72
100 fichiers modifiés avec 264 ajouts et 128 suppressions
  1. 12 2
      toolchain/check/check.cpp
  2. 10 0
      toolchain/check/handle_name.cpp
  3. 1 0
      toolchain/check/node_stack.h
  4. 1 0
      toolchain/check/testdata/array/array_in_place.carbon
  5. 1 0
      toolchain/check/testdata/array/assign_return_value.carbon
  6. 1 0
      toolchain/check/testdata/array/assign_var.carbon
  7. 1 0
      toolchain/check/testdata/array/base.carbon
  8. 1 0
      toolchain/check/testdata/array/fail_bound_overflow.carbon
  9. 1 0
      toolchain/check/testdata/array/fail_incomplete_element.carbon
  10. 1 0
      toolchain/check/testdata/array/fail_invalid_type.carbon
  11. 1 0
      toolchain/check/testdata/array/fail_out_of_bound.carbon
  12. 1 0
      toolchain/check/testdata/array/fail_type_mismatch.carbon
  13. 1 0
      toolchain/check/testdata/array/function_param.carbon
  14. 1 0
      toolchain/check/testdata/array/nine_elements.carbon
  15. 1 0
      toolchain/check/testdata/as/as_type.carbon
  16. 1 0
      toolchain/check/testdata/as/basic.carbon
  17. 1 0
      toolchain/check/testdata/as/fail_no_conversion.carbon
  18. 1 0
      toolchain/check/testdata/as/fail_not_type.carbon
  19. 1 0
      toolchain/check/testdata/as/identity.carbon
  20. 1 0
      toolchain/check/testdata/as/tuple.carbon
  21. 5 1
      toolchain/check/testdata/basics/builtin_insts.carbon
  22. 1 0
      toolchain/check/testdata/basics/builtin_types.carbon
  23. 1 0
      toolchain/check/testdata/basics/empty.carbon
  24. 1 0
      toolchain/check/testdata/basics/empty_decl.carbon
  25. 1 0
      toolchain/check/testdata/basics/fail_bad_run.carbon
  26. 1 0
      toolchain/check/testdata/basics/fail_bad_run_2.carbon
  27. 1 0
      toolchain/check/testdata/basics/fail_name_lookup.carbon
  28. 1 0
      toolchain/check/testdata/basics/fail_non_type_as_type.carbon
  29. 1 0
      toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon
  30. 2 0
      toolchain/check/testdata/basics/multifile.carbon
  31. 16 8
      toolchain/check/testdata/basics/multifile_raw_and_textual_ir.carbon
  32. 14 8
      toolchain/check/testdata/basics/multifile_raw_ir.carbon
  33. 1 0
      toolchain/check/testdata/basics/numeric_literals.carbon
  34. 1 0
      toolchain/check/testdata/basics/parens.carbon
  35. 55 51
      toolchain/check/testdata/basics/raw_and_textual_ir.carbon
  36. 1 0
      toolchain/check/testdata/basics/raw_identifier.carbon
  37. 54 51
      toolchain/check/testdata/basics/raw_ir.carbon
  38. 1 0
      toolchain/check/testdata/basics/run.carbon
  39. 1 0
      toolchain/check/testdata/basics/run_i32.carbon
  40. 1 0
      toolchain/check/testdata/basics/textual_ir.carbon
  41. 1 0
      toolchain/check/testdata/class/basic.carbon
  42. 1 0
      toolchain/check/testdata/class/fail_abstract.carbon
  43. 1 0
      toolchain/check/testdata/class/fail_addr_not_self.carbon
  44. 1 0
      toolchain/check/testdata/class/fail_addr_self.carbon
  45. 1 0
      toolchain/check/testdata/class/fail_incomplete.carbon
  46. 1 0
      toolchain/check/testdata/class/fail_init.carbon
  47. 1 0
      toolchain/check/testdata/class/fail_init_as_inplace.carbon
  48. 1 0
      toolchain/check/testdata/class/fail_memaccess_category.carbon
  49. 3 5
      toolchain/check/testdata/class/fail_member_of_let.carbon
  50. 1 0
      toolchain/check/testdata/class/fail_method.carbon
  51. 1 0
      toolchain/check/testdata/class/fail_redeclaration_introducer.carbon
  52. 1 0
      toolchain/check/testdata/class/fail_redeclaration_scope.carbon
  53. 3 2
      toolchain/check/testdata/class/fail_redefinition.carbon
  54. 1 0
      toolchain/check/testdata/class/fail_reorder.carbon
  55. 1 0
      toolchain/check/testdata/class/fail_scope.carbon
  56. 1 0
      toolchain/check/testdata/class/fail_self.carbon
  57. 1 0
      toolchain/check/testdata/class/fail_unbound_field.carbon
  58. 1 0
      toolchain/check/testdata/class/fail_unknown_member.carbon
  59. 1 0
      toolchain/check/testdata/class/field_access.carbon
  60. 1 0
      toolchain/check/testdata/class/field_access_in_value.carbon
  61. 1 0
      toolchain/check/testdata/class/forward_declared.carbon
  62. 1 0
      toolchain/check/testdata/class/init.carbon
  63. 1 0
      toolchain/check/testdata/class/init_as.carbon
  64. 1 0
      toolchain/check/testdata/class/init_nested.carbon
  65. 1 0
      toolchain/check/testdata/class/method.carbon
  66. 1 0
      toolchain/check/testdata/class/nested.carbon
  67. 1 0
      toolchain/check/testdata/class/nested_name.carbon
  68. 1 0
      toolchain/check/testdata/class/raw_self.carbon
  69. 1 0
      toolchain/check/testdata/class/raw_self_type.carbon
  70. 1 0
      toolchain/check/testdata/class/redeclaration.carbon
  71. 1 0
      toolchain/check/testdata/class/redeclaration_introducer.carbon
  72. 1 0
      toolchain/check/testdata/class/reenter_scope.carbon
  73. 1 0
      toolchain/check/testdata/class/scope.carbon
  74. 1 0
      toolchain/check/testdata/class/self.carbon
  75. 1 0
      toolchain/check/testdata/class/self_type.carbon
  76. 1 0
      toolchain/check/testdata/class/static_method.carbon
  77. 1 0
      toolchain/check/testdata/const/collapse.carbon
  78. 1 0
      toolchain/check/testdata/const/fail_collapse.carbon
  79. 1 0
      toolchain/check/testdata/expr_category/in_place_tuple_init.carbon
  80. 1 0
      toolchain/check/testdata/function/call/empty_struct.carbon
  81. 1 0
      toolchain/check/testdata/function/call/empty_tuple.carbon
  82. 1 0
      toolchain/check/testdata/function/call/fail_not_callable.carbon
  83. 1 0
      toolchain/check/testdata/function/call/fail_param_count.carbon
  84. 1 0
      toolchain/check/testdata/function/call/fail_param_type.carbon
  85. 1 0
      toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon
  86. 1 0
      toolchain/check/testdata/function/call/i32.carbon
  87. 1 0
      toolchain/check/testdata/function/call/more_param_ir.carbon
  88. 1 0
      toolchain/check/testdata/function/call/params_one.carbon
  89. 1 0
      toolchain/check/testdata/function/call/params_one_comma.carbon
  90. 1 0
      toolchain/check/testdata/function/call/params_two.carbon
  91. 1 0
      toolchain/check/testdata/function/call/params_two_comma.carbon
  92. 1 0
      toolchain/check/testdata/function/call/params_zero.carbon
  93. 1 0
      toolchain/check/testdata/function/call/return_implicit.carbon
  94. 1 0
      toolchain/check/testdata/function/declaration/simple.carbon
  95. 1 0
      toolchain/check/testdata/function/definition/fail_param_name_conflict.carbon
  96. 1 0
      toolchain/check/testdata/function/definition/order.carbon
  97. 1 0
      toolchain/check/testdata/function/definition/params_one.carbon
  98. 1 0
      toolchain/check/testdata/function/definition/params_one_comma.carbon
  99. 1 0
      toolchain/check/testdata/function/definition/params_two.carbon
  100. 1 0
      toolchain/check/testdata/function/definition/params_two_comma.carbon

+ 12 - 2
toolchain/check/check.cpp

@@ -13,6 +13,7 @@
 #include "toolchain/parse/tree.h"
 #include "toolchain/parse/tree_node_location_translator.h"
 #include "toolchain/sem_ir/file.h"
+#include "toolchain/sem_ir/typed_insts.h"
 
 namespace Carbon::Check {
 
@@ -120,9 +121,18 @@ static auto CheckParseTree(const SemIR::File& builtin_ir, UnitInfo& unit_info,
   PrettyStackTraceFunction context_dumper(
       [&](llvm::raw_ostream& output) { context.PrintForStackDump(output); });
 
-  // Add a block for the Parse::Tree.
+  // Add a block for the file.
   context.inst_block_stack().Push();
-  context.PushScope();
+
+  // Define the package scope, with an instruction for `package` expressions to
+  // reference.
+  auto package_scope = context.name_scopes().Add();
+  auto package_inst = context.AddInst(SemIR::Namespace{
+      Parse::NodeId::Invalid,
+      context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType),
+      package_scope});
+  CARBON_CHECK(package_inst == SemIR::InstId::PackageNamespace);
+  context.PushScope(SemIR::InstId::Invalid, package_scope);
 
   AddImports(context, unit_info);
 

+ 10 - 0
toolchain/check/handle_name.cpp

@@ -7,6 +7,7 @@
 #include "toolchain/check/convert.h"
 #include "toolchain/lex/token_kind.h"
 #include "toolchain/sem_ir/inst.h"
+#include "toolchain/sem_ir/typed_insts.h"
 
 namespace Carbon::Check {
 
@@ -272,6 +273,15 @@ auto HandleQualifiedDecl(Context& context, Parse::NodeId parse_node) -> bool {
   return true;
 }
 
+auto HandlePackageExpr(Context& context, Parse::NodeId parse_node) -> bool {
+  context.AddInstAndPush(
+      parse_node,
+      SemIR::NameRef{
+          parse_node, context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType),
+          SemIR::NameId::PackageNamespace, SemIR::InstId::PackageNamespace});
+  return true;
+}
+
 auto HandleSelfTypeNameExpr(Context& context, Parse::NodeId parse_node)
     -> bool {
   auto name_id = SemIR::NameId::SelfType;

+ 1 - 0
toolchain/check/node_stack.h

@@ -303,6 +303,7 @@ class NodeStack {
       case Parse::NodeKind::InfixOperator:
       case Parse::NodeKind::MemberAccessExpr:
       case Parse::NodeKind::NameExpr:
+      case Parse::NodeKind::PackageExpr:
       case Parse::NodeKind::ParenExpr:
       case Parse::NodeKind::PostfixOperator:
       case Parse::NodeKind::PrefixOperator:

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

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

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

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

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

@@ -17,6 +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:   %.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 - 0
toolchain/check/testdata/array/base.carbon

@@ -21,6 +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:   %.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 - 0
toolchain/check/testdata/array/fail_bound_overflow.carbon

@@ -12,6 +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:   %.loc10_9: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_12: i32 = int_literal 39999999999999999993
 // CHECK:STDOUT:   %a.var: ref <error> = var a

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

@@ -26,6 +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:   %Incomplete.decl = class_decl @Incomplete, ()
 // CHECK:STDOUT:   %Incomplete: type = class_type @Incomplete
 // CHECK:STDOUT:   %Incomplete.ref.loc15: type = name_ref Incomplete, %Incomplete

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

@@ -16,6 +16,7 @@ var a: [1; 1];
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/array/fail_out_of_bound.carbon

@@ -17,6 +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:   %.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 - 0
toolchain/check/testdata/array/fail_type_mismatch.carbon

@@ -41,6 +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:   %.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 - 0
toolchain/check/testdata/array/function_param.carbon

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

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

@@ -14,6 +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:   %.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 - 0
toolchain/check/testdata/as/as_type.carbon

@@ -14,6 +14,7 @@ let t: type = (i32, i32) as type;
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {}
 // 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 - 0
toolchain/check/testdata/as/basic.carbon

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

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

@@ -18,6 +18,7 @@ let n: (i32, i32) = 1 as (i32, i32);
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {}
 // 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 - 0
toolchain/check/testdata/as/fail_not_type.carbon

@@ -12,6 +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:   %.loc10_14: i32 = int_literal 1
 // CHECK:STDOUT:   %.loc10_19: i32 = int_literal 2
 // CHECK:STDOUT:   %n: i32 = bind_name n, <error>

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

@@ -33,6 +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:   %X.decl = class_decl @X, ()
 // CHECK:STDOUT:   %X: type = class_type @X
 // CHECK:STDOUT:   %Value: <function> = fn_decl @Value

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

@@ -33,6 +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:   %X.decl = class_decl @X, ()
 // CHECK:STDOUT:   %X: type = class_type @X
 // CHECK:STDOUT:   %Make: <function> = fn_decl @Make

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

@@ -12,7 +12,8 @@
 // CHECK:STDOUT:   cross_ref_irs_size: 1
 // CHECK:STDOUT:   functions:       {}
 // CHECK:STDOUT:   classes:         {}
-// CHECK:STDOUT:   types:           {}
+// CHECK:STDOUT:   types:
+// CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
 // CHECK:STDOUT:   type_blocks:     {}
 // CHECK:STDOUT:   insts:
 // CHECK:STDOUT:     instTypeType:    {kind: CrossRef, arg0: ir0, arg1: instTypeType, type: typeTypeType}
@@ -24,6 +25,9 @@
 // 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_blocks:
 // CHECK:STDOUT:     block0:          {}
+// CHECK:STDOUT:     block1:
+// CHECK:STDOUT:       0:               inst+0
 // CHECK:STDOUT: ...

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

@@ -16,6 +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:   %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 - 0
toolchain/check/testdata/basics/empty.carbon

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

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

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

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

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

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

@@ -12,6 +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:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

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

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

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

@@ -12,6 +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:   %x.var: ref type = var x
 // CHECK:STDOUT:   %x: ref type = bind_name x, %x.var
 // CHECK:STDOUT:   %.loc10: i32 = int_literal 42

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

@@ -13,6 +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:   %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 - 0
toolchain/check/testdata/basics/multifile.carbon

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

+ 16 - 8
toolchain/check/testdata/basics/multifile_raw_and_textual_ir.carbon

@@ -26,22 +26,26 @@ fn B() {}
 // CHECK:STDOUT:     function0:       {name: name0, param_refs: block0, body: [block1]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
-// CHECK:STDOUT:     type0:           {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
+// 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: FunctionDecl, arg0: function0, type: type0}
-// CHECK:STDOUT:     inst+1:          {kind: Return}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
+// CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     block0:          {}
 // CHECK:STDOUT:     block1:
-// CHECK:STDOUT:       0:               inst+1
+// CHECK:STDOUT:       0:               inst+2
 // CHECK:STDOUT:     block2:
 // CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT: ...
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- a.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.A = %A}
 // CHECK:STDOUT:   %A: <function> = fn_decl @A
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -58,22 +62,26 @@ fn B() {}
 // CHECK:STDOUT:     function0:       {name: name0, param_refs: block0, body: [block1]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
-// CHECK:STDOUT:     type0:           {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
+// 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: FunctionDecl, arg0: function0, type: type0}
-// CHECK:STDOUT:     inst+1:          {kind: Return}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
+// CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     block0:          {}
 // CHECK:STDOUT:     block1:
-// CHECK:STDOUT:       0:               inst+1
+// CHECK:STDOUT:       0:               inst+2
 // CHECK:STDOUT:     block2:
 // CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT: ...
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- b.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.B = %B}
 // CHECK:STDOUT:   %B: <function> = fn_decl @B
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

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

@@ -26,17 +26,20 @@ fn B() {}
 // CHECK:STDOUT:     function0:       {name: name0, param_refs: block0, body: [block1]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
-// CHECK:STDOUT:     type0:           {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
+// 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: FunctionDecl, arg0: function0, type: type0}
-// CHECK:STDOUT:     inst+1:          {kind: Return}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
+// CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     block0:          {}
 // CHECK:STDOUT:     block1:
-// CHECK:STDOUT:       0:               inst+1
+// CHECK:STDOUT:       0:               inst+2
 // CHECK:STDOUT:     block2:
 // CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT: ...
 // CHECK:STDOUT: ---
 // CHECK:STDOUT: filename:        b.carbon
@@ -46,15 +49,18 @@ fn B() {}
 // CHECK:STDOUT:     function0:       {name: name0, param_refs: block0, body: [block1]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
-// CHECK:STDOUT:     type0:           {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
+// 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: FunctionDecl, arg0: function0, type: type0}
-// CHECK:STDOUT:     inst+1:          {kind: Return}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+1:          {kind: FunctionDecl, arg0: function0, type: type1}
+// CHECK:STDOUT:     inst+2:          {kind: Return}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     block0:          {}
 // CHECK:STDOUT:     block1:
-// CHECK:STDOUT:       0:               inst+1
+// CHECK:STDOUT:       0:               inst+2
 // CHECK:STDOUT:     block2:
 // CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       1:               inst+1
 // CHECK:STDOUT: ...

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

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

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

@@ -9,6 +9,7 @@ var test_i32: i32 = ((1) + (2));
 // CHECK:STDOUT: --- parens.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.test_i32 = %test_i32}
 // 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_23: i32 = int_literal 1

+ 55 - 51
toolchain/check/testdata/basics/raw_and_textual_ir.carbon

@@ -17,76 +17,79 @@ fn Foo(n: i32) -> (i32, f64) {
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: block1, return_type: type3, return_slot: inst+5, body: [block4]}
+// CHECK:STDOUT:     function0:       {name: name0, param_refs: block1, return_type: type4, return_slot: inst+6, body: [block4]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
-// CHECK:STDOUT:     type0:           {inst: instIntType, value_rep: {kind: copy, type: type0}}
-// CHECK:STDOUT:     type1:           {inst: inst+1, value_rep: {kind: unknown, type: type<invalid>}}
-// CHECK:STDOUT:     type2:           {inst: instFloatType, value_rep: {kind: copy, type: type2}}
-// CHECK:STDOUT:     type3:           {inst: inst+3, value_rep: {kind: pointer, type: type4}}
-// CHECK:STDOUT:     type4:           {inst: inst+6, value_rep: {kind: copy, type: type4}}
-// CHECK:STDOUT:     type5:           {inst: instFunctionType, value_rep: {kind: copy, type: type5}}
+// CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
+// CHECK:STDOUT:     type1:           {inst: instIntType, value_rep: {kind: copy, type: type1}}
+// CHECK:STDOUT:     type2:           {inst: inst+2, value_rep: {kind: unknown, type: type<invalid>}}
+// CHECK:STDOUT:     type3:           {inst: instFloatType, value_rep: {kind: copy, type: type3}}
+// CHECK:STDOUT:     type4:           {inst: inst+4, value_rep: {kind: pointer, type: type5}}
+// CHECK:STDOUT:     type5:           {inst: inst+7, value_rep: {kind: copy, type: type5}}
+// CHECK:STDOUT:     type6:           {inst: instFunctionType, value_rep: {kind: copy, type: type6}}
 // CHECK:STDOUT:   type_blocks:
 // CHECK:STDOUT:     typeBlock0:
 // CHECK:STDOUT:       0:               typeTypeType
 // CHECK:STDOUT:       1:               typeTypeType
 // CHECK:STDOUT:     typeBlock1:
-// CHECK:STDOUT:       0:               type0
-// CHECK:STDOUT:       1:               type2
+// CHECK:STDOUT:       0:               type1
+// CHECK:STDOUT:       1:               type3
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Param, arg0: name1, type: type0}
-// CHECK:STDOUT:     inst+1:          {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
-// CHECK:STDOUT:     inst+2:          {kind: TupleLiteral, arg0: block2, type: type1}
-// CHECK:STDOUT:     inst+3:          {kind: TupleType, arg0: typeBlock1, type: typeTypeType}
-// CHECK:STDOUT:     inst+4:          {kind: Converted, arg0: inst+2, arg1: inst+3, type: typeTypeType}
-// CHECK:STDOUT:     inst+5:          {kind: VarStorage, arg0: nameReturnSlot, type: type3}
-// CHECK:STDOUT:     inst+6:          {kind: PointerType, arg0: type3, type: typeTypeType}
-// CHECK:STDOUT:     inst+7:          {kind: FunctionDecl, arg0: function0, type: type5}
-// CHECK:STDOUT:     inst+8:          {kind: NameRef, arg0: name1, arg1: inst+0, type: type0}
-// CHECK:STDOUT:     inst+9:          {kind: IntLiteral, arg0: int3, type: type0}
-// CHECK:STDOUT:     inst+10:         {kind: BinaryOperatorAdd, arg0: inst+8, arg1: inst+9, type: type0}
-// CHECK:STDOUT:     inst+11:         {kind: RealLiteral, arg0: real0, type: type2}
-// CHECK:STDOUT:     inst+12:         {kind: TupleLiteral, arg0: block5, type: type3}
-// CHECK:STDOUT:     inst+13:         {kind: TupleAccess, arg0: inst+5, arg1: element0, type: type0}
-// CHECK:STDOUT:     inst+14:         {kind: InitializeFrom, arg0: inst+10, arg1: inst+13, type: type0}
-// CHECK:STDOUT:     inst+15:         {kind: TupleAccess, arg0: inst+5, arg1: element1, type: type2}
-// CHECK:STDOUT:     inst+16:         {kind: InitializeFrom, arg0: inst+11, arg1: inst+15, type: type2}
-// CHECK:STDOUT:     inst+17:         {kind: TupleInit, arg0: block6, arg1: inst+5, type: type3}
-// CHECK:STDOUT:     inst+18:         {kind: Converted, arg0: inst+12, arg1: inst+17, type: type3}
-// CHECK:STDOUT:     inst+19:         {kind: ReturnExpr, arg0: inst+18}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+1:          {kind: Param, arg0: name1, type: type1}
+// CHECK:STDOUT:     inst+2:          {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
+// CHECK:STDOUT:     inst+3:          {kind: TupleLiteral, arg0: block2, type: type2}
+// CHECK:STDOUT:     inst+4:          {kind: TupleType, arg0: typeBlock1, type: typeTypeType}
+// CHECK:STDOUT:     inst+5:          {kind: Converted, arg0: inst+3, arg1: inst+4, type: typeTypeType}
+// CHECK:STDOUT:     inst+6:          {kind: VarStorage, arg0: nameReturnSlot, type: type4}
+// CHECK:STDOUT:     inst+7:          {kind: PointerType, arg0: type4, type: typeTypeType}
+// CHECK:STDOUT:     inst+8:          {kind: FunctionDecl, arg0: function0, type: type6}
+// CHECK:STDOUT:     inst+9:          {kind: NameRef, arg0: name1, arg1: inst+1, type: type1}
+// CHECK:STDOUT:     inst+10:         {kind: IntLiteral, arg0: int3, type: type1}
+// CHECK:STDOUT:     inst+11:         {kind: BinaryOperatorAdd, arg0: inst+9, arg1: inst+10, type: type1}
+// CHECK:STDOUT:     inst+12:         {kind: RealLiteral, arg0: real0, type: type3}
+// CHECK:STDOUT:     inst+13:         {kind: TupleLiteral, arg0: block5, type: type4}
+// CHECK:STDOUT:     inst+14:         {kind: TupleAccess, arg0: inst+6, arg1: element0, type: type1}
+// CHECK:STDOUT:     inst+15:         {kind: InitializeFrom, arg0: inst+11, arg1: inst+14, type: type1}
+// CHECK:STDOUT:     inst+16:         {kind: TupleAccess, arg0: inst+6, arg1: element1, type: type3}
+// CHECK:STDOUT:     inst+17:         {kind: InitializeFrom, arg0: inst+12, arg1: inst+16, type: type3}
+// CHECK:STDOUT:     inst+18:         {kind: TupleInit, arg0: block6, arg1: inst+6, type: type4}
+// CHECK:STDOUT:     inst+19:         {kind: Converted, arg0: inst+13, arg1: inst+18, type: type4}
+// CHECK:STDOUT:     inst+20:         {kind: ReturnExpr, arg0: inst+19}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     block0:          {}
 // CHECK:STDOUT:     block1:
-// CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       0:               inst+1
 // CHECK:STDOUT:     block2:
 // CHECK:STDOUT:       0:               instIntType
 // CHECK:STDOUT:       1:               instFloatType
 // CHECK:STDOUT:     block3:
-// CHECK:STDOUT:       0:               inst+0
-// CHECK:STDOUT:       1:               inst+2
-// CHECK:STDOUT:       2:               inst+4
-// CHECK:STDOUT:       3:               inst+5
+// CHECK:STDOUT:       0:               inst+1
+// CHECK:STDOUT:       1:               inst+3
+// CHECK:STDOUT:       2:               inst+5
+// CHECK:STDOUT:       3:               inst+6
 // CHECK:STDOUT:     block4:
-// CHECK:STDOUT:       0:               inst+8
-// CHECK:STDOUT:       1:               inst+9
-// CHECK:STDOUT:       2:               inst+10
-// CHECK:STDOUT:       3:               inst+11
-// CHECK:STDOUT:       4:               inst+12
-// CHECK:STDOUT:       5:               inst+13
-// CHECK:STDOUT:       6:               inst+14
-// CHECK:STDOUT:       7:               inst+15
-// CHECK:STDOUT:       8:               inst+16
-// CHECK:STDOUT:       9:               inst+17
-// CHECK:STDOUT:       10:              inst+18
-// CHECK:STDOUT:       11:              inst+19
+// CHECK:STDOUT:       0:               inst+9
+// CHECK:STDOUT:       1:               inst+10
+// CHECK:STDOUT:       2:               inst+11
+// CHECK:STDOUT:       3:               inst+12
+// CHECK:STDOUT:       4:               inst+13
+// CHECK:STDOUT:       5:               inst+14
+// CHECK:STDOUT:       6:               inst+15
+// CHECK:STDOUT:       7:               inst+16
+// CHECK:STDOUT:       8:               inst+17
+// CHECK:STDOUT:       9:               inst+18
+// CHECK:STDOUT:       10:              inst+19
+// CHECK:STDOUT:       11:              inst+20
 // CHECK:STDOUT:     block5:
-// CHECK:STDOUT:       0:               inst+10
-// CHECK:STDOUT:       1:               inst+11
+// CHECK:STDOUT:       0:               inst+11
+// CHECK:STDOUT:       1:               inst+12
 // CHECK:STDOUT:     block6:
-// CHECK:STDOUT:       0:               inst+14
-// CHECK:STDOUT:       1:               inst+16
+// CHECK:STDOUT:       0:               inst+15
+// CHECK:STDOUT:       1:               inst+17
 // CHECK:STDOUT:     block7:
-// CHECK:STDOUT:       0:               inst+7
+// CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       1:               inst+8
 // CHECK:STDOUT: ...
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- raw_and_textual_ir.carbon
@@ -98,6 +101,7 @@ fn Foo(n: i32) -> (i32, f64) {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

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

@@ -23,6 +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:   %A: <function> = fn_decl @A
 // CHECK:STDOUT:   %B: <function> = fn_decl @B
 // CHECK:STDOUT:   %C: <function> = fn_decl @C

+ 54 - 51
toolchain/check/testdata/basics/raw_ir.carbon

@@ -17,74 +17,77 @@ fn Foo(n: i32) -> (i32, f64) {
 // CHECK:STDOUT: sem_ir:
 // CHECK:STDOUT:   cross_ref_irs_size: 1
 // CHECK:STDOUT:   functions:
-// CHECK:STDOUT:     function0:       {name: name0, param_refs: block1, return_type: type3, return_slot: inst+5, body: [block4]}
+// CHECK:STDOUT:     function0:       {name: name0, param_refs: block1, return_type: type4, return_slot: inst+6, body: [block4]}
 // CHECK:STDOUT:   classes:         {}
 // CHECK:STDOUT:   types:
-// CHECK:STDOUT:     type0:           {inst: instIntType, value_rep: {kind: copy, type: type0}}
-// CHECK:STDOUT:     type1:           {inst: inst+1, value_rep: {kind: unknown, type: type<invalid>}}
-// CHECK:STDOUT:     type2:           {inst: instFloatType, value_rep: {kind: copy, type: type2}}
-// CHECK:STDOUT:     type3:           {inst: inst+3, value_rep: {kind: pointer, type: type4}}
-// CHECK:STDOUT:     type4:           {inst: inst+6, value_rep: {kind: copy, type: type4}}
-// CHECK:STDOUT:     type5:           {inst: instFunctionType, value_rep: {kind: copy, type: type5}}
+// CHECK:STDOUT:     type0:           {inst: instNamespaceType, value_rep: {kind: copy, type: type0}}
+// CHECK:STDOUT:     type1:           {inst: instIntType, value_rep: {kind: copy, type: type1}}
+// CHECK:STDOUT:     type2:           {inst: inst+2, value_rep: {kind: unknown, type: type<invalid>}}
+// CHECK:STDOUT:     type3:           {inst: instFloatType, value_rep: {kind: copy, type: type3}}
+// CHECK:STDOUT:     type4:           {inst: inst+4, value_rep: {kind: pointer, type: type5}}
+// CHECK:STDOUT:     type5:           {inst: inst+7, value_rep: {kind: copy, type: type5}}
+// CHECK:STDOUT:     type6:           {inst: instFunctionType, value_rep: {kind: copy, type: type6}}
 // CHECK:STDOUT:   type_blocks:
 // CHECK:STDOUT:     typeBlock0:
 // CHECK:STDOUT:       0:               typeTypeType
 // CHECK:STDOUT:       1:               typeTypeType
 // CHECK:STDOUT:     typeBlock1:
-// CHECK:STDOUT:       0:               type0
-// CHECK:STDOUT:       1:               type2
+// CHECK:STDOUT:       0:               type1
+// CHECK:STDOUT:       1:               type3
 // CHECK:STDOUT:   insts:
-// CHECK:STDOUT:     inst+0:          {kind: Param, arg0: name1, type: type0}
-// CHECK:STDOUT:     inst+1:          {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
-// CHECK:STDOUT:     inst+2:          {kind: TupleLiteral, arg0: block2, type: type1}
-// CHECK:STDOUT:     inst+3:          {kind: TupleType, arg0: typeBlock1, type: typeTypeType}
-// CHECK:STDOUT:     inst+4:          {kind: Converted, arg0: inst+2, arg1: inst+3, type: typeTypeType}
-// CHECK:STDOUT:     inst+5:          {kind: VarStorage, arg0: nameReturnSlot, type: type3}
-// CHECK:STDOUT:     inst+6:          {kind: PointerType, arg0: type3, type: typeTypeType}
-// CHECK:STDOUT:     inst+7:          {kind: FunctionDecl, arg0: function0, type: type5}
-// CHECK:STDOUT:     inst+8:          {kind: NameRef, arg0: name1, arg1: inst+0, type: type0}
-// CHECK:STDOUT:     inst+9:          {kind: IntLiteral, arg0: int3, type: type0}
-// CHECK:STDOUT:     inst+10:         {kind: BinaryOperatorAdd, arg0: inst+8, arg1: inst+9, type: type0}
-// CHECK:STDOUT:     inst+11:         {kind: RealLiteral, arg0: real0, type: type2}
-// CHECK:STDOUT:     inst+12:         {kind: TupleLiteral, arg0: block5, type: type3}
-// CHECK:STDOUT:     inst+13:         {kind: TupleAccess, arg0: inst+5, arg1: element0, type: type0}
-// CHECK:STDOUT:     inst+14:         {kind: InitializeFrom, arg0: inst+10, arg1: inst+13, type: type0}
-// CHECK:STDOUT:     inst+15:         {kind: TupleAccess, arg0: inst+5, arg1: element1, type: type2}
-// CHECK:STDOUT:     inst+16:         {kind: InitializeFrom, arg0: inst+11, arg1: inst+15, type: type2}
-// CHECK:STDOUT:     inst+17:         {kind: TupleInit, arg0: block6, arg1: inst+5, type: type3}
-// CHECK:STDOUT:     inst+18:         {kind: Converted, arg0: inst+12, arg1: inst+17, type: type3}
-// CHECK:STDOUT:     inst+19:         {kind: ReturnExpr, arg0: inst+18}
+// CHECK:STDOUT:     inst+0:          {kind: Namespace, arg0: name_scope0, type: type0}
+// CHECK:STDOUT:     inst+1:          {kind: Param, arg0: name1, type: type1}
+// CHECK:STDOUT:     inst+2:          {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
+// CHECK:STDOUT:     inst+3:          {kind: TupleLiteral, arg0: block2, type: type2}
+// CHECK:STDOUT:     inst+4:          {kind: TupleType, arg0: typeBlock1, type: typeTypeType}
+// CHECK:STDOUT:     inst+5:          {kind: Converted, arg0: inst+3, arg1: inst+4, type: typeTypeType}
+// CHECK:STDOUT:     inst+6:          {kind: VarStorage, arg0: nameReturnSlot, type: type4}
+// CHECK:STDOUT:     inst+7:          {kind: PointerType, arg0: type4, type: typeTypeType}
+// CHECK:STDOUT:     inst+8:          {kind: FunctionDecl, arg0: function0, type: type6}
+// CHECK:STDOUT:     inst+9:          {kind: NameRef, arg0: name1, arg1: inst+1, type: type1}
+// CHECK:STDOUT:     inst+10:         {kind: IntLiteral, arg0: int3, type: type1}
+// CHECK:STDOUT:     inst+11:         {kind: BinaryOperatorAdd, arg0: inst+9, arg1: inst+10, type: type1}
+// CHECK:STDOUT:     inst+12:         {kind: RealLiteral, arg0: real0, type: type3}
+// CHECK:STDOUT:     inst+13:         {kind: TupleLiteral, arg0: block5, type: type4}
+// CHECK:STDOUT:     inst+14:         {kind: TupleAccess, arg0: inst+6, arg1: element0, type: type1}
+// CHECK:STDOUT:     inst+15:         {kind: InitializeFrom, arg0: inst+11, arg1: inst+14, type: type1}
+// CHECK:STDOUT:     inst+16:         {kind: TupleAccess, arg0: inst+6, arg1: element1, type: type3}
+// CHECK:STDOUT:     inst+17:         {kind: InitializeFrom, arg0: inst+12, arg1: inst+16, type: type3}
+// CHECK:STDOUT:     inst+18:         {kind: TupleInit, arg0: block6, arg1: inst+6, type: type4}
+// CHECK:STDOUT:     inst+19:         {kind: Converted, arg0: inst+13, arg1: inst+18, type: type4}
+// CHECK:STDOUT:     inst+20:         {kind: ReturnExpr, arg0: inst+19}
 // CHECK:STDOUT:   inst_blocks:
 // CHECK:STDOUT:     block0:          {}
 // CHECK:STDOUT:     block1:
-// CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       0:               inst+1
 // CHECK:STDOUT:     block2:
 // CHECK:STDOUT:       0:               instIntType
 // CHECK:STDOUT:       1:               instFloatType
 // CHECK:STDOUT:     block3:
-// CHECK:STDOUT:       0:               inst+0
-// CHECK:STDOUT:       1:               inst+2
-// CHECK:STDOUT:       2:               inst+4
-// CHECK:STDOUT:       3:               inst+5
+// CHECK:STDOUT:       0:               inst+1
+// CHECK:STDOUT:       1:               inst+3
+// CHECK:STDOUT:       2:               inst+5
+// CHECK:STDOUT:       3:               inst+6
 // CHECK:STDOUT:     block4:
-// CHECK:STDOUT:       0:               inst+8
-// CHECK:STDOUT:       1:               inst+9
-// CHECK:STDOUT:       2:               inst+10
-// CHECK:STDOUT:       3:               inst+11
-// CHECK:STDOUT:       4:               inst+12
-// CHECK:STDOUT:       5:               inst+13
-// CHECK:STDOUT:       6:               inst+14
-// CHECK:STDOUT:       7:               inst+15
-// CHECK:STDOUT:       8:               inst+16
-// CHECK:STDOUT:       9:               inst+17
-// CHECK:STDOUT:       10:              inst+18
-// CHECK:STDOUT:       11:              inst+19
+// CHECK:STDOUT:       0:               inst+9
+// CHECK:STDOUT:       1:               inst+10
+// CHECK:STDOUT:       2:               inst+11
+// CHECK:STDOUT:       3:               inst+12
+// CHECK:STDOUT:       4:               inst+13
+// CHECK:STDOUT:       5:               inst+14
+// CHECK:STDOUT:       6:               inst+15
+// CHECK:STDOUT:       7:               inst+16
+// CHECK:STDOUT:       8:               inst+17
+// CHECK:STDOUT:       9:               inst+18
+// CHECK:STDOUT:       10:              inst+19
+// CHECK:STDOUT:       11:              inst+20
 // CHECK:STDOUT:     block5:
-// CHECK:STDOUT:       0:               inst+10
-// CHECK:STDOUT:       1:               inst+11
+// CHECK:STDOUT:       0:               inst+11
+// CHECK:STDOUT:       1:               inst+12
 // CHECK:STDOUT:     block6:
-// CHECK:STDOUT:       0:               inst+14
-// CHECK:STDOUT:       1:               inst+16
+// CHECK:STDOUT:       0:               inst+15
+// CHECK:STDOUT:       1:               inst+17
 // CHECK:STDOUT:     block7:
-// CHECK:STDOUT:       0:               inst+7
+// CHECK:STDOUT:       0:               inst+0
+// CHECK:STDOUT:       1:               inst+8
 // CHECK:STDOUT: ...

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

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

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

@@ -9,6 +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:   %Run: <function> = fn_decl @Run
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

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

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

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

@@ -29,6 +29,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/fail_abstract.carbon

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

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

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

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

@@ -47,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F.2

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

@@ -123,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %.loc15: <function> = fn_decl @.1

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

@@ -35,6 +35,7 @@ fn F() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/fail_init_as_inplace.carbon

@@ -31,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -45,6 +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:   %A.decl = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %B.decl = class_decl @B, ()

+ 3 - 5
toolchain/check/testdata/class/fail_member_of_let.carbon

@@ -13,10 +13,7 @@ let T: type = Class;
 
 // The class name is required to be written in the same way as in the class
 // declaration. An expression that evaluates to the class name is not accepted.
-// CHECK:STDERR: fail_member_of_let.carbon:[[@LINE+6]]:6: ERROR: Declaration qualifiers are only allowed for entities that provide a scope.
-// CHECK:STDERR: fn T.F() {}
-// CHECK:STDERR:      ^
-// CHECK:STDERR: fail_member_of_let.carbon:[[@LINE+3]]:4: Non-scope entity referenced here.
+// CHECK:STDERR: fail_member_of_let.carbon:[[@LINE+3]]:4: ERROR: Name `T` not found.
 // CHECK:STDERR: fn T.F() {}
 // CHECK:STDERR:    ^
 fn T.F() {}
@@ -28,11 +25,12 @@ fn T.F() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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
 // CHECK:STDOUT:   %T: type = bind_name T, %Class.ref
-// CHECK:STDOUT:   %.loc22: <function> = fn_decl @.1
+// CHECK:STDOUT:   %.loc19: <function> = fn_decl @.1
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: class @Class {

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

@@ -39,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -81,6 +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:   %A.decl.loc7 = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %A.decl.loc14 = class_decl @A, ()

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

@@ -28,6 +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:   %A.decl.loc7 = class_decl @A.1, ()
 // CHECK:STDOUT:   %A: type = class_type @A.1
 // CHECK:STDOUT:   %X.decl = class_decl @X, ()

+ 3 - 2
toolchain/check/testdata/class/fail_redefinition.carbon

@@ -31,6 +31,7 @@ fn Class.H() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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, ()
@@ -44,8 +45,8 @@ fn Class.H() {}
 // CHECK:STDOUT:   %H: <function> = fn_decl @H
 // CHECK:STDOUT:
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .F = <unexpected instref inst+2>
-// CHECK:STDOUT:   .H = <unexpected instref inst+3>
+// CHECK:STDOUT:   .F = <unexpected instref inst+3>
+// CHECK:STDOUT:   .H = <unexpected instref inst+4>
 // CHECK:STDOUT:   .G = %G
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

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

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

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

@@ -24,6 +24,7 @@ fn G() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/fail_self.carbon

@@ -59,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F.1

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

@@ -28,6 +28,7 @@ fn G() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/fail_unknown_member.carbon

@@ -24,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %G: <function> = fn_decl @G

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

@@ -24,6 +24,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/field_access_in_value.carbon

@@ -25,6 +25,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/forward_declared.carbon

@@ -11,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -26,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %Make: <function> = fn_decl @Make

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

@@ -21,6 +21,7 @@ fn F() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/init_nested.carbon

@@ -32,6 +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:   %Inner.decl = class_decl @Inner, ()
 // CHECK:STDOUT:   %Inner: type = class_type @Inner
 // CHECK:STDOUT:   %MakeInner: <function> = fn_decl @MakeInner

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

@@ -52,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -38,6 +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:   %Outer.decl = class_decl @Outer, ()
 // CHECK:STDOUT:   %Outer: type = class_type @Outer
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -29,6 +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:   %Outer.decl = class_decl @Outer, ()
 // CHECK:STDOUT:   %Outer: type = class_type @Outer
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

@@ -29,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

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

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

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

@@ -19,6 +19,7 @@ fn Class.F() {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/redeclaration_introducer.carbon

@@ -19,6 +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:   %A.decl.loc7 = class_decl @A, ()
 // CHECK:STDOUT:   %A: type = class_type @A
 // CHECK:STDOUT:   %B.decl.loc8 = class_decl @B, ()

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

@@ -20,6 +20,7 @@ fn Class.F() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/scope.carbon

@@ -29,6 +29,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/self.carbon

@@ -27,6 +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:   %Class.decl = class_decl @Class, ()
 // CHECK:STDOUT:   %Class: type = class_type @Class
 // CHECK:STDOUT:   %F: <function> = fn_decl @F

+ 1 - 0
toolchain/check/testdata/class/self_type.carbon

@@ -24,6 +24,7 @@ fn Class.F[self: Class]() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/class/static_method.carbon

@@ -22,6 +22,7 @@ fn Run() -> i32 {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.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 - 0
toolchain/check/testdata/const/collapse.carbon

@@ -15,6 +15,7 @@ fn F(p: const i32**) -> const (const i32)** {
 // CHECK:STDOUT: --- collapse.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.F = %F}
 // CHECK:STDOUT:   %F: <function> = fn_decl @F
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 0
toolchain/check/testdata/const/fail_collapse.carbon

@@ -17,6 +17,7 @@ fn G(p: const (const i32)**) -> i32** {
 // CHECK:STDOUT: --- fail_collapse.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.G = %G}
 // CHECK:STDOUT:   %G: <function> = fn_decl @G
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 0
toolchain/check/testdata/expr_category/in_place_tuple_init.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/empty_struct.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/empty_tuple.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/fail_not_callable.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/fail_param_count.carbon

@@ -62,6 +62,7 @@ fn Main() {
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Run0 = %Run0, .Run1 = %Run1, .Run2 = %Run2, .Main = %Main}
 // CHECK:STDOUT:   %Run0: <function> = fn_decl @Run0
 // CHECK:STDOUT:   %Run1: <function> = fn_decl @Run1
 // CHECK:STDOUT:   %Run2: <function> = fn_decl @Run2

+ 1 - 0
toolchain/check/testdata/function/call/fail_param_type.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/i32.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/more_param_ir.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/params_one.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/params_one_comma.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/params_two.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/params_two_comma.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/params_zero.carbon

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

+ 1 - 0
toolchain/check/testdata/function/call/return_implicit.carbon

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

+ 1 - 0
toolchain/check/testdata/function/declaration/simple.carbon

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

+ 1 - 0
toolchain/check/testdata/function/definition/fail_param_name_conflict.carbon

@@ -15,6 +15,7 @@ fn Bar(a: i32, a: i32) {}
 // CHECK:STDOUT: --- fail_param_name_conflict.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Bar = %Bar}
 // CHECK:STDOUT:   %Bar: <function> = fn_decl @Bar
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 0
toolchain/check/testdata/function/definition/order.carbon

@@ -11,6 +11,7 @@ fn Baz() {}
 // CHECK:STDOUT: --- order.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo, .Bar = %Bar, .Baz = %Baz}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT:   %Bar: <function> = fn_decl @Bar
 // CHECK:STDOUT:   %Baz: <function> = fn_decl @Baz

+ 1 - 0
toolchain/check/testdata/function/definition/params_one.carbon

@@ -9,6 +9,7 @@ fn Foo(a: i32) {}
 // CHECK:STDOUT: --- params_one.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 0
toolchain/check/testdata/function/definition/params_one_comma.carbon

@@ -9,6 +9,7 @@ fn Foo(a: i32,) {}
 // CHECK:STDOUT: --- params_one_comma.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 0
toolchain/check/testdata/function/definition/params_two.carbon

@@ -9,6 +9,7 @@ fn Foo(a: i32, b: i32) {}
 // CHECK:STDOUT: --- params_two.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 1 - 0
toolchain/check/testdata/function/definition/params_two_comma.carbon

@@ -9,6 +9,7 @@ fn Foo(a: i32, b: i32,) {}
 // CHECK:STDOUT: --- params_two_comma.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
+// CHECK:STDOUT:   package: <namespace> = namespace {.Foo = %Foo}
 // CHECK:STDOUT:   %Foo: <function> = fn_decl @Foo
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff