From 13434f0e8a64d5fa8decd6685be6c1a9649e92af Mon Sep 17 00:00:00 2001 From: Geoff Romer Date: Fri, 17 Jan 2025 09:51:34 -0800 Subject: [PATCH] Model `var` as a pattern operator (#4720) Co-authored-by: Richard Smith --- common/array_stack.h | 5 + toolchain/check/BUILD | 2 + toolchain/check/context.cpp | 9 + toolchain/check/context.h | 14 + toolchain/check/decl_introducer_state.h | 2 +- toolchain/check/eval.cpp | 2 + toolchain/check/full_pattern_stack.h | 82 ++++++ toolchain/check/handle_binding_pattern.cpp | 225 ++++++++------- toolchain/check/handle_impl.cpp | 1 + toolchain/check/handle_let_and_var.cpp | 262 +++++++++--------- toolchain/check/handle_modifier.cpp | 5 + toolchain/check/handle_name.cpp | 1 + toolchain/check/keyword_modifier_set.h | 7 +- toolchain/check/name_component.cpp | 1 + toolchain/check/node_stack.h | 1 + toolchain/check/pattern_match.cpp | 69 ++++- toolchain/check/pattern_match.h | 5 + toolchain/check/return.cpp | 40 +-- toolchain/check/return.h | 20 +- toolchain/check/scope_stack.h | 8 +- .../testdata/alias/fail_bool_value.carbon | 14 +- .../alias/no_prelude/alias_of_alias.carbon | 19 +- .../alias/no_prelude/export_name.carbon | 33 ++- .../fail_aliased_name_in_diag.carbon | 23 +- .../no_prelude/fail_name_conflict.carbon | 18 +- .../alias/no_prelude/fail_not_constant.carbon | 25 +- .../testdata/alias/no_prelude/import.carbon | 64 ++++- .../alias/no_prelude/import_access.carbon | 26 +- .../alias/no_prelude/import_order.carbon | 42 ++- .../alias/no_prelude/in_namespace.carbon | 36 ++- .../testdata/alias/no_prelude/local.carbon | 14 +- .../testdata/array/array_in_place.carbon | 22 +- .../testdata/array/array_vs_tuple.carbon | 47 +++- .../testdata/array/assign_return_value.carbon | 16 +- .../check/testdata/array/assign_var.carbon | 33 ++- toolchain/check/testdata/array/base.carbon | 47 +++- .../testdata/array/canonicalize_index.carbon | 93 ++++++- .../testdata/array/fail_bound_negative.carbon | 44 ++- .../testdata/array/fail_bound_overflow.carbon | 28 +- .../array/fail_incomplete_element.carbon | 23 +- .../testdata/array/fail_invalid_type.carbon | 13 +- .../testdata/array/fail_out_of_bound.carbon | 10 + .../fail_out_of_bound_non_literal.carbon | 22 +- .../testdata/array/fail_type_mismatch.carbon | 64 +++++ .../check/testdata/array/generic_empty.carbon | 25 +- .../testdata/array/index_not_literal.carbon | 22 +- .../array/init_dependent_bound.carbon | 40 ++- .../check/testdata/array/nine_elements.carbon | 14 +- .../testdata/as/adapter_conversion.carbon | 171 +++++++++--- toolchain/check/testdata/as/as_type.carbon | 7 +- .../testdata/as/fail_no_conversion.carbon | 17 +- .../check/testdata/as/fail_not_type.carbon | 11 +- toolchain/check/testdata/as/identity.carbon | 36 ++- .../check/testdata/as/no_prelude/tuple.carbon | 31 ++- toolchain/check/testdata/as/overloaded.carbon | 19 +- .../testdata/basics/builtin_types.carbon | 32 ++- .../basics/fail_non_type_as_type.carbon | 8 +- .../fail_numeric_literal_overflow.carbon | 110 +++++--- .../testdata/basics/numeric_literals.carbon | 37 ++- toolchain/check/testdata/basics/parens.carbon | 16 ++ .../testdata/basics/type_literals.carbon | 48 ++++ .../check/testdata/builtins/bool/eq.carbon | 122 ++++++++ .../testdata/builtins/bool/make_type.carbon | 10 + .../check/testdata/builtins/bool/neq.carbon | 122 ++++++++ .../check/testdata/builtins/float/add.carbon | 10 + .../check/testdata/builtins/float/div.carbon | 44 ++- .../testdata/builtins/float/make_type.carbon | 69 ++++- .../check/testdata/builtins/float/mul.carbon | 10 + .../testdata/builtins/float/negate.carbon | 17 +- .../check/testdata/builtins/float/sub.carbon | 10 + .../check/testdata/builtins/read/int.carbon | 26 +- .../testdata/class/access_modifers.carbon | 136 +++++++-- .../check/testdata/class/adapter/adapt.carbon | 12 +- .../testdata/class/adapter/adapt_copy.carbon | 148 +++++++--- .../class/adapter/extend_adapt.carbon | 26 +- .../adapter/fail_adapt_with_subobjects.carbon | 30 +- .../testdata/class/adapter/init_adapt.carbon | 226 +++++++++------ toolchain/check/testdata/class/base.carbon | 22 +- .../check/testdata/class/base_field.carbon | 32 ++- .../check/testdata/class/base_method.carbon | 8 +- toolchain/check/testdata/class/basic.carbon | 6 +- .../class/complete_in_member_fn.carbon | 8 +- .../testdata/class/compound_field.carbon | 38 ++- .../class/cross_package_import.carbon | 51 +++- .../testdata/class/derived_to_base.carbon | 46 ++- .../check/testdata/class/fail_abstract.carbon | 49 +++- .../testdata/class/fail_base_bad_type.carbon | 8 +- .../testdata/class/fail_base_unbound.carbon | 8 +- .../class/fail_compound_type_mismatch.carbon | 14 +- .../class/fail_convert_to_invalid.carbon | 6 +- .../class/fail_derived_to_base.carbon | 18 +- .../testdata/class/fail_extend_cycle.carbon | 6 +- .../class/fail_field_modifiers.carbon | 38 ++- .../testdata/class/fail_generic_method.carbon | 6 +- .../testdata/class/fail_import_misuses.carbon | 7 +- .../testdata/class/fail_incomplete.carbon | 21 +- .../check/testdata/class/fail_init.carbon | 12 +- .../class/fail_init_as_inplace.carbon | 21 +- .../class/fail_memaccess_category.carbon | 8 +- .../testdata/class/fail_member_of_let.carbon | 7 +- .../check/testdata/class/fail_self.carbon | 5 + .../testdata/class/fail_self_param.carbon | 11 +- .../class/fail_self_type_member.carbon | 6 +- .../testdata/class/fail_unbound_field.carbon | 10 +- .../testdata/class/fail_unknown_member.carbon | 6 +- .../check/testdata/class/field_access.carbon | 45 ++- .../class/field_access_in_value.carbon | 56 +++- .../check/testdata/class/generic/adapt.carbon | 30 +- .../class/generic/base_is_generic.carbon | 50 +++- .../check/testdata/class/generic/basic.carbon | 10 +- .../check/testdata/class/generic/call.carbon | 91 +++++- .../generic/complete_in_conversion.carbon | 31 ++- .../check/testdata/class/generic/field.carbon | 12 +- .../testdata/class/generic/import.carbon | 77 +++-- .../check/testdata/class/generic/init.carbon | 53 +++- .../class/generic/member_access.carbon | 12 +- .../class/generic/member_inline.carbon | 16 +- .../class/generic/member_lookup.carbon | 30 +- .../class/generic/member_out_of_line.carbon | 8 +- .../check/testdata/class/generic/self.carbon | 37 ++- .../testdata/class/generic/stringify.carbon | 130 ++++++++- .../testdata/class/generic_method.carbon | 6 +- toolchain/check/testdata/class/import.carbon | 59 +++- .../check/testdata/class/import_base.carbon | 23 +- .../testdata/class/import_indirect.carbon | 122 ++++++-- .../testdata/class/import_member_cycle.carbon | 14 +- .../testdata/class/import_struct_cyle.carbon | 15 +- .../testdata/class/inheritance_access.carbon | 96 +++++-- toolchain/check/testdata/class/init.carbon | 12 +- toolchain/check/testdata/class/init_as.carbon | 14 +- .../check/testdata/class/init_nested.carbon | 24 +- toolchain/check/testdata/class/local.carbon | 21 +- toolchain/check/testdata/class/method.carbon | 13 +- toolchain/check/testdata/class/nested.carbon | 120 ++++++-- .../check/testdata/class/nested_name.carbon | 16 +- .../class/no_prelude/export_name.carbon | 9 +- .../class/no_prelude/generic_vs_params.carbon | 66 ++++- .../class/no_prelude/import_access.carbon | 52 +++- .../no_prelude/indirect_import_member.carbon | 40 +++ .../class/no_prelude/syntactic_merge.carbon | 8 +- .../check/testdata/class/raw_self.carbon | 10 +- .../check/testdata/class/raw_self_type.carbon | 22 +- .../testdata/class/reorder_qualified.carbon | 68 +++-- toolchain/check/testdata/class/scope.carbon | 20 +- toolchain/check/testdata/class/self.carbon | 10 +- .../testdata/class/self_conversion.carbon | 10 +- .../check/testdata/class/self_type.carbon | 15 +- .../check/testdata/class/static_method.carbon | 5 + .../class/todo_access_modifiers.carbon | 12 +- .../testdata/class/virtual_modifiers.carbon | 65 ++++- toolchain/check/testdata/const/import.carbon | 39 +++ toolchain/check/testdata/deduce/array.carbon | 94 +++++-- .../check/testdata/eval/aggregate.carbon | 65 ++++- .../check/testdata/eval/fail_aggregate.carbon | 10 + toolchain/check/testdata/eval/symbolic.carbon | 90 ++++-- .../expr_category/in_place_tuple_init.carbon | 18 +- .../testdata/function/builtin/call.carbon | 52 ++++ .../testdata/function/builtin/method.carbon | 62 +++++ .../builtin/no_prelude/adapted_type.carbon | 5 + .../no_prelude/call_from_operator.carbon | 53 +++- .../function/builtin/no_prelude/import.carbon | 45 ++- .../function/call/fail_not_callable.carbon | 10 +- .../call/fail_return_type_mismatch.carbon | 16 +- .../check/testdata/function/call/i32.carbon | 10 +- .../function/call/more_param_ir.carbon | 17 +- .../function/call/no_prelude/alias.carbon | 10 +- .../call/no_prelude/return_implicit.carbon | 10 +- .../function/declaration/import.carbon | 205 ++++++++++++++ .../declaration/no_prelude/export_name.carbon | 8 + .../declaration/no_prelude/extern.carbon | 8 + .../no_prelude/fail_todo_no_params.carbon | 19 +- .../no_prelude/name_poisoning.carbon | 12 +- .../function/definition/import.carbon | 25 ++ .../function/definition/import_access.carbon | 72 +++++ .../no_prelude/fail_local_decl.carbon | 16 ++ .../fail_type_param_mismatch.carbon | 32 ++- .../generic/no_prelude/type_param.carbon | 29 +- .../no_prelude/type_param_scope.carbon | 4 + .../function/generic/resolve_used.carbon | 25 +- .../function/generic/return_slot.carbon | 47 +++- .../testdata/generic/complete_type.carbon | 16 +- toolchain/check/testdata/generic/local.carbon | 22 +- .../check/testdata/global/class_obj.carbon | 9 +- .../testdata/global/class_with_fun.carbon | 9 +- toolchain/check/testdata/global/decl.carbon | 8 + .../check/testdata/global/simple_init.carbon | 8 + .../testdata/global/simple_with_fun.carbon | 8 + toolchain/check/testdata/if/fail_scope.carbon | 18 +- toolchain/check/testdata/if_expr/basic.carbon | 16 +- .../if_expr/constant_condition.carbon | 125 ++++++++- .../if_expr/fail_not_in_function.carbon | 26 +- .../if_expr/fail_partial_constant.carbon | 85 +++++- .../check/testdata/if_expr/struct.carbon | 17 +- .../testdata/impl/extend_impl_generic.carbon | 32 ++- toolchain/check/testdata/impl/impl_as.carbon | 11 +- .../impl/lookup/no_prelude/impl_forall.carbon | 8 +- .../impl/lookup/no_prelude/import.carbon | 41 ++- .../fail_impl_bad_assoc_const.carbon | 4 +- .../no_prelude/import_builtin_call.carbon | 22 ++ .../import_interface_assoc_const.carbon | 28 +- .../impl/no_prelude/import_use_generic.carbon | 14 +- .../index/array_element_access.carbon | 38 ++- .../check/testdata/index/expr_category.carbon | 75 +++-- .../index/fail_array_large_index.carbon | 30 +- .../index/fail_array_non_int_indexing.carbon | 22 +- .../fail_array_out_of_bound_access.carbon | 22 +- .../testdata/index/fail_expr_category.carbon | 30 +- .../testdata/index/fail_invalid_base.carbon | 32 +++ .../testdata/index/fail_name_not_found.carbon | 10 +- .../index/fail_negative_indexing.carbon | 22 +- .../fail_assoc_const_bad_default.carbon | 6 +- .../fail_todo_assoc_const_default.carbon | 16 +- .../testdata/interface/member_lookup.carbon | 24 +- .../no_prelude/as_type_of_type.carbon | 17 +- .../interface/no_prelude/default_fn.carbon | 11 +- .../fail_assoc_const_not_binding.carbon | 2 + .../fail_assoc_const_not_constant.carbon | 5 +- .../fail_assoc_const_template.carbon | 1 + .../no_prelude/fail_incomplete_type.carbon | 53 ++++ .../fail_lookup_in_type_type.carbon | 24 +- .../no_prelude/fail_member_lookup.carbon | 13 +- .../interface/no_prelude/import.carbon | 20 +- .../interface/todo_define_not_default.carbon | 16 +- .../ir/duplicate_name_same_line.carbon | 48 ++-- .../testdata/let/compile_time_bindings.carbon | 233 ++++++++++++---- toolchain/check/testdata/let/convert.carbon | 63 +++-- .../testdata/let/fail_duplicate_decl.carbon | 26 +- .../check/testdata/let/fail_generic.carbon | 16 +- .../testdata/let/fail_generic_import.carbon | 15 +- .../testdata/let/fail_missing_value.carbon | 10 +- .../check/testdata/let/fail_modifiers.carbon | 184 +++++++----- .../testdata/let/fail_use_in_init.carbon | 9 +- toolchain/check/testdata/let/generic.carbon | 21 +- .../check/testdata/let/generic_import.carbon | 26 +- toolchain/check/testdata/let/global.carbon | 25 +- toolchain/check/testdata/let/local.carbon | 7 + .../testdata/let/no_prelude/import.carbon | 56 +++- .../let/no_prelude/import_access.carbon | 50 +++- .../check/testdata/let/shadowed_decl.carbon | 17 +- .../testdata/namespace/add_to_import.carbon | 8 + .../check/testdata/namespace/imported.carbon | 32 +++ .../namespace/imported_indirect.carbon | 8 + .../merging_with_indirections.carbon | 16 ++ .../check/testdata/namespace/shadow.carbon | 18 +- .../testdata/operators/builtin/and.carbon | 209 ++++++++++++-- .../operators/builtin/assignment.carbon | 61 +++- .../fail_and_or_not_in_function.carbon | 42 ++- .../fail_and_or_partial_constant.carbon | 168 ++++++++++- .../fail_assignment_to_non_assignable.carbon | 22 +- .../fail_redundant_compound_access.carbon | 14 +- .../builtin/fail_type_mismatch.carbon | 13 +- .../fail_type_mismatch_assignment.carbon | 14 +- .../testdata/operators/builtin/or.carbon | 209 +++++++++++++- .../operators/builtin/unary_op.carbon | 88 +++++- .../testdata/operators/overloaded/dec.carbon | 11 +- .../operators/overloaded/fail_no_impl.carbon | 13 +- .../overloaded/fail_no_impl_for_arg.carbon | 11 +- .../operators/overloaded/implicit_as.carbon | 8 +- .../testdata/operators/overloaded/inc.carbon | 11 +- .../operators/overloaded/index.carbon | 196 ++++++++----- .../package_expr/fail_not_found.carbon | 10 +- .../check/testdata/package_expr/syntax.carbon | 52 +++- .../fail_conflict_no_namespaces.carbon | 8 + .../packages/fail_import_type_error.carbon | 93 +++++-- .../fail_name_with_import_failure.carbon | 8 + .../packages/implicit_imports_prelude.carbon | 16 ++ .../testdata/packages/loaded_global.carbon | 32 +++ .../no_prelude/cross_package_export.carbon | 97 ++++++- .../packages/no_prelude/export_import.carbon | 96 +++++-- .../packages/no_prelude/export_mixed.carbon | 73 ++++- .../packages/no_prelude/export_name.carbon | 131 +++++++-- .../no_prelude/fail_export_name_member.carbon | 6 +- .../implicit_imports_entities.carbon | 79 +++++- .../no_prelude/missing_prelude.carbon | 48 +++- .../testdata/pointer/address_of_deref.carbon | 18 +- .../testdata/pointer/address_of_lvalue.carbon | 102 ++++++- toolchain/check/testdata/pointer/arrow.carbon | 14 +- toolchain/check/testdata/pointer/basic.carbon | 29 +- .../pointer/fail_address_of_value.carbon | 17 +- .../testdata/pointer/fail_deref_error.carbon | 22 +- .../testdata/pointer/fail_deref_type.carbon | 25 +- .../check/testdata/pointer/import.carbon | 26 ++ .../fail_return_with_returned_var.carbon | 39 ++- .../fail_returned_var_no_return_type.carbon | 43 ++- .../return/fail_returned_var_shadow.carbon | 64 +++-- .../return/fail_returned_var_type.carbon | 21 +- .../testdata/return/fail_var_in_type.carbon | 4 + .../no_prelude/import_convert_function.carbon | 8 + .../check/testdata/return/returned_var.carbon | 43 ++- .../testdata/return/returned_var_scope.carbon | 64 +++-- .../testdata/struct/fail_assign_empty.carbon | 9 + .../struct/fail_assign_to_empty.carbon | 8 + .../struct/fail_duplicate_name.carbon | 44 ++- .../struct/fail_field_name_mismatch.carbon | 18 ++ .../struct/fail_field_type_mismatch.carbon | 9 + .../struct/fail_member_access_type.carbon | 26 +- .../struct/fail_non_member_access.carbon | 21 +- .../struct/fail_too_few_values.carbon | 11 + .../testdata/struct/fail_type_assign.carbon | 13 +- .../testdata/struct/fail_value_as_type.carbon | 13 +- toolchain/check/testdata/struct/import.carbon | 161 ++++++++++- .../testdata/struct/member_access.carbon | 36 ++- .../struct/nested_struct_in_place.carbon | 29 +- .../testdata/struct/no_prelude/empty.carbon | 24 +- .../no_prelude/fail_assign_nested.carbon | 9 + .../no_prelude/fail_nested_incomplete.carbon | 21 +- .../check/testdata/struct/one_entry.carbon | 26 +- .../testdata/struct/reorder_fields.carbon | 46 ++- .../testdata/struct/tuple_as_element.carbon | 35 ++- .../check/testdata/struct/two_entries.carbon | 90 ++++-- .../tuple/access/element_access.carbon | 37 ++- .../tuple/access/fail_access_error.carbon | 25 +- .../tuple/access/fail_large_index.carbon | 45 ++- .../access/fail_negative_indexing.carbon | 25 +- .../access/fail_non_deterministic_type.carbon | 33 ++- .../tuple/access/fail_non_int_indexing.carbon | 25 +- .../tuple/access/fail_non_tuple_access.carbon | 26 +- .../access/fail_out_of_bound_access.carbon | 25 +- .../fail_out_of_bound_not_literal.carbon | 25 +- .../tuple/access/index_not_literal.carbon | 45 ++- .../testdata/tuple/fail_assign_nested.carbon | 22 ++ .../tuple/fail_element_type_mismatch.carbon | 13 + .../tuple/fail_nested_incomplete.carbon | 27 +- .../tuple/fail_too_few_element.carbon | 13 + .../testdata/tuple/fail_type_assign.carbon | 10 + .../testdata/tuple/fail_value_as_type.carbon | 13 +- toolchain/check/testdata/tuple/import.carbon | 182 +++++++++++- .../check/testdata/tuple/nested_tuple.carbon | 22 +- .../tuple/nested_tuple_in_place.carbon | 58 +++- .../testdata/tuple/no_prelude/empty.carbon | 24 +- .../tuple/no_prelude/fail_assign_empty.carbon | 10 + .../no_prelude/fail_assign_to_empty.carbon | 8 + .../check/testdata/tuple/one_element.carbon | 29 +- .../check/testdata/tuple/two_elements.carbon | 95 +++++-- .../testdata/var/fail_not_copyable.carbon | 15 +- .../var/fail_storage_is_literal.carbon | 12 +- .../var/fail_todo_control_flow_init.carbon | 36 +++ .../check/testdata/var/no_prelude/decl.carbon | 8 + .../var/no_prelude/decl_with_init.carbon | 14 +- .../var/no_prelude/export_name.carbon | 20 +- .../var/no_prelude/fail_duplicate_decl.carbon | 28 +- .../var/no_prelude/fail_generic.carbon | 19 +- .../no_prelude/fail_init_type_mismatch.carbon | 14 +- .../var/no_prelude/fail_init_with_self.carbon | 12 +- .../fail_lookup_outside_scope.carbon | 16 ++ .../var/no_prelude/fail_modifiers.carbon | 36 ++- .../no_prelude/fail_namespace_conflict.carbon | 20 +- .../var/no_prelude/global_decl.carbon | 9 + .../no_prelude/global_decl_with_init.carbon | 13 +- .../var/no_prelude/global_lookup.carbon | 26 +- .../no_prelude/global_lookup_in_scope.carbon | 28 +- .../testdata/var/no_prelude/import.carbon | 24 +- .../var/no_prelude/import_access.carbon | 40 ++- .../testdata/var/no_prelude/lookup.carbon | 14 +- .../testdata/var/no_prelude/shadowing.carbon | 42 ++- .../testdata/where_expr/designator.carbon | 8 + .../testdata/where_expr/dot_self_index.carbon | 14 +- .../testdata/where_expr/equal_rewrite.carbon | 142 +++++++--- .../testdata/where_expr/fail_not_facet.carbon | 17 +- toolchain/diagnostics/diagnostic_kind.def | 4 + toolchain/lex/token_kind.def | 3 +- toolchain/lower/file_context.cpp | 2 +- toolchain/lower/handle.cpp | 5 + toolchain/lower/testdata/alias/local.carbon | 13 +- .../testdata/array/array_in_place.carbon | 2 +- .../testdata/array/assign_return_value.carbon | 2 +- toolchain/lower/testdata/array/base.carbon | 81 +++--- .../testdata/basics/numeric_literals.carbon | 31 +-- .../testdata/builtins/no_prelude/types.carbon | 17 +- toolchain/lower/testdata/class/adapt.carbon | 2 +- toolchain/lower/testdata/class/basic.carbon | 2 +- toolchain/lower/testdata/class/convert.carbon | 19 +- toolchain/lower/testdata/class/field.carbon | 2 +- toolchain/lower/testdata/class/method.carbon | 12 +- toolchain/lower/testdata/class/virtual.carbon | 31 +-- .../function/call/empty_struct.carbon | 2 +- .../testdata/function/call/empty_tuple.carbon | 2 +- .../lower/testdata/function/call/i32.carbon | 9 +- .../call/implicit_empty_tuple_as_arg.carbon | 2 +- .../function/call/return_implicit.carbon | 2 +- .../testdata/function/call/var_param.carbon | 17 +- .../testdata/function/generic/call.carbon | 41 ++- .../function/generic/call_method.carbon | 23 +- .../lower/testdata/global/class_obj.carbon | 4 +- .../testdata/global/class_with_fun.carbon | 4 +- .../index/array_element_access.carbon | 2 +- toolchain/lower/testdata/let/tuple.carbon | 93 +++---- .../testdata/operators/assignment.carbon | 23 +- .../testdata/pointer/address_of_field.carbon | 19 +- .../testdata/pointer/address_of_unused.carbon | 9 +- toolchain/lower/testdata/pointer/basic.carbon | 13 +- .../pointer/pointer_to_pointer.carbon | 33 ++- .../testdata/return/return_var_byval.carbon | 8 +- toolchain/lower/testdata/return/var.carbon | 13 +- toolchain/lower/testdata/struct/empty.carbon | 2 +- .../testdata/struct/member_access.carbon | 29 +- .../struct/nested_struct_in_place.carbon | 2 +- .../lower/testdata/struct/one_entry.carbon | 21 +- .../lower/testdata/struct/two_entries.carbon | 29 +- .../tuple/access/element_access.carbon | 31 +-- .../tuple/access/return_value_access.carbon | 9 +- toolchain/lower/testdata/tuple/empty.carbon | 2 +- .../tuple/nested_tuple_in_place.carbon | 2 +- .../lower/testdata/tuple/one_entry.carbon | 21 +- .../lower/testdata/tuple/two_entries.carbon | 29 +- .../testdata/tuple/value_formation.carbon | 2 +- toolchain/lower/testdata/var/local.carbon | 13 +- toolchain/lower/testdata/var/nested.carbon | 39 ++- toolchain/parse/handle_var.cpp | 7 + toolchain/parse/node_kind.def | 1 + .../array/fail_require_close_bracket.carbon | 9 +- .../testdata/array/fail_require_semi.carbon | 15 +- .../parse/testdata/array/fail_syntax.carbon | 54 ++-- .../parse/testdata/array/with_length.carbon | 17 +- .../testdata/array/without_length.carbon | 15 +- toolchain/parse/testdata/auto/var.carbon | 9 +- .../testdata/basics/builtin_types.carbon | 27 +- .../basics/fail_bracket_recovery.carbon | 44 +-- .../basics/fail_paren_match_regression.carbon | 11 +- .../testdata/basics/numeric_literals.carbon | 36 +-- toolchain/parse/testdata/class/var.carbon | 11 +- .../for/fail_colon_instead_of_in.carbon | 15 +- .../parse/testdata/for/fail_missing_in.carbon | 15 +- toolchain/parse/testdata/for/nested.carbon | 30 +- toolchain/parse/testdata/for/simple.carbon | 15 +- .../function/definition/decl_statement.carbon | 31 ++- .../if_expr/fail_condition_missing.carbon | 11 +- .../if_expr/fail_else_expr_missing.carbon | 11 +- .../testdata/if_expr/fail_else_missing.carbon | 11 +- .../if_expr/fail_then_expr_missing.carbon | 11 +- .../testdata/if_expr/fail_then_missing.carbon | 11 +- .../parse/testdata/if_expr/in_type.carbon | 9 +- .../parse/testdata/index/assign_to_var.carbon | 9 +- .../testdata/index/fail_empty_expr.carbon | 9 +- .../testdata/index/fail_malformed_expr.carbon | 9 +- .../match/fail_cases_after_default.carbon | 11 +- ...il_unexpected_tokens_in_cases_block.carbon | 11 +- toolchain/parse/testdata/match/match.carbon | 11 +- .../parse/testdata/operators/assign.carbon | 20 +- .../operators/fail_chained_assign.carbon | 20 +- .../fail_infix_uneven_space_after.carbon | 9 +- .../fail_infix_uneven_space_before.carbon | 9 +- .../operators/fail_invalid_infix.carbon | 27 +- .../operators/fail_postfix_space.carbon | 9 +- .../fail_postfix_space_before_comma.carbon | 9 +- .../fail_postfix_space_in_call.carbon | 9 +- .../fail_postfix_space_surrounding.carbon | 9 +- .../operators/fail_postincrement.carbon | 11 +- .../operators/fail_precedence_assign.carbon | 11 +- .../operators/fail_prefix_space.carbon | 9 +- ...ail_prefix_uneven_space_with_assign.carbon | 9 +- .../testdata/operators/fail_star_minus.carbon | 9 +- .../testdata/operators/fail_star_star.carbon | 9 +- .../operators/fail_star_star_no_space.carbon | 9 +- .../testdata/operators/fixity_in_var.carbon | 22 +- .../testdata/operators/infix_no_space.carbon | 9 +- .../operators/infix_with_paren_after.carbon | 9 +- .../operators/infix_with_paren_before.carbon | 9 +- .../parse/testdata/operators/postfix.carbon | 9 +- .../operators/postfix_space_after_op.carbon | 9 +- .../operators/precedence_assign.carbon | 31 ++- .../parse/testdata/operators/prefix.carbon | 18 +- .../testdata/operators/prefix_no_space.carbon | 9 +- .../parse/testdata/package_expr/basic.carbon | 13 +- .../testdata/package_expr/fail_in_name.carbon | 9 +- .../testdata/pointer/pointer_type.carbon | 9 +- .../testdata/pointer/pointer_value.carbon | 35 +-- .../parse/testdata/return/returned_var.carbon | 11 +- .../testdata/struct/fail_comma_only.carbon | 15 +- .../struct/fail_comma_repeat_in_type.carbon | 25 +- .../struct/fail_comma_repeat_in_value.carbon | 25 +- .../struct/fail_extra_token_in_type.carbon | 19 +- .../struct/fail_extra_token_in_value.carbon | 19 +- .../struct/fail_identifier_colon.carbon | 13 +- .../struct/fail_identifier_equals.carbon | 13 +- .../struct/fail_identifier_only.carbon | 13 +- .../fail_invalid_struct_designator.carbon | 9 +- .../testdata/struct/fail_missing_type.carbon | 19 +- .../testdata/struct/fail_missing_value.carbon | 19 +- .../struct/fail_mix_type_and_value.carbon | 25 +- .../struct/fail_mix_value_and_type.carbon | 23 +- .../struct/fail_mix_with_unknown.carbon | 18 +- .../struct/fail_no_colon_or_equals.carbon | 17 +- .../testdata/struct/fail_period_only.carbon | 17 +- .../testdata/struct/fail_period_paren.carbon | 19 +- .../struct/fail_period_string_colon.carbon | 25 +- .../struct/fail_period_string_equals.carbon | 27 +- .../struct/fail_type_no_designator.carbon | 13 +- .../parse/testdata/struct/no_entries.carbon | 11 +- .../testdata/struct/one_entry_no_comma.carbon | 19 +- .../struct/one_entry_with_comma.carbon | 21 +- .../parse/testdata/struct/two_entries.carbon | 29 +- toolchain/parse/testdata/tuple/nested.carbon | 25 +- .../parse/testdata/tuple/two_entries.carbon | 17 +- .../parse/testdata/var/fail_bad_name.carbon | 9 +- .../parse/testdata/var/fail_empty.carbon | 9 +- .../parse/testdata/var/fail_no_semi.carbon | 13 +- toolchain/parse/testdata/var/var.carbon | 29 +- toolchain/parse/testdata/var/var_tuple.carbon | 23 +- .../testdata/where_expr/designators.carbon | 13 +- toolchain/parse/typed_nodes.h | 11 +- toolchain/parse/typed_nodes_test.cpp | 14 +- toolchain/sem_ir/file.cpp | 2 + toolchain/sem_ir/formatter.cpp | 4 + toolchain/sem_ir/ids.h | 5 + toolchain/sem_ir/inst_kind.def | 2 + toolchain/sem_ir/inst_namer.cpp | 10 +- toolchain/sem_ir/stringify_type.cpp | 2 + toolchain/sem_ir/typed_insts.h | 38 ++- toolchain/sem_ir/yaml_test.cpp | 3 +- 510 files changed, 11819 insertions(+), 3352 deletions(-) create mode 100644 toolchain/check/full_pattern_stack.h create mode 100644 toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon diff --git a/common/array_stack.h b/common/array_stack.h index 8fdbbfe47259..325ebcbdd057 100644 --- a/common/array_stack.h +++ b/common/array_stack.h @@ -47,6 +47,11 @@ class ArrayStack { return llvm::ArrayRef(values_).slice(array_offsets_.back()); } + auto PeekArray() -> llvm::MutableArrayRef { + CARBON_CHECK(!array_offsets_.empty()); + return llvm::MutableArrayRef(values_).slice(array_offsets_.back()); + } + // Returns the array at a specific index. auto PeekArrayAt(int index) const -> llvm::ArrayRef { auto ref = llvm::ArrayRef(values_).slice(array_offsets_[index]); diff --git a/toolchain/check/BUILD b/toolchain/check/BUILD index 790df1c18cb4..73432525bbb4 100644 --- a/toolchain/check/BUILD +++ b/toolchain/check/BUILD @@ -74,6 +74,7 @@ cc_library( "//common:array_stack", "//common:check", "//common:map", + "//common:set", "//common:vlog", "//toolchain/base:index_base", "//toolchain/base:kind_switch", @@ -254,6 +255,7 @@ cc_library( name = "scope_stack", srcs = ["scope_stack.cpp"], hdrs = [ + "full_pattern_stack.h", "lexical_lookup.h", "scope_index.h", "scope_stack.h", diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 0b2ef27b686a..732e27e81085 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -395,6 +395,14 @@ auto Context::LookupUnqualifiedName(Parse::NodeId node_id, } } + if (lexical_result == SemIR::InstId::InitTombstone) { + CARBON_DIAGNOSTIC(UsedBeforeInitialization, Error, + "`{0}` used before initialization", SemIR::NameId); + emitter_->Emit(node_id, UsedBeforeInitialization, name_id); + return {.specific_id = SemIR::SpecificId::Invalid, + .inst_id = SemIR::ErrorInst::SingletonInstId}; + } + if (lexical_result.is_valid()) { // A lexical scope never needs an associated specific. If there's a // lexically enclosing generic, then it also encloses the point of use of @@ -776,6 +784,7 @@ auto Context::AddConvergenceBlockAndPush(Parse::NodeId node_id, int num_blocks) if (new_block_id == SemIR::InstBlockId::Unreachable) { new_block_id = inst_blocks().AddDefaultValue(); } + CARBON_CHECK(node_id.is_valid()); AddInst(node_id, {.target_id = new_block_id}); } inst_block_stack().Pop(); diff --git a/toolchain/check/context.h b/toolchain/check/context.h index 301133d89b19..4f5110f42cb2 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -11,6 +11,7 @@ #include "toolchain/check/decl_introducer_state.h" #include "toolchain/check/decl_name_stack.h" #include "toolchain/check/diagnostic_helpers.h" +#include "toolchain/check/full_pattern_stack.h" #include "toolchain/check/generic_region_stack.h" #include "toolchain/check/global_init.h" #include "toolchain/check/inst_block_stack.h" @@ -714,6 +715,14 @@ class Context { return bind_name_map_; } + auto var_storage_map() -> Map& { + return var_storage_map_; + } + + auto full_pattern_stack() -> FullPatternStack& { + return scope_stack_.full_pattern_stack(); + } + private: // A FoldingSet node for a type. class TypeNode : public llvm::FastFoldingSetNode { @@ -831,6 +840,11 @@ class Context { Map bind_name_map_; + // Map from VarPattern insts to the corresponding VarStorage insts. The + // VarStorage insts are allocated, emitted, and stored in the map after + // processing the enclosing full-pattern. + Map var_storage_map_; + // Stack of single-entry regions being built. ArrayStack region_stack_; }; diff --git a/toolchain/check/decl_introducer_state.h b/toolchain/check/decl_introducer_state.h index 6e4e3728c593..ab86eb688352 100644 --- a/toolchain/check/decl_introducer_state.h +++ b/toolchain/check/decl_introducer_state.h @@ -15,7 +15,7 @@ namespace Carbon::Check { // declaration and the keyword modifiers that apply to that declaration // introducer. struct DeclIntroducerState { - auto modifier_node_id(ModifierOrder order) -> Parse::NodeId { + auto modifier_node_id(ModifierOrder order) const -> Parse::NodeId { return ordered_modifier_node_ids[static_cast(order)]; } auto set_modifier_node_id(ModifierOrder order, Parse::NodeId node_id) diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 4d9743f2fac5..ecae4d927a4b 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -2076,6 +2076,7 @@ static auto TryEvalInstInContext(EvalContext& eval_context, case SemIR::BranchIf::Kind: case SemIR::BranchWithArg::Kind: case SemIR::ImportDecl::Kind: + case SemIR::NameBindingDecl::Kind: case SemIR::OutParam::Kind: case SemIR::OutParamPattern::Kind: case SemIR::RequirementEquivalent::Kind: @@ -2087,6 +2088,7 @@ static auto TryEvalInstInContext(EvalContext& eval_context, case SemIR::StructLiteral::Kind: case SemIR::TupleLiteral::Kind: case SemIR::ValueParam::Kind: + case SemIR::VarPattern::Kind: case SemIR::VarStorage::Kind: break; diff --git a/toolchain/check/full_pattern_stack.h b/toolchain/check/full_pattern_stack.h new file mode 100644 index 000000000000..1043b86453ab --- /dev/null +++ b/toolchain/check/full_pattern_stack.h @@ -0,0 +1,82 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef CARBON_TOOLCHAIN_CHECK_FULL_PATTERN_STACK_H_ +#define CARBON_TOOLCHAIN_CHECK_FULL_PATTERN_STACK_H_ + +#include "common/array_stack.h" +#include "common/check.h" +#include "toolchain/check/lexical_lookup.h" +#include "toolchain/sem_ir/ids.h" + +namespace Carbon::Check { + +// Stack of full-patterns currently being checked. When a pattern +// is followed by an explicit initializer, name bindings should not be used +// within that initializer, although they are usable before it (within the +// pattern) and after it. This class keeps track of those state transitions. +// It is structured as a stack to handle situations like a pattern that +// contains an initializer, or a pattern in a lambda in an expression pattern. +// +// TODO: Unify this with Context::pattern_block_stack, or differentiate them +// more clearly (and consider unifying this with ScopeStack instead). +class FullPatternStack { + public: + explicit FullPatternStack(LexicalLookup* lookup) : lookup_(lookup) {} + + // Marks the possible start of a new full-pattern (i.e. a pattern which occurs + // in a non-pattern context). + auto PushFullPattern() -> void { bind_name_stack_.PushArray(); } + + // Marks the start of the initializer for the full-pattern at the top of the + // stack. + auto StartPatternInitializer() -> void { + for (auto& [name_id, inst_id] : bind_name_stack_.PeekArray()) { + CARBON_CHECK(inst_id == SemIR::InstId::InitTombstone); + auto& lookup_result = lookup_->Get(name_id); + if (!lookup_result.empty()) { + // TODO: find a way to preserve location information, so that we can + // provide good diagnostics for a redeclaration of `name_id` in + // the initializer, if that becomes possible. + std::swap(lookup_result.back().inst_id, inst_id); + } + } + } + + // Marks the end of the initializer for the full-pattern at the top of the + // stack. + auto EndPatternInitializer() -> void { + for (auto& [name_id, inst_id] : bind_name_stack_.PeekArray()) { + auto& lookup_result = lookup_->Get(name_id); + if (!lookup_result.empty()) { + std::swap(lookup_result.back().inst_id, inst_id); + } + CARBON_CHECK(inst_id == SemIR::InstId::InitTombstone); + } + } + + // Marks the end of checking for the full-pattern at the top of the stack. + // This cannot be called while processing an initializer for the top + // pattern. + auto PopFullPattern() -> void { bind_name_stack_.PopArray(); } + + // Records that `bind_inst_id` was introduced by the full-pattern at the + // top of the stack. + auto AddBindName(SemIR::NameId name_id) -> void { + bind_name_stack_.AppendToTop( + {.name_id = name_id, .inst_id = SemIR::InstId::InitTombstone}); + } + + private: + LexicalLookup* lookup_; + struct LookupEntry { + SemIR::NameId name_id; + SemIR::InstId inst_id; + }; + ArrayStack bind_name_stack_; +}; + +} // namespace Carbon::Check + +#endif // CARBON_TOOLCHAIN_CHECK_FULL_PATTERN_STACK_H_ diff --git a/toolchain/check/handle_binding_pattern.cpp b/toolchain/check/handle_binding_pattern.cpp index 0bf456df68e2..01d44e03aae8 100644 --- a/toolchain/check/handle_binding_pattern.cpp +++ b/toolchain/check/handle_binding_pattern.cpp @@ -5,6 +5,7 @@ #include "toolchain/check/context.h" #include "toolchain/check/convert.h" #include "toolchain/check/handle.h" +#include "toolchain/check/interface.h" #include "toolchain/check/return.h" #include "toolchain/diagnostics/format_providers.h" #include "toolchain/sem_ir/ids.h" @@ -14,6 +15,7 @@ namespace Carbon::Check { static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, bool is_generic) -> bool { + // TODO: split this into smaller, more focused functions. auto [type_node, parsed_type_id] = context.node_stack().PopExprWithNodeId(); auto [cast_type_inst_id, cast_type_id] = ExprAsType(context, type_node, parsed_type_id); @@ -39,9 +41,12 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, bool needs_compile_time_binding = is_generic && !is_associated_constant; - // Create the appropriate kind of binding for this pattern. - auto make_bind_name = [&](SemIR::TypeId type_id, - SemIR::InstId value_id) -> SemIR::LocIdAndInst { + const DeclIntroducerState& introducer = + context.decl_introducer_state_stack().innermost(); + + auto make_binding_pattern = [&]() -> SemIR::InstId { + auto bind_id = SemIR::InstId::Invalid; + auto binding_pattern_id = SemIR::InstId::Invalid; // TODO: Eventually the name will need to support associations with other // scopes, but right now we don't support qualified names here. auto entity_name_id = context.entity_names().Add( @@ -54,25 +59,43 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, : SemIR::CompileTimeBindIndex::Invalid}); if (is_generic) { // TODO: Create a `BindTemplateName` instead inside a `template` pattern. - return SemIR::LocIdAndInst( - name_node, SemIR::BindSymbolicName{.type_id = type_id, - .entity_name_id = entity_name_id, - .value_id = value_id}); + bind_id = context.AddInstInNoBlock(SemIR::LocIdAndInst( + name_node, + SemIR::BindSymbolicName{.type_id = cast_type_id, + .entity_name_id = entity_name_id, + .value_id = SemIR::InstId::Invalid})); + binding_pattern_id = + context.AddPatternInst( + name_node, + {.type_id = cast_type_id, .entity_name_id = entity_name_id}); } else { - return SemIR::LocIdAndInst( - name_node, SemIR::BindName{.type_id = type_id, + bind_id = context.AddInstInNoBlock(SemIR::LocIdAndInst( + name_node, SemIR::BindName{.type_id = cast_type_id, .entity_name_id = entity_name_id, - .value_id = value_id}); + .value_id = SemIR::InstId::Invalid})); + binding_pattern_id = context.AddPatternInst( + name_node, + {.type_id = cast_type_id, .entity_name_id = entity_name_id}); } - }; - // Push the binding onto the node stack and, if necessary, onto the scope - // stack. - auto push_bind_name = [&](SemIR::InstId bind_id) { - context.node_stack().Push(node_id, bind_id); + // Add name to lookup immediately, so it can be used in the rest of the + // enclosing pattern. if (needs_compile_time_binding) { context.scope_stack().PushCompileTimeBinding(bind_id); } + auto name_context = + context.decl_name_stack().MakeUnqualifiedName(node_id, name_id); + context.decl_name_stack().AddNameOrDiagnose( + name_context, bind_id, introducer.modifier_set.GetAccessKind()); + context.full_pattern_stack().AddBindName(name_id); + + bool inserted = context.bind_name_map() + .Insert(binding_pattern_id, + {.bind_name_id = bind_id, + .type_expr_region_id = type_expr_region_id}) + .is_inserted(); + CARBON_CHECK(inserted); + return binding_pattern_id; }; // A `self` binding can only appear in an implicit parameter list. @@ -84,12 +107,84 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, context.emitter().Emit(node_id, SelfOutsideImplicitParamList); } - // Allocate an instruction of the appropriate kind, linked to the name for - // error locations. // TODO: The node stack is a fragile way of getting context information. // Get this information from somewhere else. - switch (auto context_node_kind = context.node_stack().PeekNodeKind()) { - case Parse::NodeKind::ReturnedModifier: + auto context_node_kind = context.node_stack().PeekNodeKind(); + + // A `var` binding in a class scope declares a field, not a true binding, + // so we handle it separately. + if (auto parent_class_decl = context.GetCurrentScopeAs(); + parent_class_decl.has_value() && + context_node_kind == Parse::NodeKind::VariableIntroducer) { + cast_type_id = context.AsConcreteType( + cast_type_id, type_node, + [&] { + CARBON_DIAGNOSTIC(IncompleteTypeInFieldDecl, Error, + "field has incomplete type {0}", SemIR::TypeId); + return context.emitter().Build(type_node, IncompleteTypeInFieldDecl, + cast_type_id); + }, + [&] { + CARBON_DIAGNOSTIC(AbstractTypeInFieldDecl, Error, + "field has abstract type {0}", SemIR::TypeId); + return context.emitter().Build(type_node, AbstractTypeInFieldDecl, + cast_type_id); + }); + auto binding_id = + is_generic ? Parse::NodeId::Invalid + : context.parse_tree().As(node_id); + auto& class_info = context.classes().Get(parent_class_decl->class_id); + auto field_type_id = + context.GetUnboundElementType(class_info.self_type_id, cast_type_id); + auto field_id = context.AddInst( + binding_id, {.type_id = field_type_id, + .name_id = name_id, + .index = SemIR::ElementIndex::Invalid}); + context.field_decls_stack().AppendToTop(field_id); + + context.node_stack().Push(node_id, field_id); + auto name_context = + context.decl_name_stack().MakeUnqualifiedName(node_id, name_id); + context.decl_name_stack().AddNameOrDiagnose( + name_context, field_id, introducer.modifier_set.GetAccessKind()); + return true; + } + + // A binding in an interface scope declares an associated constant, not a + // true binding, so we handle it separately. + if (auto parent_interface_decl = + context.GetCurrentScopeAs(); + parent_interface_decl.has_value() && is_generic) { + cast_type_id = context.AsCompleteType(cast_type_id, type_node, [&] { + CARBON_DIAGNOSTIC(IncompleteTypeInAssociatedDecl, Error, + "associated constant has incomplete type {0}", + SemIR::TypeId); + return context.emitter().Build(type_node, IncompleteTypeInAssociatedDecl, + cast_type_id); + }); + context.entity_names().Add( + {.name_id = name_id, + .parent_scope_id = context.scope_stack().PeekNameScopeId(), + .bind_index = SemIR::CompileTimeBindIndex::Invalid}); + + SemIR::InstId decl_id = context.AddInst( + context.parse_tree().As(node_id), + {cast_type_id, name_id}); + context.node_stack().Push(node_id, decl_id); + + // Add an associated entity name to the interface scope. + auto assoc_id = BuildAssociatedEntity( + context, parent_interface_decl->interface_id, decl_id); + auto name_context = + context.decl_name_stack().MakeUnqualifiedName(node_id, name_id); + context.decl_name_stack().AddNameOrDiagnose( + name_context, assoc_id, introducer.modifier_set.GetAccessKind()); + return true; + } + + // Allocate an instruction of the appropriate kind, linked to the name for + // error locations. + switch (context_node_kind) { case Parse::NodeKind::VariableIntroducer: { if (is_generic) { CARBON_DIAGNOSTIC( @@ -99,64 +194,36 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, // Prevent lambda helpers from creating a compile time binding. needs_compile_time_binding = false; } - auto binding_id = - is_generic - ? Parse::NodeId::Invalid - : context.parse_tree().As(node_id); - // A `var` declaration at class scope introduces a field. - auto parent_class_decl = context.GetCurrentScopeAs(); cast_type_id = context.AsConcreteType( cast_type_id, type_node, [&] { CARBON_DIAGNOSTIC(IncompleteTypeInVarDecl, Error, - "{0:field|variable} has incomplete type {1}", - BoolAsSelect, SemIR::TypeId); + "variable has incomplete type {0}", + SemIR::TypeId); return context.emitter().Build(type_node, IncompleteTypeInVarDecl, - parent_class_decl.has_value(), cast_type_id); }, [&] { CARBON_DIAGNOSTIC(AbstractTypeInVarDecl, Error, - "{0:field|variable} has abstract type {1}", - BoolAsSelect, SemIR::TypeId); + "variable has abstract type {0}", SemIR::TypeId); return context.emitter().Build(type_node, AbstractTypeInVarDecl, - parent_class_decl.has_value(), cast_type_id); }); - if (parent_class_decl) { - CARBON_CHECK(context_node_kind == Parse::NodeKind::VariableIntroducer, - "`returned var` at class scope"); - auto& class_info = context.classes().Get(parent_class_decl->class_id); - auto field_type_id = context.GetUnboundElementType( - class_info.self_type_id, cast_type_id); - auto field_id = context.AddInst( - binding_id, {.type_id = field_type_id, - .name_id = name_id, - .index = SemIR::ElementIndex::Invalid}); - context.field_decls_stack().AppendToTop(field_id); - context.node_stack().Push(node_id, field_id); - break; - } - - SemIR::InstId value_id = SemIR::InstId::Invalid; - if (context_node_kind == Parse::NodeKind::ReturnedModifier) { + auto binding_pattern_id = make_binding_pattern(); + if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Returned)) { // TODO: Should we check this for the `var` as a whole, rather than for // the name binding? - value_id = - CheckReturnedVar(context, context.node_stack().PeekNodeId(), - name_node, name_id, type_node, cast_type_id); - } else { - value_id = context.AddInst( - name_node, {.type_id = cast_type_id, .name_id = name_id}); - } - auto bind_id = context.AddInst(make_bind_name(cast_type_id, value_id)); - push_bind_name(bind_id); - - if (context_node_kind == Parse::NodeKind::ReturnedModifier) { - RegisterReturnedVar(context, bind_id); + auto bind_id = context.bind_name_map() + .Lookup(binding_pattern_id) + .value() + .bind_name_id; + RegisterReturnedVar(context, + introducer.modifier_node_id(ModifierOrder::Decl), + type_node, cast_type_id, bind_id); } + context.node_stack().Push(node_id, binding_pattern_id); break; } @@ -168,7 +235,7 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, // parameters. auto param_pattern_id = SemIR::InstId::Invalid; bool had_error = false; - switch (context.decl_introducer_state_stack().innermost().kind) { + switch (introducer.kind) { case Lex::TokenKind::Fn: { if (context_node_kind == Parse::NodeKind::ImplicitParamListStart && !(is_generic || name_id == SemIR::NameId::SelfValue)) { @@ -205,33 +272,7 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, // try constructing a generic based on it. param_pattern_id = SemIR::ErrorInst::SingletonInstId; } else { - auto bind_id = context.AddInstInNoBlock( - make_bind_name(cast_type_id, SemIR::InstId::Invalid)); - if (needs_compile_time_binding) { - context.scope_stack().PushCompileTimeBinding(bind_id); - } - // TODO: Bindings should come into scope immediately in other contexts - // too. - context.AddNameToLookup(name_id, bind_id); - auto entity_name_id = - context.insts().GetAs(bind_id).entity_name_id; - auto pattern_inst_id = SemIR::InstId::Invalid; - if (is_generic) { - pattern_inst_id = - context.AddPatternInst( - name_node, - {.type_id = cast_type_id, .entity_name_id = entity_name_id}); - } else { - pattern_inst_id = context.AddPatternInst( - name_node, - {.type_id = cast_type_id, .entity_name_id = entity_name_id}); - } - bool inserted = context.bind_name_map() - .Insert(pattern_inst_id, {.bind_name_id = bind_id, - .type_expr_region_id = - type_expr_region_id}) - .is_inserted(); - CARBON_CHECK(inserted); + auto pattern_inst_id = make_binding_pattern(); param_pattern_id = context.AddPatternInst( node_id, { @@ -257,13 +298,7 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id, return context.emitter().Build(type_node, IncompleteTypeInLetDecl, cast_type_inst_id); }); - // Create the instruction, but don't add it to a block until after we've - // formed its initializer. - // TODO: For general pattern parsing, we'll need to create a block to hold - // the `let` pattern before we see the initializer. - auto bind_id = context.AddPlaceholderInstInNoBlock( - make_bind_name(cast_type_id, SemIR::InstId::Invalid)); - push_bind_name(bind_id); + context.node_stack().Push(node_id, make_binding_pattern()); break; } diff --git a/toolchain/check/handle_impl.cpp b/toolchain/check/handle_impl.cpp index 65ec19237b16..84e3a6fe7df9 100644 --- a/toolchain/check/handle_impl.cpp +++ b/toolchain/check/handle_impl.cpp @@ -42,6 +42,7 @@ auto HandleParseNode(Context& context, Parse::ImplIntroducerId node_id) // TODO: Instead use a separate parse node kinds for `impl` and `impl forall`, // and only push a pattern block in `forall` case. context.pattern_block_stack().Push(); + context.full_pattern_stack().PushFullPattern(); return true; } diff --git a/toolchain/check/handle_let_and_var.cpp b/toolchain/check/handle_let_and_var.cpp index f07c4fcd373b..11c90bc4b8c3 100644 --- a/toolchain/check/handle_let_and_var.cpp +++ b/toolchain/check/handle_let_and_var.cpp @@ -8,6 +8,8 @@ #include "toolchain/check/handle.h" #include "toolchain/check/interface.h" #include "toolchain/check/modifiers.h" +#include "toolchain/check/pattern_match.h" +#include "toolchain/check/return.h" #include "toolchain/diagnostics/diagnostic_emitter.h" #include "toolchain/lex/token_kind.h" #include "toolchain/sem_ir/inst.h" @@ -22,6 +24,7 @@ static auto HandleIntroducer(Context& context, Parse::NodeId node_id) -> bool { // Push a bracketing node and pattern block to establish the pattern context. context.node_stack().Push(node_id); context.pattern_block_stack().Push(); + context.full_pattern_stack().PushFullPattern(); context.BeginSubpattern(); return true; } @@ -35,18 +38,91 @@ auto HandleParseNode(Context& context, Parse::VariableIntroducerId node_id) return HandleIntroducer(context, node_id); } -auto HandleParseNode(Context& context, Parse::ReturnedModifierId node_id) +// Returns a VarStorage inst for the given pattern. If the pattern +// is the body of a returned var, this reuses the return slot, and otherwise it +// adds a new inst. +static auto GetOrAddStorage(Context& context, SemIR::InstId pattern_id) + -> SemIR::InstId { + if (context.decl_introducer_state_stack().innermost().modifier_set.HasAnyOf( + KeywordModifierSet::Returned)) { + auto& function = GetCurrentFunctionForReturn(context); + auto return_info = + SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), function); + if (return_info.has_return_slot()) { + return GetCurrentReturnSlot(context); + } + } + auto pattern = context.insts().GetWithLocId(pattern_id); + auto subpattern = + context.insts().Get(pattern.inst.As().subpattern_id); + + // Try to populate name_id on a best-effort basis. + auto name_id = SemIR::NameId::Invalid; + if (auto binding_pattern = subpattern.TryAs()) { + name_id = + context.entity_names().Get(binding_pattern->entity_name_id).name_id; + } + return context.AddInst(SemIR::LocIdAndInst::UncheckedLoc( + pattern.loc_id, SemIR::VarStorage{.type_id = subpattern.type_id(), + .pretty_name_id = name_id})); +} + +auto HandleParseNode(Context& context, Parse::VariablePatternId node_id) -> bool { - // This is pushed to be seen by HandleBindingPattern. - context.node_stack().Push(node_id); + auto subpattern_id = SemIR::InstId::Invalid; + if (context.node_stack().PeekIs(Parse::NodeKind::TuplePattern)) { + context.node_stack().PopAndIgnore(); + CARBON_CHECK( + context.node_stack().PeekIs(Parse::NodeKind::TuplePatternStart)); + context.node_stack().PopAndIgnore(); + context.inst_block_stack().PopAndDiscard(); + context.TODO(node_id, "tuple pattern in let/var"); + subpattern_id = SemIR::ErrorInst::SingletonInstId; + } else { + subpattern_id = context.node_stack().PopPattern(); + } + auto type_id = context.insts().Get(subpattern_id).type_id(); + + auto pattern_id = context.AddPatternInst( + node_id, {.type_id = type_id, .subpattern_id = subpattern_id}); + context.node_stack().Push(node_id, pattern_id); return true; } +// Handle the end of the full-pattern of a let/var declaration (before the +// start of the initializer, if any). +static auto EndFullPattern(Context& context) -> void { + if (context.GetCurrentScopeAs()) { + // Don't emit NameBindingDecl for an associated constant, because it will + // always be empty. + context.pattern_block_stack().PopAndDiscard(); + return; + } + auto pattern_block_id = context.pattern_block_stack().Pop(); + context.AddInst( + context.node_stack().PeekNodeId(), + {.pattern_block_id = pattern_block_id}); + + // We need to emit the VarStorage insts early, because they may be output + // arguments for the initializer. However, we can't emit them when we emit + // the corresponding `VarPattern`s because they're part of the pattern match, + // not part of the pattern. + // TODO: find a way to do this without walking the whole pattern block. + for (auto inst_id : context.inst_blocks().Get(pattern_block_id)) { + if (context.insts().Is(inst_id)) { + context.var_storage_map().Insert(inst_id, + GetOrAddStorage(context, inst_id)); + } + } +} + static auto HandleInitializer(Context& context, Parse::NodeId node_id) -> bool { + EndFullPattern(context); if (context.scope_stack().PeekIndex() == ScopeIndex::Package) { context.global_init().Resume(); } context.node_stack().Push(node_id); + context.full_pattern_stack().StartPatternInitializer(); return true; } @@ -60,73 +136,6 @@ auto HandleParseNode(Context& context, Parse::VariableInitializerId node_id) return HandleInitializer(context, node_id); } -// Builds an associated constant declaration for a `let`. -static auto BuildAssociatedConstantDecl(Context& context, - Parse::LetDeclId node_id, - SemIR::InstId pattern_id, - SemIR::LocIdAndInst pattern, - SemIR::InterfaceId interface_id, - SemIR::AccessKind access_kind) -> void { - auto& interface_info = context.interfaces().Get(interface_id); - - auto binding_pattern = pattern.inst.TryAs(); - if (!binding_pattern) { - CARBON_DIAGNOSTIC(ExpectedSymbolicBindingInAssociatedConstant, Error, - "pattern in associated constant declaration must be a " - "single `:!` binding"); - context.emitter().Emit(pattern.loc_id, - ExpectedSymbolicBindingInAssociatedConstant); - context.name_scopes().Get(interface_info.scope_id).set_has_error(); - return; - } - - // Replace the tentative BindName instruction with the associated constant - // declaration. - auto name_id = - context.entity_names().Get(binding_pattern->entity_name_id).name_id; - context.ReplaceLocIdAndInstBeforeConstantUse( - pattern_id, - SemIR::LocIdAndInst(node_id, SemIR::AssociatedConstantDecl{ - binding_pattern->type_id, name_id})); - auto decl_id = pattern_id; - context.inst_block_stack().AddInstId(decl_id); - - // Add an associated entity name to the interface scope. - auto assoc_id = BuildAssociatedEntity(context, interface_id, decl_id); - auto name_context = - context.decl_name_stack().MakeUnqualifiedName(pattern.loc_id, name_id); - context.decl_name_stack().AddNameOrDiagnose(name_context, assoc_id, - access_kind); -} - -// Adds name bindings. Returns the resulting ID for the references. -static auto HandleNameBinding(Context& context, SemIR::InstId pattern_id, - SemIR::AccessKind access_kind) -> SemIR::InstId { - // Extract the name binding. - if (auto bind_name = - context.insts().TryGetAs(pattern_id)) { - // Form a corresponding name in the current context, and bind the name to - // the variable. - auto name_context = context.decl_name_stack().MakeUnqualifiedName( - context.insts().GetLocId(pattern_id), - context.entity_names().Get(bind_name->entity_name_id).name_id); - context.decl_name_stack().AddNameOrDiagnose(name_context, pattern_id, - access_kind); - return bind_name->value_id; - } else if (auto field_decl = - context.insts().TryGetAs(pattern_id)) { - // Introduce the field name into the class. - auto name_context = context.decl_name_stack().MakeUnqualifiedName( - context.insts().GetLocId(pattern_id), field_decl->name_id); - context.decl_name_stack().AddNameOrDiagnose(name_context, pattern_id, - access_kind); - return pattern_id; - } else { - // TODO: Handle other kinds of pattern. - return pattern_id; - } -} - namespace { // State from HandleDecl, returned for type-specific handling. struct DeclInfo { @@ -148,15 +157,18 @@ static auto HandleDecl(Context& context, NodeT node_id) -> std::optional { std::optional decl_info = DeclInfo(); - // TODO: Update binding-pattern handling to use the pattern block even in - // a let/var context, and then consume it here. - context.pattern_block_stack().PopAndDiscard(); - // Handle the optional initializer. if (context.node_stack().PeekNextIs(InitializerNodeKind)) { decl_info->init_id = context.node_stack().PopExpr(); context.node_stack().PopAndDiscardSoloNodeId(); + if (context.scope_stack().PeekIndex() == ScopeIndex::Package) { + context.global_init().Suspend(); + } + context.full_pattern_stack().EndPatternInitializer(); + } else { + EndFullPattern(context); } + context.full_pattern_stack().PopFullPattern(); if (context.node_stack().PeekIs(Parse::NodeKind::TuplePattern)) { if (decl_info->init_id && @@ -170,12 +182,6 @@ static auto HandleDecl(Context& context, NodeT node_id) decl_info->pattern_id = context.node_stack().PopPattern(); - if constexpr (IntroducerTokenKind == Lex::TokenKind::Var) { - // Pop the `returned` modifier if present. - context.node_stack() - .PopAndDiscardSoloNodeIdIf(); - } - context.node_stack().PopAndDiscardSoloNodeId(); // Process declaration modifiers. @@ -193,6 +199,32 @@ static auto HandleDecl(Context& context, NodeT node_id) return decl_info; } +static auto HandleAssociatedConstantDecl(Context& context, + Parse::LetDeclId node_id, + DeclInfo decl_info, + SemIR::InterfaceDecl interface_scope) + -> void { + auto pattern = context.insts().GetWithLocId(decl_info.pattern_id); + + if (decl_info.init_id) { + // Convert the value to match the type of the pattern. + ConvertToValueOfType(context, node_id, *decl_info.init_id, + pattern.inst.type_id()); + } + + if (auto decl = pattern.inst.TryAs(); + !decl.has_value()) { + CARBON_DIAGNOSTIC(ExpectedSymbolicBindingInAssociatedConstant, Error, + "pattern in associated constant declaration must be a " + "single `:!` binding"); + context.emitter().Emit(pattern.loc_id, + ExpectedSymbolicBindingInAssociatedConstant); + context.name_scopes() + .Get(context.interfaces().Get(interface_scope.interface_id).scope_id) + .set_has_error(); + } +} + auto HandleParseNode(Context& context, Parse::LetDeclId node_id) -> bool { auto decl_info = HandleDecl bool { "interface modifier"); } - auto pattern = context.insts().GetWithLocId(decl_info->pattern_id); - - if (decl_info->init_id) { - // Convert the value to match the type of the pattern. - decl_info->init_id = ConvertToValueOfType( - context, node_id, *decl_info->init_id, pattern.inst.type_id()); - } - - auto interface_scope = context.GetCurrentScopeAs(); - // At interface scope, we are forming an associated constant, which has // different rules. - if (interface_scope) { - BuildAssociatedConstantDecl( - context, node_id, decl_info->pattern_id, pattern, - interface_scope->interface_id, - decl_info->introducer.modifier_set.GetAccessKind()); + if (auto interface_scope = context.GetCurrentScopeAs(); + interface_scope) { + HandleAssociatedConstantDecl(context, node_id, *decl_info, + *interface_scope); return true; } - if (!decl_info->init_id) { + if (decl_info->init_id) { + LocalPatternMatch(context, decl_info->pattern_id, *decl_info->init_id); + } else { CARBON_DIAGNOSTIC( ExpectedInitializerAfterLet, Error, "expected `=`; `let` declaration must have an initializer"); context.emitter().Emit(TokenOnly(node_id), ExpectedInitializerAfterLet); } - // Update the binding with its value and add it to the current block, after - // the computation of the value. - // TODO: Support other kinds of pattern here. - auto bind_name = pattern.inst.As(); - CARBON_CHECK(!bind_name.value_id.is_valid(), - "Binding should not already have a value!"); - bind_name.value_id = decl_info->init_id ? *decl_info->init_id - : SemIR::ErrorInst::SingletonInstId; - context.ReplaceInstBeforeConstantUse(decl_info->pattern_id, bind_name); - context.inst_block_stack().AddInstId(decl_info->pattern_id); - - HandleNameBinding(context, decl_info->pattern_id, - decl_info->introducer.modifier_set.GetAccessKind()); - - if (decl_info->init_id && - context.scope_stack().PeekIndex() == ScopeIndex::Package) { - context.global_init().Suspend(); - } - return true; } @@ -270,32 +274,20 @@ auto HandleParseNode(Context& context, Parse::VariableDeclId node_id) -> bool { return false; } - LimitModifiersOnDecl(context, decl_info->introducer, - KeywordModifierSet::Access); + LimitModifiersOnDecl( + context, decl_info->introducer, + KeywordModifierSet::Access | KeywordModifierSet::Returned); - decl_info->pattern_id = - HandleNameBinding(context, decl_info->pattern_id, - decl_info->introducer.modifier_set.GetAccessKind()); - - // If there was an initializer, assign it to the storage. - if (decl_info->init_id) { - if (context.GetCurrentScopeAs()) { + if (context.GetCurrentScopeAs()) { + if (decl_info->init_id) { // TODO: In a class scope, we should instead save the initializer // somewhere so that we can use it as a default. context.TODO(node_id, "Field initializer"); - } else { - decl_info->init_id = Initialize(context, node_id, decl_info->pattern_id, - *decl_info->init_id); - // TODO: Consider using different instruction kinds for assignment - // versus initialization. - context.AddInst(node_id, {.lhs_id = decl_info->pattern_id, - .rhs_id = *decl_info->init_id}); - } - - if (context.scope_stack().PeekIndex() == ScopeIndex::Package) { - context.global_init().Suspend(); } + return true; } + LocalPatternMatch(context, decl_info->pattern_id, + decl_info->init_id.value_or(SemIR::InstId::Invalid)); return true; } diff --git a/toolchain/check/handle_modifier.cpp b/toolchain/check/handle_modifier.cpp index 7398aa4ebde4..27a752c51001 100644 --- a/toolchain/check/handle_modifier.cpp +++ b/toolchain/check/handle_modifier.cpp @@ -119,4 +119,9 @@ auto HandleParseNode(Context& context, Parse::ExternModifierId node_id) return HandleModifier(context, node_id, KeywordModifierSet::Extern); } +auto HandleParseNode(Context& context, Parse::ReturnedModifierId node_id) + -> bool { + return HandleModifier(context, node_id, KeywordModifierSet::Returned); +} + } // namespace Carbon::Check diff --git a/toolchain/check/handle_name.cpp b/toolchain/check/handle_name.cpp index 2e117f8d38d3..003c9aadcb9d 100644 --- a/toolchain/check/handle_name.cpp +++ b/toolchain/check/handle_name.cpp @@ -143,6 +143,7 @@ auto HandleParseNode(Context& context, Parse::IdentifierNameBeforeParamsId node_id) -> bool { // Push a pattern block stack entry to handle the parameter pattern. context.pattern_block_stack().Push(); + context.full_pattern_stack().PushFullPattern(); return HandleIdentifierName(context, node_id); } diff --git a/toolchain/check/keyword_modifier_set.h b/toolchain/check/keyword_modifier_set.h index 78b4275fa2c6..316f3c699c4a 100644 --- a/toolchain/check/keyword_modifier_set.h +++ b/toolchain/check/keyword_modifier_set.h @@ -45,6 +45,7 @@ class KeywordModifierSet { Final = 1 << 8, Impl = 1 << 9, Virtual = 1 << 10, + Returned = 1 << 11, // Sets of modifiers: Access = Private | Protected, @@ -52,10 +53,10 @@ class KeywordModifierSet { Method = Abstract | Impl | Virtual, ImplDecl = Extend | Final, Interface = Default | Final, - Decl = Class | Method | ImplDecl | Interface | Export, + Decl = Class | Method | ImplDecl | Interface | Export | Returned, None = 0, - LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Virtual) + LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Returned) }; // Default construct to empty. @@ -112,7 +113,7 @@ class KeywordModifierSet { } // Returns the access kind from modifiers. - auto GetAccessKind() -> SemIR::AccessKind { + auto GetAccessKind() const -> SemIR::AccessKind { if (HasAnyOf(KeywordModifierSet::Protected)) { return SemIR::AccessKind::Protected; } diff --git a/toolchain/check/name_component.cpp b/toolchain/check/name_component.cpp index fe7e2ffee1b8..f2f245623c50 100644 --- a/toolchain/check/name_component.cpp +++ b/toolchain/check/name_component.cpp @@ -50,6 +50,7 @@ auto PopNameComponent(Context& context, SemIR::InstId return_slot_pattern_id) CalleePatternMatch(context, *implicit_param_patterns_id, *param_patterns_id, return_slot_pattern_id); pattern_block_id = context.pattern_block_stack().Pop(); + context.full_pattern_stack().PopFullPattern(); } auto [name_loc_id, name_id] = diff --git a/toolchain/check/node_stack.h b/toolchain/check/node_stack.h index edcbe9018349..d1614d07f818 100644 --- a/toolchain/check/node_stack.h +++ b/toolchain/check/node_stack.h @@ -406,6 +406,7 @@ class NodeStack { case Parse::NodeKind::ShortCircuitOperandAnd: case Parse::NodeKind::ShortCircuitOperandOr: case Parse::NodeKind::StructLiteralField: + case Parse::NodeKind::VariablePattern: case Parse::NodeKind::WhereOperand: return Id::KindFor(); case Parse::NodeKind::IfCondition: diff --git a/toolchain/check/pattern_match.cpp b/toolchain/check/pattern_match.cpp index 4c2c88e3b496..02bcd7b6fc19 100644 --- a/toolchain/check/pattern_match.cpp +++ b/toolchain/check/pattern_match.cpp @@ -46,7 +46,9 @@ enum class MatchKind : uint8_t { // against the portion of the pattern below the ParamPattern insts. Callee, - // TODO: Add enumerator for non-function-call pattern match. + // Local pattern matching is pattern matching outside of a function call, + // such as in a let/var declaration. + Local, }; // The collected state of a pattern-matching operation. @@ -140,7 +142,7 @@ auto MatchContext::EmitPatternMatch(Context& context, CARBON_KIND_SWITCH(pattern.inst) { case SemIR::BindingPattern::Kind: case SemIR::SymbolicBindingPattern::Kind: { - CARBON_CHECK(kind_ == MatchKind::Callee); + auto binding_pattern = pattern.inst.As(); // We're logically consuming this map entry, so we invalidate it in order // to avoid accidentally consuming it twice. auto [bind_name_id, type_expr_region_id] = std::exchange( @@ -148,19 +150,34 @@ auto MatchContext::EmitPatternMatch(Context& context, {.bind_name_id = SemIR::InstId::Invalid, .type_expr_region_id = SemIR::ExprRegionId::Invalid}); context.InsertHere(type_expr_region_id); + auto value_id = entry.scrutinee_id; + switch (kind_) { + case MatchKind::Local: { + value_id = ConvertToValueOrRefOfType( + context, context.insts().GetLocId(entry.scrutinee_id), + entry.scrutinee_id, binding_pattern.type_id); + break; + } + case MatchKind::Callee: { + if (context.insts() + .GetAs(value_id) + .runtime_index.is_valid()) { + results_.push_back(value_id); + } + break; + } + case MatchKind::Caller: + CARBON_FATAL("Found binding pattern during caller pattern match"); + } auto bind_name = context.insts().GetAs(bind_name_id); CARBON_CHECK(!bind_name.value_id.is_valid()); - bind_name.value_id = entry.scrutinee_id; + bind_name.value_id = value_id; context.ReplaceInstBeforeConstantUse(bind_name_id, bind_name); context.inst_block_stack().AddInstId(bind_name_id); - if (context.insts() - .GetAs(entry.scrutinee_id) - .runtime_index.is_valid()) { - results_.push_back(entry.scrutinee_id); - } break; } case CARBON_KIND(SemIR::AddrPattern addr_pattern): { + CARBON_CHECK(kind_ != MatchKind::Local); if (kind_ == MatchKind::Callee) { // We're emitting pattern-match IR for the callee, but we're still on // the caller side of the pattern, so we traverse without emitting any @@ -233,6 +250,9 @@ auto MatchContext::EmitPatternMatch(Context& context, .pretty_name_id = GetPrettyName(context, param_pattern)})}); break; } + case MatchKind::Local: { + CARBON_FATAL("Found ValueParamPattern during local pattern match"); + } } break; } @@ -267,6 +287,9 @@ auto MatchContext::EmitPatternMatch(Context& context, .pretty_name_id = GetPrettyName(context, param_pattern)})}); break; } + case MatchKind::Local: { + CARBON_FATAL("Found OutParamPattern during local pattern match"); + } } break; } @@ -284,6 +307,29 @@ auto MatchContext::EmitPatternMatch(Context& context, results_.push_back(entry.scrutinee_id); break; } + case CARBON_KIND(SemIR::VarPattern var_pattern): { + auto var_id = context.var_storage_map().Lookup(entry.pattern_id).value(); + // TODO: Find a more efficient way to put these insts in the global_init + // block (or drop the distinction between the global_init block and the + // file scope?) + if (context.scope_stack().PeekIndex() == ScopeIndex::Package) { + context.global_init().Resume(); + } + if (entry.scrutinee_id.is_valid()) { + auto init_id = + Initialize(context, pattern.loc_id, var_id, entry.scrutinee_id); + // TODO: Consider using different instruction kinds for assignment + // versus initialization. + context.AddInst(pattern.loc_id, + {.lhs_id = var_id, .rhs_id = init_id}); + } + AddWork( + {.pattern_id = var_pattern.subpattern_id, .scrutinee_id = var_id}); + if (context.scope_stack().PeekIndex() == ScopeIndex::Package) { + context.global_init().Suspend(); + } + break; + } default: { CARBON_FATAL("Inst kind not handled: {0}", pattern.inst.kind()); } @@ -366,4 +412,11 @@ auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id, return match.DoWork(context); } +auto LocalPatternMatch(Context& context, SemIR::InstId pattern_id, + SemIR::InstId scrutinee_id) -> void { + MatchContext match(MatchKind::Local); + match.AddWork({.pattern_id = pattern_id, .scrutinee_id = scrutinee_id}); + match.DoWork(context); +} + } // namespace Carbon::Check diff --git a/toolchain/check/pattern_match.h b/toolchain/check/pattern_match.h index f146bd26a918..c48df3f3d97b 100644 --- a/toolchain/check/pattern_match.h +++ b/toolchain/check/pattern_match.h @@ -43,6 +43,11 @@ auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id, llvm::ArrayRef arg_refs, SemIR::InstId return_slot_arg_id) -> SemIR::InstBlockId; +// Emits the pattern-match IR for a local pattern matching operation with the +// given pattern and scrutinee. +auto LocalPatternMatch(Context& context, SemIR::InstId pattern_id, + SemIR::InstId scrutinee_id) -> void; + } // namespace Carbon::Check #endif // CARBON_TOOLCHAIN_CHECK_PATTERN_MATCH_H_ diff --git a/toolchain/check/return.cpp b/toolchain/check/return.cpp index f40c22ee7e9b..a3f35ffc79c5 100644 --- a/toolchain/check/return.cpp +++ b/toolchain/check/return.cpp @@ -10,7 +10,7 @@ namespace Carbon::Check { // Gets the function that lexically encloses the current location. -static auto GetCurrentFunction(Context& context) -> SemIR::Function& { +auto GetCurrentFunctionForReturn(Context& context) -> SemIR::Function& { CARBON_CHECK(!context.return_scope_stack().empty(), "Handling return but not in a function"); auto function_id = context.insts() @@ -20,9 +20,7 @@ static auto GetCurrentFunction(Context& context) -> SemIR::Function& { return context.functions().Get(function_id); } -// Gets the return slot of the function that lexically encloses the current -// location. -static auto GetCurrentReturnSlot(Context& context) -> SemIR::InstId { +auto GetCurrentReturnSlot(Context& context) -> SemIR::InstId { // TODO: this does some unnecessary work to compute non-lexical scopes, // so a separate API on ScopeStack could be more efficient. auto return_slot_id = context.scope_stack() @@ -70,18 +68,15 @@ static auto NoteReturnedVar(Context::DiagnosticBuilder& diag, diag.Note(returned_var_id, ReturnedVarHere); } -auto CheckReturnedVar(Context& context, Parse::NodeId returned_node, - Parse::NodeId name_node, SemIR::NameId name_id, - Parse::NodeId type_node, SemIR::TypeId type_id) - -> SemIR::InstId { - auto& function = GetCurrentFunction(context); +auto RegisterReturnedVar(Context& context, Parse::NodeId returned_node, + Parse::NodeId type_node, SemIR::TypeId type_id, + SemIR::InstId bind_id) -> void { + auto& function = GetCurrentFunctionForReturn(context); auto return_info = SemIR::ReturnTypeInfo::ForFunction(context.sem_ir(), function); if (!return_info.is_valid()) { - // We already diagnosed this when we started defining the function. Create a - // placeholder for error recovery. - return context.AddInst( - name_node, {.type_id = type_id, .name_id = name_id}); + // We already diagnosed this when we started defining the function. + return; } // A `returned var` requires an explicit return type. @@ -92,7 +87,7 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node, context.emitter().Build(returned_node, ReturnedVarWithNoReturnType); NoteNoReturnTypeProvided(diag, function); diag.Emit(); - return SemIR::ErrorInst::SingletonInstId; + return; } // The declared type of the var must match the return type of the function. @@ -105,19 +100,8 @@ auto CheckReturnedVar(Context& context, Parse::NodeId returned_node, context.emitter().Build(type_node, ReturnedVarWrongType, type_id); NoteReturnType(context, diag, function); diag.Emit(); - return SemIR::ErrorInst::SingletonInstId; } - // The variable aliases the return slot if there is one. If not, it has its - // own storage. - if (return_info.has_return_slot()) { - return GetCurrentReturnSlot(context); - } - return context.AddInst( - name_node, {.type_id = type_id, .name_id = name_id}); -} - -auto RegisterReturnedVar(Context& context, SemIR::InstId bind_id) -> void { auto existing_id = context.scope_stack().SetReturnedVarOrGetExisting(bind_id); if (existing_id.is_valid()) { CARBON_DIAGNOSTIC(ReturnedVarShadowed, Error, @@ -131,7 +115,7 @@ auto RegisterReturnedVar(Context& context, SemIR::InstId bind_id) -> void { auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id) -> void { - const auto& function = GetCurrentFunction(context); + const auto& function = GetCurrentFunctionForReturn(context); auto return_type_id = function.GetDeclaredReturnType(context.sem_ir()); if (return_type_id.is_valid()) { @@ -147,7 +131,7 @@ auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id) auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id, SemIR::InstId expr_id) -> void { - const auto& function = GetCurrentFunction(context); + const auto& function = GetCurrentFunctionForReturn(context); auto returned_var_id = GetCurrentReturnedVar(context); auto return_slot_id = SemIR::InstId::Invalid; auto return_info = @@ -189,7 +173,7 @@ auto BuildReturnWithExpr(Context& context, Parse::ReturnStatementId node_id, auto BuildReturnVar(Context& context, Parse::ReturnStatementId node_id) -> void { - const auto& function = GetCurrentFunction(context); + const auto& function = GetCurrentFunctionForReturn(context); auto returned_var_id = GetCurrentReturnedVar(context); if (!returned_var_id.is_valid()) { diff --git a/toolchain/check/return.h b/toolchain/check/return.h index 31dde77b8750..0748850f32b6 100644 --- a/toolchain/check/return.h +++ b/toolchain/check/return.h @@ -10,15 +10,19 @@ namespace Carbon::Check { -// Checks a `returned var` binding and returns the location of the return -// value storage that the name should bind to. -auto CheckReturnedVar(Context& context, Parse::NodeId returned_node, - Parse::NodeId name_node, SemIR::NameId name_id, - Parse::NodeId type_node, SemIR::TypeId type_id) - -> SemIR::InstId; +// Gets the function that a `return` statement in the current context would +// return from. +auto GetCurrentFunctionForReturn(Context& context) -> SemIR::Function&; -// Registers the given binding as the current `returned var` in this scope. -auto RegisterReturnedVar(Context& context, SemIR::InstId bind_id) -> void; +// Gets the return slot of the function that lexically encloses the current +// location. +auto GetCurrentReturnSlot(Context& context) -> SemIR::InstId; + +// Checks a `returned var` binding and registers it as the current `returned +// var` in this scope. +auto RegisterReturnedVar(Context& context, Parse::NodeId returned_node, + Parse::NodeId type_node, SemIR::TypeId type_id, + SemIR::InstId bind_id) -> void; // Checks and builds SemIR for a `return;` statement. auto BuildReturnWithNoExpr(Context& context, Parse::ReturnStatementId node_id) diff --git a/toolchain/check/scope_stack.h b/toolchain/check/scope_stack.h index a1ba60c4d14d..f76400adabaa 100644 --- a/toolchain/check/scope_stack.h +++ b/toolchain/check/scope_stack.h @@ -8,6 +8,7 @@ #include "common/array_stack.h" #include "common/set.h" #include "llvm/ADT/SmallVector.h" +#include "toolchain/check/full_pattern_stack.h" #include "toolchain/check/lexical_lookup.h" #include "toolchain/check/scope_index.h" #include "toolchain/sem_ir/file.h" @@ -20,7 +21,7 @@ namespace Carbon::Check { class ScopeStack { public: explicit ScopeStack(const CanonicalValueStore& identifiers) - : lexical_lookup_(identifiers) {} + : lexical_lookup_(identifiers), full_pattern_stack_(&lexical_lookup_) {} // A scope in which `break` and `continue` can be used. struct BreakContinueScope { @@ -166,6 +167,8 @@ class ScopeStack { return compile_time_binding_stack_; } + auto full_pattern_stack() -> FullPatternStack& { return full_pattern_stack_; } + private: // An entry in scope_stack_. struct ScopeStackEntry { @@ -244,6 +247,9 @@ class ScopeStack { // Tracks lexical lookup results. LexicalLookup lexical_lookup_; + + // Stack of full-patterns currently being checked. + FullPatternStack full_pattern_stack_; }; struct ScopeStack::SuspendedScope { diff --git a/toolchain/check/testdata/alias/fail_bool_value.carbon b/toolchain/check/testdata/alias/fail_bool_value.carbon index 678258538acc..5c9c45d73d5a 100644 --- a/toolchain/check/testdata/alias/fail_bool_value.carbon +++ b/toolchain/check/testdata/alias/fail_bool_value.carbon @@ -19,6 +19,8 @@ let a_test: bool = a; // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %false: bool = bool_literal false [template] +// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -33,17 +35,25 @@ let a_test: bool = a; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a -// CHECK:STDOUT: .a_test = @__global_init.%a_test +// CHECK:STDOUT: .a_test = %a_test // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] // CHECK:STDOUT: %a: = bind_alias a, [template = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_test.patt: bool = binding_pattern a_test +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16_13.1: type = splice_block %.loc16_13.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc16_13.2: type = value_of_initializer %bool.make_type [template = bool] +// CHECK:STDOUT: %.loc16_13.3: type = converted %bool.make_type, %.loc16_13.2 [template = bool] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a_test: bool = bind_name a_test, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: = name_ref a, file.%a [template = ] -// CHECK:STDOUT: %a_test: bool = bind_name a_test, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon b/toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon index 9bbf88269bf2..7dac2c8ea027 100644 --- a/toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon +++ b/toolchain/check/testdata/alias/no_prelude/alias_of_alias.carbon @@ -29,7 +29,7 @@ let d: c = {}; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b // CHECK:STDOUT: .c = %c -// CHECK:STDOUT: .d = @__global_init.%d +// CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] @@ -38,6 +38,15 @@ let d: c = {}; // CHECK:STDOUT: %b: type = bind_alias b, %a [template = constants.%C] // CHECK:STDOUT: %b.ref: type = name_ref b, %b [template = constants.%C] // CHECK:STDOUT: %c: type = bind_alias c, %b [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %C = binding_pattern d +// CHECK:STDOUT: } +// CHECK:STDOUT: %c.ref: type = name_ref c, %c [template = constants.%C] +// CHECK:STDOUT: %.loc15_13.1: ref %C = temporary_storage +// CHECK:STDOUT: %.loc15_13.2: init %C = class_init (), %.loc15_13.1 [template = constants.%C.val] +// CHECK:STDOUT: %.loc15_13.3: ref %C = temporary %.loc15_13.1, %.loc15_13.2 +// CHECK:STDOUT: %.loc15_13.4: ref %C = converted @__global_init.%.loc15, %.loc15_13.3 +// CHECK:STDOUT: %d: ref %C = bind_name d, %.loc15_13.4 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { @@ -47,13 +56,7 @@ let d: c = {}; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc15_13.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc15_13.2: ref %C = temporary_storage -// CHECK:STDOUT: %.loc15_13.3: init %C = class_init (), %.loc15_13.2 [template = constants.%C.val] -// CHECK:STDOUT: %.loc15_13.4: ref %C = temporary %.loc15_13.2, %.loc15_13.3 -// CHECK:STDOUT: %.loc15_14.1: ref %C = converted %.loc15_13.1, %.loc15_13.4 -// CHECK:STDOUT: %.loc15_14.2: %C = bind_value %.loc15_14.1 -// CHECK:STDOUT: %d: %C = bind_name d, %.loc15_14.2 +// CHECK:STDOUT: %.loc15: %empty_struct_type = struct_literal () // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/export_name.carbon b/toolchain/check/testdata/alias/no_prelude/export_name.carbon index 83f4dab69204..c14b254de1de 100644 --- a/toolchain/check/testdata/alias/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/alias/no_prelude/export_name.carbon @@ -166,7 +166,12 @@ var d: D* = &c; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %C = binding_pattern d +// CHECK:STDOUT: %.loc6: %C = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %C = var d +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.c3f [template = constants.%C] // CHECK:STDOUT: %d: ref %C = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -178,8 +183,8 @@ var d: D* = &c; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), file.%d.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_14: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%d.var, %.loc6_14 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%d.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -199,8 +204,13 @@ var d: D* = &c; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc10: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: %C.ref: = name_ref C, [template = ] +// CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -234,9 +244,22 @@ var d: D* = &c; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %ptr.019 = binding_pattern d +// CHECK:STDOUT: %.loc8_1: %ptr.019 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %ptr.019 = var d +// CHECK:STDOUT: %.loc8_9: type = splice_block %ptr [template = constants.%ptr.019] { +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.c3f [template = constants.%C] +// CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %ptr.019 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -248,8 +271,8 @@ var d: D* = &c; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_13.2: init %C = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_14: init %C = converted %.loc7_13.1, %.loc7_13.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_14 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_13.1, %.loc7_13.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c // CHECK:STDOUT: %addr: %ptr.019 = addr_of %c.ref // CHECK:STDOUT: assign file.%d.var, %addr diff --git a/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon b/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon index 25e61149adc8..fbc8732fd957 100644 --- a/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon @@ -14,9 +14,9 @@ class D {} alias c = C; var d: D = {}; -// CHECK:STDERR: fail_aliased_name_in_diag.carbon:[[@LINE+4]]:1: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound] +// CHECK:STDERR: fail_aliased_name_in_diag.carbon:[[@LINE+4]]:16: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound] // CHECK:STDERR: let c_var: c = d; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^ // CHECK:STDERR: let c_var: c = d; @@ -36,14 +36,25 @@ let c_var: c = d; // CHECK:STDOUT: .D = %D.decl // CHECK:STDOUT: .c = %c // CHECK:STDOUT: .d = %d -// CHECK:STDOUT: .c_var = @__global_init.%c_var +// CHECK:STDOUT: .c_var = %c_var // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {} // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %c: type = bind_alias c, %C.decl [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %D = binding_pattern d +// CHECK:STDOUT: %.loc15: %D = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %D = var d +// CHECK:STDOUT: %D.ref: type = name_ref D, %D.decl [template = constants.%D] // CHECK:STDOUT: %d: ref %D = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_var.patt: %C = binding_pattern c_var +// CHECK:STDOUT: } +// CHECK:STDOUT: %c.ref: type = name_ref c, %c [template = constants.%C] +// CHECK:STDOUT: %.loc21: %C = converted @__global_init.%d.ref, [template = ] +// CHECK:STDOUT: %c_var: %C = bind_name c_var, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { @@ -60,11 +71,9 @@ let c_var: c = d; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc15_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc15_13.2: init %D = class_init (), file.%d.var [template = constants.%D.val] -// CHECK:STDOUT: %.loc15_14: init %D = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%D.val] -// CHECK:STDOUT: assign file.%d.var, %.loc15_14 +// CHECK:STDOUT: %.loc15_1: init %D = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%D.val] +// CHECK:STDOUT: assign file.%d.var, %.loc15_1 // CHECK:STDOUT: %d.ref: ref %D = name_ref d, file.%d -// CHECK:STDOUT: %.loc21: %C = converted %d.ref, [template = ] -// CHECK:STDOUT: %c_var: %C = bind_name c_var, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon b/toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon index d57c2908bb23..4cde4fa881eb 100644 --- a/toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_name_conflict.carbon @@ -48,9 +48,19 @@ alias b = C; // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %a.loc13: type = bind_alias a, %C.decl [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C = binding_pattern a +// CHECK:STDOUT: %.loc21: %C = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C = var a +// CHECK:STDOUT: %C.ref.loc21: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %a.loc21: ref %C = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %C = binding_pattern b +// CHECK:STDOUT: %.loc23: %C = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %C = var b +// CHECK:STDOUT: %C.ref.loc23: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %b: ref %C = bind_name b, %b.var // CHECK:STDOUT: %C.ref.loc31: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %.loc31: type = bind_alias , %C.decl [template = constants.%C] @@ -65,12 +75,12 @@ alias b = C; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc21_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc21_13.2: init %C = class_init (), file.%a.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc21_14: init %C = converted %.loc21_13.1, %.loc21_13.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%a.var, %.loc21_14 +// CHECK:STDOUT: %.loc21_1: init %C = converted %.loc21_13.1, %.loc21_13.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%a.var, %.loc21_1 // CHECK:STDOUT: %.loc23_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc23_13.2: init %C = class_init (), file.%b.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc23_14: init %C = converted %.loc23_13.1, %.loc23_13.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%b.var, %.loc23_14 +// CHECK:STDOUT: %.loc23_1: init %C = converted %.loc23_13.1, %.loc23_13.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%b.var, %.loc23_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon b/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon index 5e19c89fca92..cbd291e22c80 100644 --- a/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon +++ b/toolchain/check/testdata/alias/no_prelude/fail_not_constant.carbon @@ -37,17 +37,34 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc12_3.1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a -// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: %.loc12_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc12_16.2: init %empty_tuple.type = tuple_init () to %a.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_17: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %a.var, %.loc12_17 +// CHECK:STDOUT: %.loc12_3.2: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %a.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %ptr = binding_pattern b +// CHECK:STDOUT: %.loc13_3: %ptr = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %ptr = var b -// CHECK:STDOUT: %b: ref %ptr = bind_name b, %b.var // CHECK:STDOUT: %a.ref: ref %empty_tuple.type = name_ref a, %a // CHECK:STDOUT: %addr: %ptr = addr_of %a.ref // CHECK:STDOUT: assign %b.var, %addr +// CHECK:STDOUT: %.loc13_12.1: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %.loc13_11: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_12.2: type = converted %.loc13_11, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %ptr: type = ptr_type %empty_tuple.type [template = constants.%ptr] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %ptr = bind_name b, %b.var // CHECK:STDOUT: %b.ref: ref %ptr = name_ref b, %b // CHECK:STDOUT: %.loc18_14: %ptr = bind_value %b.ref // CHECK:STDOUT: %.loc18_13: ref %empty_tuple.type = deref %.loc18_14 diff --git a/toolchain/check/testdata/alias/no_prelude/import.carbon b/toolchain/check/testdata/alias/no_prelude/import.carbon index cf6f4ffe9a1f..19350989d7f0 100644 --- a/toolchain/check/testdata/alias/no_prelude/import.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import.carbon @@ -83,9 +83,17 @@ var c: () = a_alias_alias; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} -// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %c_alias: type = bind_alias c_alias, %C.decl [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %ptr = binding_pattern a +// CHECK:STDOUT: %.loc8_1: %ptr = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %ptr = var a +// CHECK:STDOUT: %.loc8_9: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %ptr = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -119,9 +127,17 @@ var c: () = a_alias_alias; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %c_alias.ref: type = name_ref c_alias, imports.%import_ref.204 [template = constants.%C] +// CHECK:STDOUT: %c_alias.ref.loc6: type = name_ref c_alias, imports.%import_ref.204 [template = constants.%C] // CHECK:STDOUT: %c_alias_alias: type = bind_alias c_alias_alias, imports.%import_ref.204 [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %ptr = binding_pattern b +// CHECK:STDOUT: %.loc8_1: %ptr = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %ptr = var b +// CHECK:STDOUT: %.loc8_15: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %c_alias.ref.loc8: type = name_ref c_alias, imports.%import_ref.204 [template = constants.%C] +// CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %ptr = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -151,7 +167,15 @@ var c: () = a_alias_alias; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %ptr = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %ptr = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %ptr = var c +// CHECK:STDOUT: %.loc6_21: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %c_alias_alias.ref: type = name_ref c_alias_alias, imports.%import_ref.3fd [template = constants.%C] +// CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %ptr = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -171,7 +195,15 @@ var c: () = a_alias_alias; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .a_alias = %a_alias // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %empty_tuple.type = name_ref a, %a // CHECK:STDOUT: %a_alias: ref %empty_tuple.type = bind_alias a_alias, %a @@ -181,8 +213,8 @@ var c: () = a_alias_alias; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_14.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc4_14.2: init %empty_tuple.type = tuple_init () to file.%a.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_15: init %empty_tuple.type = converted %.loc4_14.1, %.loc4_14.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc4_15 +// CHECK:STDOUT: %.loc4_1: init %empty_tuple.type = converted %.loc4_14.1, %.loc4_14.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -208,7 +240,15 @@ var c: () = a_alias_alias; // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %a_alias.ref: ref %empty_tuple.type = name_ref a_alias, imports.%import_ref.22c // CHECK:STDOUT: %a_alias_alias: ref %empty_tuple.type = bind_alias a_alias_alias, imports.%import_ref.22c +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b +// CHECK:STDOUT: %.loc8_9.1: type = splice_block %.loc8_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc8_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_9.3: type = converted %.loc8_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -216,8 +256,8 @@ var c: () = a_alias_alias; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a_alias.ref: ref %empty_tuple.type = name_ref a_alias, imports.%import_ref.22c // CHECK:STDOUT: %.loc8_13: init %empty_tuple.type = tuple_init () to file.%b.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc8_20: init %empty_tuple.type = converted %a_alias.ref, %.loc8_13 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%b.var, %.loc8_20 +// CHECK:STDOUT: %.loc8_1: init %empty_tuple.type = converted %a_alias.ref, %.loc8_13 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%b.var, %.loc8_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -240,7 +280,15 @@ var c: () = a_alias_alias; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %empty_tuple.type = binding_pattern c +// CHECK:STDOUT: %.loc11_1: %empty_tuple.type = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %empty_tuple.type = var c +// CHECK:STDOUT: %.loc11_9.1: type = splice_block %.loc11_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc11_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_9.3: type = converted %.loc11_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -248,8 +296,8 @@ var c: () = a_alias_alias; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a_alias_alias.ref: ref %empty_tuple.type = name_ref a_alias_alias, imports.%import_ref.692 [template = ] // CHECK:STDOUT: %.loc11_13: init %empty_tuple.type = tuple_init () to file.%c.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc11_26: init %empty_tuple.type = converted %a_alias_alias.ref, %.loc11_13 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%c.var, %.loc11_26 +// CHECK:STDOUT: %.loc11_1: init %empty_tuple.type = converted %a_alias_alias.ref, %.loc11_13 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%c.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/import_access.carbon b/toolchain/check/testdata/alias/no_prelude/import_access.carbon index 8016a1d92acf..777bc3553018 100644 --- a/toolchain/check/testdata/alias/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import_access.carbon @@ -99,7 +99,12 @@ var inst: Test.A = {}; // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %inst.patt: %C = binding_pattern inst +// CHECK:STDOUT: %.loc4: %C = var_pattern %inst.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %inst.var: ref %C = var inst +// CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.323 [template = constants.%C] // CHECK:STDOUT: %inst: ref %C = bind_name inst, %inst.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -111,8 +116,8 @@ var inst: Test.A = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_16.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc4_16.2: init %C = class_init (), file.%inst.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc4_17: init %C = converted %.loc4_16.1, %.loc4_16.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%inst.var, %.loc4_17 +// CHECK:STDOUT: %.loc4_1: init %C = converted %.loc4_16.1, %.loc4_16.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%inst.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -132,8 +137,13 @@ var inst: Test.A = {}; // CHECK:STDOUT: .inst = %inst // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %inst.patt: = binding_pattern inst +// CHECK:STDOUT: %.loc10: = var_pattern %inst.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %inst.var: ref = var inst -// CHECK:STDOUT: %inst: ref = bind_name inst, %inst.var +// CHECK:STDOUT: %A.ref: = name_ref A, [template = ] +// CHECK:STDOUT: %inst: = bind_name inst, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -161,8 +171,16 @@ var inst: Test.A = {}; // CHECK:STDOUT: .inst = %inst // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %inst.patt: = binding_pattern inst +// CHECK:STDOUT: %.loc10: = var_pattern %inst.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %inst.var: ref = var inst -// CHECK:STDOUT: %inst: ref = bind_name inst, %inst.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] +// CHECK:STDOUT: %A.ref: = name_ref A, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %inst: = bind_name inst, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { diff --git a/toolchain/check/testdata/alias/no_prelude/import_order.carbon b/toolchain/check/testdata/alias/no_prelude/import_order.carbon index 3367d7a577a0..78ee22805865 100644 --- a/toolchain/check/testdata/alias/no_prelude/import_order.carbon +++ b/toolchain/check/testdata/alias/no_prelude/import_order.carbon @@ -60,7 +60,11 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc4: %C.elem = field_decl v, element0 [template] +// CHECK:STDOUT: %.loc4_16: %C.elem = field_decl v, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc4_11: %C.elem = var_pattern %.loc4_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.v [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -100,13 +104,33 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: .a_val = %a_val // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d_val.patt: %C = binding_pattern d_val +// CHECK:STDOUT: %.loc7: %C = var_pattern %d_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d_val.var: ref %C = var d_val +// CHECK:STDOUT: %d.ref: type = name_ref d, imports.%import_ref.14f [template = constants.%C] // CHECK:STDOUT: %d_val: ref %C = bind_name d_val, %d_val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_val.patt: %C = binding_pattern c_val +// CHECK:STDOUT: %.loc8: %C = var_pattern %c_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_val.var: ref %C = var c_val +// CHECK:STDOUT: %c.ref: type = name_ref c, imports.%import_ref.610 [template = constants.%C] // CHECK:STDOUT: %c_val: ref %C = bind_name c_val, %c_val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_val.patt: %C = binding_pattern b_val +// CHECK:STDOUT: %.loc9: %C = var_pattern %b_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_val.var: ref %C = var b_val +// CHECK:STDOUT: %b.ref: type = name_ref b, imports.%import_ref.fb0 [template = constants.%C] // CHECK:STDOUT: %b_val: ref %C = bind_name b_val, %b_val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_val.patt: %C = binding_pattern a_val +// CHECK:STDOUT: %.loc10: %C = var_pattern %a_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_val.var: ref %C = var a_val +// CHECK:STDOUT: %a.ref: type = name_ref a, imports.%import_ref.e38 [template = constants.%C] // CHECK:STDOUT: %a_val: ref %C = bind_name a_val, %a_val.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -122,8 +146,8 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: %.loc7_23.2: init %empty_tuple.type = tuple_init () to %.loc7_24.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_24.3: init %empty_tuple.type = converted %.loc7_23.1, %.loc7_23.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_24.4: init %C = class_init (%.loc7_24.3), file.%d_val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_25: init %C = converted %.loc7_24.1, %.loc7_24.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%d_val.var, %.loc7_25 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_24.1, %.loc7_24.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%d_val.var, %.loc7_1 // CHECK:STDOUT: %d_val.ref: ref %C = name_ref d_val, file.%d_val // CHECK:STDOUT: %v.ref.loc8: %C.elem = name_ref v, imports.%import_ref.f99 [template = imports.%.2fc] // CHECK:STDOUT: %.loc8_27.1: ref %empty_tuple.type = class_element_access %d_val.ref, element0 @@ -132,8 +156,8 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: %.loc8_27.2: init %empty_tuple.type = tuple_init () to %.loc8_29.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_29.3: init %empty_tuple.type = converted %.loc8_27.1, %.loc8_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_29.4: init %C = class_init (%.loc8_29.3), file.%c_val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc8_30: init %C = converted %.loc8_29.1, %.loc8_29.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c_val.var, %.loc8_30 +// CHECK:STDOUT: %.loc8_1: init %C = converted %.loc8_29.1, %.loc8_29.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c_val.var, %.loc8_1 // CHECK:STDOUT: %c_val.ref: ref %C = name_ref c_val, file.%c_val // CHECK:STDOUT: %v.ref.loc9: %C.elem = name_ref v, imports.%import_ref.f99 [template = imports.%.2fc] // CHECK:STDOUT: %.loc9_27.1: ref %empty_tuple.type = class_element_access %c_val.ref, element0 @@ -142,8 +166,8 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: %.loc9_27.2: init %empty_tuple.type = tuple_init () to %.loc9_29.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc9_29.3: init %empty_tuple.type = converted %.loc9_27.1, %.loc9_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc9_29.4: init %C = class_init (%.loc9_29.3), file.%b_val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc9_30: init %C = converted %.loc9_29.1, %.loc9_29.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%b_val.var, %.loc9_30 +// CHECK:STDOUT: %.loc9_1: init %C = converted %.loc9_29.1, %.loc9_29.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%b_val.var, %.loc9_1 // CHECK:STDOUT: %b_val.ref: ref %C = name_ref b_val, file.%b_val // CHECK:STDOUT: %v.ref.loc10: %C.elem = name_ref v, imports.%import_ref.f99 [template = imports.%.2fc] // CHECK:STDOUT: %.loc10_27.1: ref %empty_tuple.type = class_element_access %b_val.ref, element0 @@ -152,8 +176,8 @@ var a_val: a = {.v = b_val.v}; // CHECK:STDOUT: %.loc10_27.2: init %empty_tuple.type = tuple_init () to %.loc10_29.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc10_29.3: init %empty_tuple.type = converted %.loc10_27.1, %.loc10_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc10_29.4: init %C = class_init (%.loc10_29.3), file.%a_val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc10_30: init %C = converted %.loc10_29.1, %.loc10_29.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%a_val.var, %.loc10_30 +// CHECK:STDOUT: %.loc10_1: init %C = converted %.loc10_29.1, %.loc10_29.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%a_val.var, %.loc10_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon b/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon index e818d451debc..6d820cd408b6 100644 --- a/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon +++ b/toolchain/check/testdata/alias/no_prelude/in_namespace.carbon @@ -37,7 +37,7 @@ fn F() -> NS.a { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .NS = %NS -// CHECK:STDOUT: .b = @__global_init.%b +// CHECK:STDOUT: .b = %b // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} @@ -46,6 +46,21 @@ fn F() -> NS.a { // CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %a: type = bind_alias a, %C.decl [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %C = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16_10: type = splice_block %a.ref [template = constants.%C] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, %NS [template = %NS] +// CHECK:STDOUT: %a.ref: type = name_ref a, %a [template = constants.%C] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16_23.1: ref %C = temporary_storage +// CHECK:STDOUT: %.loc16_23.2: ref %empty_tuple.type = class_element_access %.loc16_23.1, element0 +// CHECK:STDOUT: %.loc16_22: init %empty_tuple.type = tuple_init () to %.loc16_23.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc16_23.3: init %empty_tuple.type = converted @__global_init.%.loc16_22, %.loc16_22 [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc16_23.4: init %C = class_init (%.loc16_23.3), %.loc16_23.1 [template = constants.%C.val] +// CHECK:STDOUT: %.loc16_23.5: ref %C = temporary %.loc16_23.1, %.loc16_23.4 +// CHECK:STDOUT: %.loc16_23.6: ref %C = converted @__global_init.%.loc16_23, %.loc16_23.5 +// CHECK:STDOUT: %b: ref %C = bind_name b, %.loc16_23.6 // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 @@ -58,7 +73,11 @@ fn F() -> NS.a { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc11: %C.elem = field_decl v, element0 [template] +// CHECK:STDOUT: %.loc11_16: %C.elem = field_decl v, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc11_11: %C.elem = var_pattern %.loc11_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.v [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -77,17 +96,8 @@ fn F() -> NS.a { // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc16_22.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc16_23.1: %struct_type.v = struct_literal (%.loc16_22.1) -// CHECK:STDOUT: %.loc16_23.2: ref %C = temporary_storage -// CHECK:STDOUT: %.loc16_23.3: ref %empty_tuple.type = class_element_access %.loc16_23.2, element0 -// CHECK:STDOUT: %.loc16_22.2: init %empty_tuple.type = tuple_init () to %.loc16_23.3 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_23.4: init %empty_tuple.type = converted %.loc16_22.1, %.loc16_22.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_23.5: init %C = class_init (%.loc16_23.4), %.loc16_23.2 [template = constants.%C.val] -// CHECK:STDOUT: %.loc16_23.6: ref %C = temporary %.loc16_23.2, %.loc16_23.5 -// CHECK:STDOUT: %.loc16_24.1: ref %C = converted %.loc16_23.1, %.loc16_23.6 -// CHECK:STDOUT: %.loc16_24.2: %C = bind_value %.loc16_24.1 -// CHECK:STDOUT: %b: %C = bind_name b, %.loc16_24.2 +// CHECK:STDOUT: %.loc16_22: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_23: %struct_type.v = struct_literal (%.loc16_22) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/alias/no_prelude/local.carbon b/toolchain/check/testdata/alias/no_prelude/local.carbon index 10112e19a49d..671eaa0ebf09 100644 --- a/toolchain/check/testdata/alias/no_prelude/local.carbon +++ b/toolchain/check/testdata/alias/no_prelude/local.carbon @@ -40,12 +40,20 @@ fn F() -> () { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %empty_tuple.type { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc12_3.1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a -// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: %.loc12_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc12_16.2: init %empty_tuple.type = tuple_init () to %a.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_17: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %a.var, %.loc12_17 +// CHECK:STDOUT: %.loc12_3.2: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %a.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %empty_tuple.type = name_ref a, %a // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_alias b, %a // CHECK:STDOUT: %b.ref: ref %empty_tuple.type = name_ref b, %b diff --git a/toolchain/check/testdata/array/array_in_place.carbon b/toolchain/check/testdata/array/array_in_place.carbon index fb17f2b6175b..47ef1d7d7e35 100644 --- a/toolchain/check/testdata/array/array_in_place.carbon +++ b/toolchain/check/testdata/array/array_in_place.carbon @@ -69,8 +69,11 @@ fn G() { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %array_type = binding_pattern v +// CHECK:STDOUT: %.loc14_3.1: %array_type = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %array_type = var v -// CHECK:STDOUT: %v: ref %array_type = bind_name v, %v.var // CHECK:STDOUT: %F.ref.loc14_34: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %.loc14_42.1: ref %tuple.type.189 = splice_block %.loc14_42.2 { // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] @@ -85,8 +88,21 @@ fn G() { // CHECK:STDOUT: %F.call.loc14_41: init %tuple.type.189 = call %F.ref.loc14_39() to %.loc14_42.3 // CHECK:STDOUT: %.loc14_42.5: %tuple.type.99b = tuple_literal (%F.call.loc14_36, %F.call.loc14_41) // CHECK:STDOUT: %.loc14_42.6: init %array_type = array_init (%F.call.loc14_36, %F.call.loc14_41) to %v.var -// CHECK:STDOUT: %.loc14_43: init %array_type = converted %.loc14_42.5, %.loc14_42.6 -// CHECK:STDOUT: assign %v.var, %.loc14_43 +// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %.loc14_42.5, %.loc14_42.6 +// CHECK:STDOUT: assign %v.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_29: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc14_12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_25.1: %tuple.type.ff9 = tuple_literal (%i32.loc14_12, %i32.loc14_17, %i32.loc14_22) +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] +// CHECK:STDOUT: %.loc14_25.2: type = converted %.loc14_25.1, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: %array_type: type = array_type %int_2, %tuple.type.189 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %array_type = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/array_vs_tuple.carbon b/toolchain/check/testdata/array/array_vs_tuple.carbon index 8bdda099b045..a47f72d980c0 100644 --- a/toolchain/check/testdata/array/array_vs_tuple.carbon +++ b/toolchain/check/testdata/array/array_vs_tuple.carbon @@ -41,6 +41,7 @@ fn G() { // CHECK:STDOUT: %Convert.specific_fn.b42: = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template] // CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [template] +// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [template] // CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [template] // CHECK:STDOUT: %tuple: %tuple.type.189 = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [template] // CHECK:STDOUT: } @@ -65,12 +66,15 @@ fn G() { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc13_3.1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: %int_1.loc13_22: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc13_25: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc13: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc13_29.1: %tuple.type.37f = tuple_literal (%int_1.loc13_22, %int_2.loc13_25, %int_3.loc13) +// CHECK:STDOUT: %int_3.loc13_28: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc13_29.1: %tuple.type.37f = tuple_literal (%int_1.loc13_22, %int_2.loc13_25, %int_3.loc13_28) // CHECK:STDOUT: %impl.elem0.loc13_29.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc13_29.1: = bound_method %int_1.loc13_22, %impl.elem0.loc13_29.1 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc13_29.1: = specific_function %Convert.bound.loc13_29.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] @@ -88,18 +92,28 @@ fn G() { // CHECK:STDOUT: %.loc13_29.6: ref %i32 = array_index %a.var, %int_1.loc13_29 // CHECK:STDOUT: %.loc13_29.7: init %i32 = initialize_from %.loc13_29.5 to %.loc13_29.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %impl.elem0.loc13_29.3: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc13_29.3: = bound_method %int_3.loc13, %impl.elem0.loc13_29.3 [template = constants.%Convert.bound.b30] +// CHECK:STDOUT: %Convert.bound.loc13_29.3: = bound_method %int_3.loc13_28, %impl.elem0.loc13_29.3 [template = constants.%Convert.bound.b30] // CHECK:STDOUT: %Convert.specific_fn.loc13_29.3: = specific_function %Convert.bound.loc13_29.3, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc13_29.3: init %i32 = call %Convert.specific_fn.loc13_29.3(%int_3.loc13) [template = constants.%int_3.822] -// CHECK:STDOUT: %.loc13_29.8: init %i32 = converted %int_3.loc13, %int.convert_checked.loc13_29.3 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc13_29.3: init %i32 = call %Convert.specific_fn.loc13_29.3(%int_3.loc13_28) [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc13_29.8: init %i32 = converted %int_3.loc13_28, %int.convert_checked.loc13_29.3 [template = constants.%int_3.822] // CHECK:STDOUT: %int_2.loc13_29: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc13_29.9: ref %i32 = array_index %a.var, %int_2.loc13_29 // CHECK:STDOUT: %.loc13_29.10: init %i32 = initialize_from %.loc13_29.8 to %.loc13_29.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc13_29.11: init %array_type = array_init (%.loc13_29.4, %.loc13_29.7, %.loc13_29.10) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc13_30: init %array_type = converted %.loc13_29.1, %.loc13_29.11 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc13_30 +// CHECK:STDOUT: %.loc13_3.2: init %array_type = converted %.loc13_29.1, %.loc13_29.11 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc13_3.2 +// CHECK:STDOUT: %.loc13_17: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc13_16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3.loc13_16, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %tuple.type.189 = binding_pattern b +// CHECK:STDOUT: %.loc14_3.1: %tuple.type.189 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %tuple.type.189 = var b -// CHECK:STDOUT: %b: ref %tuple.type.189 = bind_name b, %b.var // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc14: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %int_3.loc14: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] @@ -126,8 +140,19 @@ fn G() { // CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %b.var, element2 // CHECK:STDOUT: %.loc14_36.7: init %i32 = initialize_from %.loc14_36.6 to %tuple.elem2 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc14_36.8: init %tuple.type.189 = tuple_init (%.loc14_36.3, %.loc14_36.5, %.loc14_36.7) to %b.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc14_37: init %tuple.type.189 = converted %.loc14_36.1, %.loc14_36.8 [template = constants.%tuple] -// CHECK:STDOUT: assign %b.var, %.loc14_37 +// CHECK:STDOUT: %.loc14_3.2: init %tuple.type.189 = converted %.loc14_36.1, %.loc14_36.8 [template = constants.%tuple] +// CHECK:STDOUT: assign %b.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_24.1: type = splice_block %.loc14_24.3 [template = constants.%tuple.type.189] { +// CHECK:STDOUT: %int_32.loc14_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_24.2: %tuple.type.ff9 = tuple_literal (%i32.loc14_11, %i32.loc14_16, %i32.loc14_21) +// CHECK:STDOUT: %.loc14_24.3: type = converted %.loc14_24.2, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %tuple.type.189 = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/assign_return_value.carbon b/toolchain/check/testdata/array/assign_return_value.carbon index 7956091b57a9..e882233d4369 100644 --- a/toolchain/check/testdata/array/assign_return_value.carbon +++ b/toolchain/check/testdata/array/assign_return_value.carbon @@ -86,8 +86,11 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t.patt: %array_type = binding_pattern t +// CHECK:STDOUT: %.loc14_3.1: %array_type = var_pattern %t.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t.var: ref %array_type = var t -// CHECK:STDOUT: %t: ref %array_type = bind_name t, %t.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %F.call: init %tuple.type.a1c = call %F.ref() // CHECK:STDOUT: %.loc14_23.1: ref %tuple.type.a1c = temporary_storage @@ -98,8 +101,15 @@ fn Run() { // CHECK:STDOUT: %.loc14_23.4: ref %i32 = array_index %t.var, %int_0 // CHECK:STDOUT: %.loc14_23.5: init %i32 = initialize_from %.loc14_23.3 to %.loc14_23.4 // CHECK:STDOUT: %.loc14_23.6: init %array_type = array_init (%.loc14_23.5) to %t.var -// CHECK:STDOUT: %.loc14_24: init %array_type = converted %F.call, %.loc14_23.6 -// CHECK:STDOUT: assign %t.var, %.loc14_24 +// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %F.call, %.loc14_23.6 +// CHECK:STDOUT: assign %t.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_17: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %t: ref %array_type = bind_name t, %t.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/assign_var.carbon b/toolchain/check/testdata/array/assign_var.carbon index 891af5952c6d..54975068a189 100644 --- a/toolchain/check/testdata/array/assign_var.carbon +++ b/toolchain/check/testdata/array/assign_var.carbon @@ -16,6 +16,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [template] // CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] @@ -55,9 +56,33 @@ var b: [i32; 3] = a; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.189 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.189 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.189 = var a +// CHECK:STDOUT: %.loc11_22.1: type = splice_block %.loc11_22.3 [template = constants.%tuple.type.189] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_22.2: %tuple.type.ff9 = tuple_literal (%i32.loc11_9, %i32.loc11_14, %i32.loc11_19) +// CHECK:STDOUT: %.loc11_22.3: type = converted %.loc11_22.2, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.189 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %array_type = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %array_type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %array_type = var b +// CHECK:STDOUT: %.loc12_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %array_type = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -89,8 +114,8 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %tuple.elem2.loc11: ref %i32 = tuple_access file.%a.var, element2 // CHECK:STDOUT: %.loc11_34.7: init %i32 = initialize_from %.loc11_34.6 to %tuple.elem2.loc11 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc11_34.8: init %tuple.type.189 = tuple_init (%.loc11_34.3, %.loc11_34.5, %.loc11_34.7) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_35: init %tuple.type.189 = converted %.loc11_34.1, %.loc11_34.8 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_35 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.189 = converted %.loc11_34.1, %.loc11_34.8 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.189 = name_ref a, file.%a // CHECK:STDOUT: %tuple.elem0.loc12: ref %i32 = tuple_access %a.ref, element0 // CHECK:STDOUT: %.loc12_19.1: %i32 = bind_value %tuple.elem0.loc12 @@ -108,8 +133,8 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %.loc12_19.8: ref %i32 = array_index file.%b.var, %int_2.loc12 // CHECK:STDOUT: %.loc12_19.9: init %i32 = initialize_from %.loc12_19.7 to %.loc12_19.8 // CHECK:STDOUT: %.loc12_19.10: init %array_type = array_init (%.loc12_19.3, %.loc12_19.6, %.loc12_19.9) to file.%b.var -// CHECK:STDOUT: %.loc12_20: init %array_type = converted %a.ref, %.loc12_19.10 -// CHECK:STDOUT: assign file.%b.var, %.loc12_20 +// CHECK:STDOUT: %.loc12_1: init %array_type = converted %a.ref, %.loc12_19.10 +// CHECK:STDOUT: assign file.%b.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/base.carbon b/toolchain/check/testdata/array/base.carbon index cf4f4d45a26c..48384a449b55 100644 --- a/toolchain/check/testdata/array/base.carbon +++ b/toolchain/check/testdata/array/base.carbon @@ -30,6 +30,9 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template] // CHECK:STDOUT: %array.237: %array_type.0cb = tuple_value (%int_1.5d2) [template] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %array_type.ce7: type = array_type %int_2, f64 [template] // CHECK:STDOUT: %float.6e4: f64 = float_literal 11.100000000000001 [template] @@ -63,11 +66,43 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.0cb = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type.0cb = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.0cb = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type.loc11 [template = constants.%array_type.0cb] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type.loc11: type = array_type %int_1, %i32 [template = constants.%array_type.0cb] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type.0cb = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %array_type.ce7 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %array_type.ce7 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %array_type.ce7 = var b +// CHECK:STDOUT: %.loc12_15: type = splice_block %array_type.loc12 [template = constants.%array_type.ce7] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] +// CHECK:STDOUT: %.loc12_9.1: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc12_9.2: type = converted %float.make_type, %.loc12_9.1 [template = f64] +// CHECK:STDOUT: %array_type.loc12: type = array_type %int_2, f64 [template = constants.%array_type.ce7] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %array_type.ce7 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %array_type.c13 = binding_pattern c +// CHECK:STDOUT: %.loc13_1: %array_type.c13 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %array_type.c13 = var c +// CHECK:STDOUT: %.loc13_14: type = splice_block %array_type.loc13 [template = constants.%array_type.c13] { +// CHECK:STDOUT: %.loc13_10.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5] +// CHECK:STDOUT: %.loc13_10.2: type = converted %.loc13_10.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %array_type.loc13: type = array_type %int_5, %empty_tuple.type [template = constants.%array_type.c13] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %array_type.c13 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -84,8 +119,8 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc11_22.3: ref %i32 = array_index file.%a.var, %int_0.loc11 // CHECK:STDOUT: %.loc11_22.4: init %i32 = initialize_from %.loc11_22.2 to %.loc11_22.3 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc11_22.5: init %array_type.0cb = array_init (%.loc11_22.4) to file.%a.var [template = constants.%array.237] -// CHECK:STDOUT: %.loc11_23: init %array_type.0cb = converted %.loc11_22.1, %.loc11_22.5 [template = constants.%array.237] -// CHECK:STDOUT: assign file.%a.var, %.loc11_23 +// CHECK:STDOUT: %.loc11_1: init %array_type.0cb = converted %.loc11_22.1, %.loc11_22.5 [template = constants.%array.237] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %float.loc12_20: f64 = float_literal 11.100000000000001 [template = constants.%float.6e4] // CHECK:STDOUT: %float.loc12_26: f64 = float_literal 2.2000000000000002 [template = constants.%float.9f7] // CHECK:STDOUT: %.loc12_30.1: %tuple.type.bdb = tuple_literal (%float.loc12_20, %float.loc12_26) @@ -96,8 +131,8 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc12_30.4: ref f64 = array_index file.%b.var, %int_1.loc12 // CHECK:STDOUT: %.loc12_30.5: init f64 = initialize_from %float.loc12_26 to %.loc12_30.4 [template = constants.%float.9f7] // CHECK:STDOUT: %.loc12_30.6: init %array_type.ce7 = array_init (%.loc12_30.3, %.loc12_30.5) to file.%b.var [template = constants.%array.6a2] -// CHECK:STDOUT: %.loc12_31: init %array_type.ce7 = converted %.loc12_30.1, %.loc12_30.6 [template = constants.%array.6a2] -// CHECK:STDOUT: assign file.%b.var, %.loc12_31 +// CHECK:STDOUT: %.loc12_1: init %array_type.ce7 = converted %.loc12_30.1, %.loc12_30.6 [template = constants.%array.6a2] +// CHECK:STDOUT: assign file.%b.var, %.loc12_1 // CHECK:STDOUT: %.loc13_20.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc13_24.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc13_28.1: %empty_tuple.type = tuple_literal () @@ -125,8 +160,8 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc13_36.2: init %empty_tuple.type = tuple_init () to %.loc13_38.10 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc13_38.11: init %empty_tuple.type = converted %.loc13_36.1, %.loc13_36.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc13_38.12: init %array_type.c13 = array_init (%.loc13_38.3, %.loc13_38.5, %.loc13_38.7, %.loc13_38.9, %.loc13_38.11) to file.%c.var [template = constants.%array.1cb] -// CHECK:STDOUT: %.loc13_39: init %array_type.c13 = converted %.loc13_38.1, %.loc13_38.12 [template = constants.%array.1cb] -// CHECK:STDOUT: assign file.%c.var, %.loc13_39 +// CHECK:STDOUT: %.loc13_1: init %array_type.c13 = converted %.loc13_38.1, %.loc13_38.12 [template = constants.%array.1cb] +// CHECK:STDOUT: assign file.%c.var, %.loc13_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/canonicalize_index.carbon b/toolchain/check/testdata/array/canonicalize_index.carbon index 1edebc6a88bd..03a5b9223a07 100644 --- a/toolchain/check/testdata/array/canonicalize_index.carbon +++ b/toolchain/check/testdata/array/canonicalize_index.carbon @@ -28,6 +28,7 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template] // CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] @@ -38,6 +39,11 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: %Convert.specific_fn.787: = specific_function %Convert.bound.ef9, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template] // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template] +// CHECK:STDOUT: %impl_witness.023: = impl_witness (imports.%import_ref.85c), @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.2d6: = bound_method %int_3.822, %Convert.960 [template] +// CHECK:STDOUT: %Convert.specific_fn.377: = specific_function %Convert.bound.2d6, @Convert.3(%int_32) [template] // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [template] // CHECK:STDOUT: %ptr: type = ptr_type %array_type [template] @@ -46,6 +52,12 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: %Convert.bound.b30: = bound_method %int_3.1ba, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn.b42: = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template] // CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [template] +// CHECK:STDOUT: %int_3.d14: %u32 = int_value 3 [template] +// CHECK:STDOUT: %impl_witness.8da2: = impl_witness (imports.%import_ref.823), @impl.45(%int_32) [template] +// CHECK:STDOUT: %Convert.type.e06: type = fn_type @Convert.9, @impl.45(%int_32) [template] +// CHECK:STDOUT: %Convert.47f: %Convert.type.e06 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.258: = bound_method %int_3.d14, %Convert.47f [template] +// CHECK:STDOUT: %Convert.specific_fn.d14: = specific_function %Convert.bound.258, @Convert.9(%int_32) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -64,8 +76,8 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: .Add = %Add.decl // CHECK:STDOUT: .ConvertToU32 = %ConvertToU32.decl // CHECK:STDOUT: .a = %a -// CHECK:STDOUT: .b = @__global_init.%b -// CHECK:STDOUT: .c = @__global_init.%c +// CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Add.decl: %Add.type.b1f = fn_decl @Add.1 [template = constants.%Add] { @@ -110,8 +122,79 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: %return.param: ref %u32 = out_param runtime_param1 // CHECK:STDOUT: %return: ref %u32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc14_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc14_23: type = splice_block %array_type.loc14 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %Add.ref: %Add.type.b1f = name_ref Add, %Add.decl [template = constants.%Add] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %impl.elem0.loc14_18: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc14_18: = bound_method %int_1, %impl.elem0.loc14_18 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc14_18: = specific_function %Convert.bound.loc14_18, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc14_18: init %i32 = call %Convert.specific_fn.loc14_18(%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_18.1: %i32 = value_of_initializer %int.convert_checked.loc14_18 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_18.2: %i32 = converted %int_1, %.loc14_18.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc14_21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc14_21: = bound_method %int_2, %impl.elem0.loc14_21 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc14_21: = specific_function %Convert.bound.loc14_21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc14_21: init %i32 = call %Convert.specific_fn.loc14_21(%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_21.1: %i32 = value_of_initializer %int.convert_checked.loc14_21 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc14_21.2: %i32 = converted %int_2, %.loc14_21.1 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc14_18.2, %.loc14_21.2) [template = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc14_22: %Convert.type.71e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960] +// CHECK:STDOUT: %Convert.bound.loc14_22: = bound_method %int.sadd, %impl.elem0.loc14_22 [template = constants.%Convert.bound.2d6] +// CHECK:STDOUT: %Convert.specific_fn.loc14_22: = specific_function %Convert.bound.loc14_22, @Convert.3(constants.%int_32) [template = constants.%Convert.specific_fn.377] +// CHECK:STDOUT: %.loc14_22.1: %i32 = value_of_initializer %int.sadd [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_22.2: %i32 = converted %int.sadd, %.loc14_22.1 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc14_22: init Core.IntLiteral = call %Convert.specific_fn.loc14_22(%.loc14_22.2) [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc14_22.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc14_22 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc14_22.4: Core.IntLiteral = converted %int.sadd, %.loc14_22.3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc14: type = array_type %.loc14_22.4, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %ptr = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15: type = splice_block %ptr.loc15 [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc15: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc15: type = array_type %int_3.loc15, %i32 [template = constants.%array_type] +// CHECK:STDOUT: %ptr.loc15: type = ptr_type %array_type [template = constants.%ptr] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: %ptr = bind_name b, @__global_init.%addr.loc15 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %ptr = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16_30: type = splice_block %ptr.loc16 [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ConvertToU32.ref: %ConvertToU32.type = name_ref ConvertToU32, %ConvertToU32.decl [template = constants.%ConvertToU32] +// CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %impl.elem0.loc16_27: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc16_27: = bound_method %int_3.loc16, %impl.elem0.loc16_27 [template = constants.%Convert.bound.b30] +// CHECK:STDOUT: %Convert.specific_fn.loc16_27: = specific_function %Convert.bound.loc16_27, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] +// CHECK:STDOUT: %int.convert_checked.loc16_27: init %i32 = call %Convert.specific_fn.loc16_27(%int_3.loc16) [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc16_27.1: %i32 = value_of_initializer %int.convert_checked.loc16_27 [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc16_27.2: %i32 = converted %int_3.loc16, %.loc16_27.1 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc16_28.1: init %u32 = call %ConvertToU32.ref(%.loc16_27.2) [template = constants.%int_3.d14] +// CHECK:STDOUT: %impl.elem0.loc16_28: %Convert.type.71e = impl_witness_access constants.%impl_witness.8da2, element0 [template = constants.%Convert.47f] +// CHECK:STDOUT: %Convert.bound.loc16_28: = bound_method %int.convert_checked.loc16_28.1, %impl.elem0.loc16_28 [template = constants.%Convert.bound.258] +// CHECK:STDOUT: %Convert.specific_fn.loc16_28: = specific_function %Convert.bound.loc16_28, @Convert.9(constants.%int_32) [template = constants.%Convert.specific_fn.d14] +// CHECK:STDOUT: %.loc16_28.1: %u32 = value_of_initializer %int.convert_checked.loc16_28.1 [template = constants.%int_3.d14] +// CHECK:STDOUT: %.loc16_28.2: %u32 = converted %int.convert_checked.loc16_28.1, %.loc16_28.1 [template = constants.%int_3.d14] +// CHECK:STDOUT: %int.convert_checked.loc16_28.2: init Core.IntLiteral = call %Convert.specific_fn.loc16_28(%.loc16_28.2) [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc16_28.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc16_28.2 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc16_28.4: Core.IntLiteral = converted %int.convert_checked.loc16_28.1, %.loc16_28.3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc16: type = array_type %.loc16_28.4, %i32 [template = constants.%array_type] +// CHECK:STDOUT: %ptr.loc16: type = ptr_type %array_type [template = constants.%ptr] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c: %ptr = bind_name c, @__global_init.%addr.loc16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Add.1(%a.param_patt: %i32, %b.param_patt: %i32) -> %i32 = "int.sadd"; @@ -149,14 +232,12 @@ let c: [i32; ConvertToU32(3)]* = &a; // CHECK:STDOUT: %.loc14_35.9: ref %i32 = array_index file.%a.var, %int_2.loc14_35 // CHECK:STDOUT: %.loc14_35.10: init %i32 = initialize_from %.loc14_35.8 to %.loc14_35.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc14_35.11: init %array_type = array_init (%.loc14_35.4, %.loc14_35.7, %.loc14_35.10) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc14_36: init %array_type = converted %.loc14_35.1, %.loc14_35.11 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc14_36 +// CHECK:STDOUT: %.loc14_1: init %array_type = converted %.loc14_35.1, %.loc14_35.11 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc14_1 // CHECK:STDOUT: %a.ref.loc15: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %addr.loc15: %ptr = addr_of %a.ref.loc15 -// CHECK:STDOUT: %b: %ptr = bind_name b, %addr.loc15 // CHECK:STDOUT: %a.ref.loc16: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %addr.loc16: %ptr = addr_of %a.ref.loc16 -// CHECK:STDOUT: %c: %ptr = bind_name c, %addr.loc16 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/fail_bound_negative.carbon b/toolchain/check/testdata/array/fail_bound_negative.carbon index bda5d622557b..3bc28089c175 100644 --- a/toolchain/check/testdata/array/fail_bound_negative.carbon +++ b/toolchain/check/testdata/array/fail_bound_negative.carbon @@ -23,6 +23,22 @@ var a: [i32; Negate(1)]; // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %Negate.type.15b: type = fn_type @Negate.1 [template] // CHECK:STDOUT: %Negate: %Negate.type.15b = struct_value () [template] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template] +// CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.ab5: = bound_method %int_1.5b8, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.70c: = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template] +// CHECK:STDOUT: %int_-1.251: %i32 = int_value -1 [template] +// CHECK:STDOUT: %impl_witness.023: = impl_witness (imports.%import_ref.85c), @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.75d: = bound_method %int_-1.251, %Convert.960 [template] +// CHECK:STDOUT: %Convert.specific_fn.4af: = specific_function %Convert.bound.75d, @Convert.3(%int_32) [template] +// CHECK:STDOUT: %int_-1.638: Core.IntLiteral = int_value -1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -58,8 +74,34 @@ var a: [i32; Negate(1)]; // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc17_1: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.loc17_23: type = splice_block %array_type [template = ] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %Negate.ref: %Negate.type.15b = name_ref Negate, %Negate.decl [template = constants.%Negate] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %impl.elem0.loc17_21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc17_21: = bound_method %int_1, %impl.elem0.loc17_21 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc17_21: = specific_function %Convert.bound.loc17_21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc17_21: init %i32 = call %Convert.specific_fn.loc17_21(%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc17_21.1: %i32 = value_of_initializer %int.convert_checked.loc17_21 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc17_21.2: %i32 = converted %int_1, %.loc17_21.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %int.snegate: init %i32 = call %Negate.ref(%.loc17_21.2) [template = constants.%int_-1.251] +// CHECK:STDOUT: %impl.elem0.loc17_22: %Convert.type.71e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960] +// CHECK:STDOUT: %Convert.bound.loc17_22: = bound_method %int.snegate, %impl.elem0.loc17_22 [template = constants.%Convert.bound.75d] +// CHECK:STDOUT: %Convert.specific_fn.loc17_22: = specific_function %Convert.bound.loc17_22, @Convert.3(constants.%int_32) [template = constants.%Convert.specific_fn.4af] +// CHECK:STDOUT: %.loc17_22.1: %i32 = value_of_initializer %int.snegate [template = constants.%int_-1.251] +// CHECK:STDOUT: %.loc17_22.2: %i32 = converted %int.snegate, %.loc17_22.1 [template = constants.%int_-1.251] +// CHECK:STDOUT: %int.convert_checked.loc17_22: init Core.IntLiteral = call %Convert.specific_fn.loc17_22(%.loc17_22.2) [template = constants.%int_-1.638] +// CHECK:STDOUT: %.loc17_22.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc17_22 [template = constants.%int_-1.638] +// CHECK:STDOUT: %.loc17_22.4: Core.IntLiteral = converted %int.snegate, %.loc17_22.3 [template = constants.%int_-1.638] +// CHECK:STDOUT: %array_type: type = array_type %.loc17_22.4, %i32 [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Negate.1(%n.param_patt: %i32) -> %i32 = "int.snegate"; diff --git a/toolchain/check/testdata/array/fail_bound_overflow.carbon b/toolchain/check/testdata/array/fail_bound_overflow.carbon index 3e9f005761b9..f0383fd0f9c5 100644 --- a/toolchain/check/testdata/array/fail_bound_overflow.carbon +++ b/toolchain/check/testdata/array/fail_bound_overflow.carbon @@ -26,6 +26,10 @@ var b: [1; 39999999999999999993]; // CHECK:STDOUT: --- fail_bound_overflow.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %int_39999999999999999993: Core.IntLiteral = int_value 39999999999999999993 [template] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -44,9 +48,29 @@ var b: [1; 39999999999999999993]; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc15_1: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.loc15_34: type = splice_block %array_type.loc15 [template = ] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_39999999999999999993.loc15: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993] +// CHECK:STDOUT: %array_type.loc15: type = array_type %int_39999999999999999993.loc15, %i32 [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: = binding_pattern b +// CHECK:STDOUT: %.loc24_1: = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref = var b -// CHECK:STDOUT: %b: ref = bind_name b, %b.var +// CHECK:STDOUT: %.loc24_32: type = splice_block %array_type.loc24 [template = ] { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %int_39999999999999999993.loc24: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993] +// CHECK:STDOUT: %.loc24_9: type = converted %int_1, [template = ] +// CHECK:STDOUT: %array_type.loc24: type = array_type %int_39999999999999999993.loc24, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: = bind_name b, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/fail_incomplete_element.carbon b/toolchain/check/testdata/array/fail_incomplete_element.carbon index 27f8af3a94d7..53cf0c15c6a8 100644 --- a/toolchain/check/testdata/array/fail_incomplete_element.carbon +++ b/toolchain/check/testdata/array/fail_incomplete_element.carbon @@ -25,6 +25,8 @@ var p: Incomplete* = &a[0]; // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete [template] // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [template] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: } @@ -45,9 +47,26 @@ var p: Incomplete* = &a[0]; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc20_1: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.loc20_22: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr = binding_pattern p +// CHECK:STDOUT: %.loc22_1: %ptr = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr = var p +// CHECK:STDOUT: %.loc22_18: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %Incomplete.ref.loc22: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] +// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -55,7 +74,7 @@ var p: Incomplete* = &a[0]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: ref = name_ref a, file.%a +// CHECK:STDOUT: %a.ref: = name_ref a, file.%a // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: %addr: = addr_of [template = ] // CHECK:STDOUT: assign file.%p.var, diff --git a/toolchain/check/testdata/array/fail_invalid_type.carbon b/toolchain/check/testdata/array/fail_invalid_type.carbon index 78c21511539d..04c03c4d3383 100644 --- a/toolchain/check/testdata/array/fail_invalid_type.carbon +++ b/toolchain/check/testdata/array/fail_invalid_type.carbon @@ -20,6 +20,7 @@ var a: [1; 1]; // CHECK:STDOUT: --- fail_invalid_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -36,7 +37,17 @@ var a: [1; 1]; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc18_1: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.loc18_13: type = splice_block %array_type [template = ] { +// CHECK:STDOUT: %int_1.loc18_9: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %int_1.loc18_12: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %.loc18_9: type = converted %int_1.loc18_9, [template = ] +// CHECK:STDOUT: %array_type: type = array_type %int_1.loc18_12, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/fail_out_of_bound.carbon b/toolchain/check/testdata/array/fail_out_of_bound.carbon index 955407191a07..87d051af2671 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound.carbon @@ -40,7 +40,17 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc15_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc15_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon index fc3d0c7fda31..986b95df8215 100644 --- a/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon +++ b/toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon @@ -60,9 +60,27 @@ var b: i32 = a[{.index = 3}.index]; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -97,8 +115,8 @@ var b: i32 = a[{.index = 3}.index]; // CHECK:STDOUT: %.loc11_27.9: ref %i32 = array_index file.%a.var, %int_2.loc11_27 // CHECK:STDOUT: %.loc11_27.10: init %i32 = initialize_from %.loc11_27.8 to %.loc11_27.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc11_27.11: init %array_type = array_init (%.loc11_27.4, %.loc11_27.7, %.loc11_27.10) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_28: init %array_type = converted %.loc11_27.1, %.loc11_27.11 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_27.1, %.loc11_27.11 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %.loc16_27.1: %struct_type.index = struct_literal (%int_3.loc16) diff --git a/toolchain/check/testdata/array/fail_type_mismatch.carbon b/toolchain/check/testdata/array/fail_type_mismatch.carbon index 2301e6be2ae5..aedc64a23f0f 100644 --- a/toolchain/check/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/array/fail_type_mismatch.carbon @@ -59,9 +59,11 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %Convert.bound: = bound_method %int_1.5b8, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template] +// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [template] // CHECK:STDOUT: %tuple.type.9e7: type = tuple_type (%i32, String, String) [template] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -85,17 +87,79 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc18_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc18_15: type = splice_block %array_type.loc18 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc18: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type.loc18: type = array_type %int_3.loc18, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t1.patt: %tuple.type.9e7 = binding_pattern t1 +// CHECK:STDOUT: %.loc20_1: %tuple.type.9e7 = var_pattern %t1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t1.var: ref %tuple.type.9e7 = var t1 +// CHECK:STDOUT: %.loc20_29.1: type = splice_block %.loc20_29.3 [template = constants.%tuple.type.9e7] { +// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc20_29.2: %tuple.type.ff9 = tuple_literal (%i32.loc20, String, String) +// CHECK:STDOUT: %.loc20_29.3: type = converted %.loc20_29.2, constants.%tuple.type.9e7 [template = constants.%tuple.type.9e7] +// CHECK:STDOUT: } // CHECK:STDOUT: %t1: ref %tuple.type.9e7 = bind_name t1, %t1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %array_type = binding_pattern b +// CHECK:STDOUT: %.loc28_1: %array_type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %array_type = var b +// CHECK:STDOUT: %.loc28_15: type = splice_block %array_type.loc28 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc28: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc28: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc28: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type.loc28: type = array_type %int_3.loc28, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %array_type = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %array_type = binding_pattern c +// CHECK:STDOUT: %.loc34_1: %array_type = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %array_type = var c +// CHECK:STDOUT: %.loc34_15: type = splice_block %array_type.loc34 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc34: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc34: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc34: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type.loc34: type = array_type %int_3.loc34, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %array_type = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t2.patt: %tuple.type.d07 = binding_pattern t2 +// CHECK:STDOUT: %.loc36_1: %tuple.type.d07 = var_pattern %t2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t2.var: ref %tuple.type.d07 = var t2 +// CHECK:STDOUT: %.loc36_18.1: type = splice_block %.loc36_18.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc36_10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc36_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc36_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc36_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc36_18.2: %tuple.type.24b = tuple_literal (%i32.loc36_10, %i32.loc36_15) +// CHECK:STDOUT: %.loc36_18.3: type = converted %.loc36_18.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %t2: ref %tuple.type.d07 = bind_name t2, %t2.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %array_type = binding_pattern d +// CHECK:STDOUT: %.loc41_1: %array_type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %array_type = var d +// CHECK:STDOUT: %.loc41_15: type = splice_block %array_type.loc41 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc41: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc41: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc41: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type.loc41: type = array_type %int_3.loc41, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %array_type = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/array/generic_empty.carbon b/toolchain/check/testdata/array/generic_empty.carbon index b834d1567718..548554ce16fa 100644 --- a/toolchain/check/testdata/array/generic_empty.carbon +++ b/toolchain/check/testdata/array/generic_empty.carbon @@ -54,18 +54,27 @@ fn G(T:! type) { // CHECK:STDOUT: %T.patt.loc11_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %array_type: type = array_type constants.%int_0, @G.%T.loc11_6.2 (%T) [symbolic = %array_type (constants.%array_type)] -// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type (%array_type) [symbolic = %require_complete (constants.%require_complete)] -// CHECK:STDOUT: %array: @G.%array_type (%array_type) = tuple_value () [symbolic = %array (constants.%array)] +// CHECK:STDOUT: %array_type.loc13_17.2: type = array_type constants.%int_0, @G.%T.loc11_6.2 (%T) [symbolic = %array_type.loc13_17.2 (constants.%array_type)] +// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc13_17.2 (%array_type) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: %array: @G.%array_type.loc13_17.2 (%array_type) = tuple_value () [symbolic = %array (constants.%array)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %arr.var: ref @G.%array_type (%array_type) = var arr -// CHECK:STDOUT: %arr: ref @G.%array_type (%array_type) = bind_name arr, %arr.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %arr.patt: @G.%array_type.loc13_17.2 (%array_type) = binding_pattern arr +// CHECK:STDOUT: %.loc13_3.1: @G.%array_type.loc13_17.2 (%array_type) = var_pattern %arr.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc13_17.2 (%array_type) = var arr // CHECK:STDOUT: %.loc13_22.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_22.2: init @G.%array_type (%array_type) = array_init () to %arr.var [symbolic = %array (constants.%array)] -// CHECK:STDOUT: %.loc13_23: init @G.%array_type (%array_type) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)] -// CHECK:STDOUT: assign %arr.var, %.loc13_23 +// CHECK:STDOUT: %.loc13_22.2: init @G.%array_type.loc13_17.2 (%array_type) = array_init () to %arr.var [symbolic = %array (constants.%array)] +// CHECK:STDOUT: %.loc13_3.2: init @G.%array_type.loc13_17.2 (%array_type) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %array (constants.%array)] +// CHECK:STDOUT: assign %arr.var, %.loc13_3.2 +// CHECK:STDOUT: %.loc13_17: type = splice_block %array_type.loc13_17.1 [symbolic = %array_type.loc13_17.2 (constants.%array_type)] { +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)] +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] +// CHECK:STDOUT: %array_type.loc13_17.1: type = array_type %int_0, %T [symbolic = %array_type.loc13_17.2 (constants.%array_type)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %arr: ref @G.%array_type.loc13_17.2 (%array_type) = bind_name arr, %arr.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/index_not_literal.carbon b/toolchain/check/testdata/array/index_not_literal.carbon index a732e9804444..4abdeb61c058 100644 --- a/toolchain/check/testdata/array/index_not_literal.carbon +++ b/toolchain/check/testdata/array/index_not_literal.carbon @@ -56,9 +56,27 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc12_8: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -93,8 +111,8 @@ var b: i32 = a[{.index = 2}.index]; // CHECK:STDOUT: %.loc11_27.9: ref %i32 = array_index file.%a.var, %int_2.loc11_27 // CHECK:STDOUT: %.loc11_27.10: init %i32 = initialize_from %.loc11_27.8 to %.loc11_27.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc11_27.11: init %array_type = array_init (%.loc11_27.4, %.loc11_27.7, %.loc11_27.10) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_28: init %array_type = converted %.loc11_27.1, %.loc11_27.11 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_27.1, %.loc11_27.11 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc12_27.1: %struct_type.index = struct_literal (%int_2.loc12) diff --git a/toolchain/check/testdata/array/init_dependent_bound.carbon b/toolchain/check/testdata/array/init_dependent_bound.carbon index e1591a5b7483..d420d657b585 100644 --- a/toolchain/check/testdata/array/init_dependent_bound.carbon +++ b/toolchain/check/testdata/array/init_dependent_bound.carbon @@ -44,6 +44,8 @@ fn H() { G(3); } // CHECK:STDOUT: %N.patt.8e2: %i32 = symbolic_binding_pattern N, 0 [symbolic] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template] +// CHECK:STDOUT: %impl_witness.023: = impl_witness (imports.%import_ref.85c), @impl.2(%int_32) [template] // CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.2(%int_32) [template] // CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template] // CHECK:STDOUT: %Convert.bound: = bound_method %N.51e, %Convert.960 [symbolic] @@ -77,9 +79,9 @@ fn H() { G(3); } // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc4_6.1, runtime_param [symbolic = %N.patt.loc4_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: } { // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param -// CHECK:STDOUT: %.loc4: type = splice_block %i32 [template = constants.%i32] { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc4: type = splice_block %i32.loc4 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc4_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc4_6.2 (constants.%N.51e)] // CHECK:STDOUT: } @@ -90,21 +92,37 @@ fn H() { G(3); } // CHECK:STDOUT: %N.patt.loc4_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc4_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Convert.bound: = bound_method %N.loc4_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)] -// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.loc4_6.2) [symbolic = %int.convert_checked (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type: type = array_type %int.convert_checked, %i32 [symbolic = %array_type (constants.%array_type)] -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type (%array_type) [symbolic = %require_complete (constants.%require_complete.9dc)] +// CHECK:STDOUT: %Convert.bound.loc9_18.2: = bound_method %N.loc4_6.2, constants.%Convert.960 [symbolic = %Convert.bound.loc9_18.2 (constants.%Convert.bound)] +// CHECK:STDOUT: %Convert.specific_fn.loc9_18.2: = specific_function %Convert.bound.loc9_18.2, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc9_18.2 (constants.%Convert.specific_fn)] +// CHECK:STDOUT: %int.convert_checked.loc9_18.2: init Core.IntLiteral = call %Convert.specific_fn.loc9_18.2(%N.loc4_6.2) [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc9_19.2: type = array_type %int.convert_checked.loc9_18.2, %i32 [symbolic = %array_type.loc9_19.2 (constants.%array_type)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%array_type.loc9_19.2 (%array_type) [symbolic = %require_complete (constants.%require_complete.9dc)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%N.param_patt: %i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %arr.var: ref @F.%array_type (%array_type) = var arr -// CHECK:STDOUT: %arr: ref @F.%array_type (%array_type) = bind_name arr, %arr.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %arr.patt: @F.%array_type.loc9_19.2 (%array_type) = binding_pattern arr +// CHECK:STDOUT: %.loc9_3: @F.%array_type.loc9_19.2 (%array_type) = var_pattern %arr.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %arr.var: ref @F.%array_type.loc9_19.2 (%array_type) = var arr // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] -// CHECK:STDOUT: %.loc9: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) +// CHECK:STDOUT: %.loc9_31: %tuple.type = tuple_literal (%int_1, %int_2, %int_3) // CHECK:STDOUT: assign %arr.var, +// CHECK:STDOUT: %.loc9_19: type = splice_block %array_type.loc9_19.1 [symbolic = %array_type.loc9_19.2 (constants.%array_type)] { +// CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc4_6.1 [symbolic = %N.loc4_6.2 (constants.%N.51e)] +// CHECK:STDOUT: %impl.elem0: %Convert.type.71e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960] +// CHECK:STDOUT: %Convert.bound.loc9_18.1: = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound.loc9_18.2 (constants.%Convert.bound)] +// CHECK:STDOUT: %Convert.specific_fn.loc9_18.1: = specific_function %Convert.bound.loc9_18.1, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc9_18.2 (constants.%Convert.specific_fn)] +// CHECK:STDOUT: %int.convert_checked.loc9_18.1: init Core.IntLiteral = call %Convert.specific_fn.loc9_18.1(%N.ref) [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc9_18.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc9_18.1 [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc9_18.2: Core.IntLiteral = converted %N.ref, %.loc9_18.1 [symbolic = %int.convert_checked.loc9_18.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc9_19.1: type = array_type %.loc9_18.2, %i32 [symbolic = %array_type.loc9_19.2 (constants.%array_type)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %arr: ref @F.%array_type.loc9_19.2 (%array_type) = bind_name arr, %arr.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/nine_elements.carbon b/toolchain/check/testdata/array/nine_elements.carbon index 7c13d39cd2fc..2b08eef74342 100644 --- a/toolchain/check/testdata/array/nine_elements.carbon +++ b/toolchain/check/testdata/array/nine_elements.carbon @@ -76,7 +76,17 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [template = constants.%int_9.988] +// CHECK:STDOUT: %array_type: type = array_type %int_9, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -165,8 +175,8 @@ var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9); // CHECK:STDOUT: %.loc11_45.27: ref %i32 = array_index file.%a.var, %int_8.loc11_45 // CHECK:STDOUT: %.loc11_45.28: init %i32 = initialize_from %.loc11_45.26 to %.loc11_45.27 [template = constants.%int_9.f88] // CHECK:STDOUT: %.loc11_45.29: init %array_type = array_init (%.loc11_45.4, %.loc11_45.7, %.loc11_45.10, %.loc11_45.13, %.loc11_45.16, %.loc11_45.19, %.loc11_45.22, %.loc11_45.25, %.loc11_45.28) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_46: init %array_type = converted %.loc11_45.1, %.loc11_45.29 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_46 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_45.1, %.loc11_45.29 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/adapter_conversion.carbon b/toolchain/check/testdata/as/adapter_conversion.carbon index 7009182c6e07..3f58e56ae5f7 100644 --- a/toolchain/check/testdata/as/adapter_conversion.carbon +++ b/toolchain/check/testdata/as/adapter_conversion.carbon @@ -131,7 +131,7 @@ fn F(a: A) { // CHECK:STDERR: fail_init_tuple_variable.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType] // CHECK:STDERR: var a_init: A = (a as (i32, Noncopyable)) as A; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_init_tuple_variable.carbon:[[@LINE+4]]:19: note: in copy of `A` [InCopy] // CHECK:STDERR: var a_init: A = (a as (i32, Noncopyable)) as A; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -207,23 +207,59 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .a_ref = %a_ref -// CHECK:STDOUT: .a_val = @__global_init.%a_val -// CHECK:STDOUT: .b_val = @__global_init.%b_val -// CHECK:STDOUT: .b_ptr = @__global_init.%b_ptr +// CHECK:STDOUT: .a_val = %a_val +// CHECK:STDOUT: .b_val = %b_val +// CHECK:STDOUT: .b_ptr = %b_ptr // CHECK:STDOUT: .b_factory = %b_factory // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: %A = binding_pattern a_ref +// CHECK:STDOUT: %.loc17: %A = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref %A = var a_ref +// CHECK:STDOUT: %A.ref.loc17: type = name_ref A, %A.decl [template = constants.%A] // CHECK:STDOUT: %a_ref: ref %A = bind_name a_ref, %a_ref.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_val.patt: %A = binding_pattern a_val +// CHECK:STDOUT: } +// CHECK:STDOUT: %A.ref.loc18: type = name_ref A, %A.decl [template = constants.%A] +// CHECK:STDOUT: %a_val: ref %A = bind_name a_val, @__global_init.%a_ref.ref.loc18 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_val.patt: %B = binding_pattern b_val +// CHECK:STDOUT: } +// CHECK:STDOUT: %B.ref.loc21: type = name_ref B, %B.decl [template = constants.%B] +// CHECK:STDOUT: %b_val: ref %B = bind_name b_val, @__global_init.%.loc21_22.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_ptr.patt: %ptr.e79 = binding_pattern b_ptr +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc22: type = splice_block %ptr [template = constants.%ptr.e79] { +// CHECK:STDOUT: %B.ref.loc22: type = name_ref B, %B.decl [template = constants.%B] +// CHECK:STDOUT: %ptr: type = ptr_type %B [template = constants.%ptr.e79] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b_ptr: %ptr.e79 = bind_name b_ptr, @__global_init.%addr +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_factory.patt: %B = binding_pattern b_factory +// CHECK:STDOUT: %.loc24: %B = var_pattern %b_factory.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_factory.var: ref %B = var b_factory +// CHECK:STDOUT: %B.ref.loc24: type = name_ref B, %B.decl [template = constants.%B] // CHECK:STDOUT: %b_factory: ref %B = bind_name b_factory, %b_factory.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] -// CHECK:STDOUT: %.loc6: %A.elem = field_decl y, element1 [template] +// CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %A.elem = var +// CHECK:STDOUT: %.loc6_8: %A.elem = field_decl y, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %A.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %A.elem = var // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] { // CHECK:STDOUT: %return.patt: %A = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %A = out_param_pattern %return.patt, runtime_param0 @@ -287,26 +323,22 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %.loc17_31.6: ref %i32 = class_element_access file.%a_ref.var, element1 // CHECK:STDOUT: %.loc17_31.7: init %i32 = initialize_from %.loc17_31.5 to %.loc17_31.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc17_31.8: init %A = class_init (%.loc17_31.4, %.loc17_31.7), file.%a_ref.var [template = constants.%A.val] -// CHECK:STDOUT: %.loc17_32: init %A = converted %.loc17_31.1, %.loc17_31.8 [template = constants.%A.val] -// CHECK:STDOUT: assign file.%a_ref.var, %.loc17_32 +// CHECK:STDOUT: %.loc17_1: init %A = converted %.loc17_31.1, %.loc17_31.8 [template = constants.%A.val] +// CHECK:STDOUT: assign file.%a_ref.var, %.loc17_1 // CHECK:STDOUT: %a_ref.ref.loc18: ref %A = name_ref a_ref, file.%a_ref -// CHECK:STDOUT: %.loc18: %A = bind_value %a_ref.ref.loc18 -// CHECK:STDOUT: %a_val: %A = bind_name a_val, %.loc18 -// CHECK:STDOUT: %a_val.ref: %A = name_ref a_val, %a_val +// CHECK:STDOUT: %a_val.ref: ref %A = name_ref a_val, file.%a_val // CHECK:STDOUT: %B.ref.loc21: type = name_ref B, file.%B.decl [template = constants.%B] -// CHECK:STDOUT: %.loc21_22.1: %B = as_compatible %a_val.ref -// CHECK:STDOUT: %.loc21_22.2: %B = converted %a_val.ref, %.loc21_22.1 -// CHECK:STDOUT: %b_val: %B = bind_name b_val, %.loc21_22.2 +// CHECK:STDOUT: %.loc21_22.1: ref %B = as_compatible %a_val.ref +// CHECK:STDOUT: %.loc21_22.2: ref %B = converted %a_val.ref, %.loc21_22.1 // CHECK:STDOUT: %a_ref.ref.loc22: ref %A = name_ref a_ref, file.%a_ref // CHECK:STDOUT: %B.ref.loc22: type = name_ref B, file.%B.decl [template = constants.%B] // CHECK:STDOUT: %.loc22_25.1: ref %B = as_compatible %a_ref.ref.loc22 // CHECK:STDOUT: %.loc22_25.2: ref %B = converted %a_ref.ref.loc22, %.loc22_25.1 // CHECK:STDOUT: %addr: %ptr.e79 = addr_of %.loc22_25.2 -// CHECK:STDOUT: %b_ptr: %ptr.e79 = bind_name b_ptr, %addr // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, @A.%Make.decl [template = constants.%Make] -// CHECK:STDOUT: %.loc24_5: ref %B = splice_block file.%b_factory.var {} -// CHECK:STDOUT: %Make.call: init %A = call %Make.ref() to %.loc24_5 +// CHECK:STDOUT: %.loc24_1: ref %B = splice_block file.%b_factory.var {} +// CHECK:STDOUT: %Make.call: init %A = call %Make.ref() to %.loc24_1 // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [template = constants.%B] // CHECK:STDOUT: %.loc24_29.1: init %B = as_compatible %Make.call // CHECK:STDOUT: %.loc24_29.2: init %B = converted %Make.call, %.loc24_29.1 @@ -345,11 +377,24 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl -// CHECK:STDOUT: .a = @__global_init.%a -// CHECK:STDOUT: .n = @__global_init.%n +// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A] +// CHECK:STDOUT: %a: %A = bind_name a, @__global_init.%.loc8_23.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: %i32 = bind_name n, @__global_init.%.loc9_16.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { @@ -374,13 +419,11 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %.loc8_23.1: %A = as_compatible %.loc8_15.2 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc8_23.2: %A = converted %.loc8_15.2, %.loc8_23.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %a: %A = bind_name a, %.loc8_23.2 -// CHECK:STDOUT: %a.ref: %A = name_ref a, %a +// CHECK:STDOUT: %a.ref: %A = name_ref a, file.%a // CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %.loc9_16.1: %i32 = as_compatible %a.ref // CHECK:STDOUT: %.loc9_16.2: %i32 = converted %a.ref, %.loc9_16.1 -// CHECK:STDOUT: %n: %i32 = bind_name n, %.loc9_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -410,13 +453,18 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .d = @__global_init.%d +// CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %D = binding_pattern d +// CHECK:STDOUT: } +// CHECK:STDOUT: %D.ref: type = name_ref D, %D.decl [template = constants.%D] +// CHECK:STDOUT: %d: %D = bind_name d, @__global_init.%.loc9_15.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { @@ -455,7 +503,6 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [template = constants.%empty_struct] // CHECK:STDOUT: %.loc9_15.1: %D = as_compatible %empty_struct [template = constants.%empty_struct] // CHECK:STDOUT: %.loc9_15.2: %D = converted %.loc9_13, %.loc9_15.1 [template = constants.%empty_struct] -// CHECK:STDOUT: %d: %D = bind_name d, %.loc9_15.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -499,16 +546,29 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .B = %B.decl -// CHECK:STDOUT: .b_value = @__global_init.%b_value +// CHECK:STDOUT: .b_value = %b_value // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_value.patt: %B = binding_pattern b_value +// CHECK:STDOUT: } +// CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B] +// CHECK:STDOUT: %b_value: ref %B = bind_name b_value, @__global_init.%.loc13_42.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] -// CHECK:STDOUT: %.loc6: %A.elem = field_decl y, element1 [template] +// CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %A.elem = var +// CHECK:STDOUT: %.loc6_8: %A.elem = field_decl y, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %A.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x.y.871 [template = constants.%complete_type.70a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -547,8 +607,6 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] // CHECK:STDOUT: %.loc13_42.1: ref %B = as_compatible %.loc13_36 // CHECK:STDOUT: %.loc13_42.2: ref %B = converted %.loc13_36, %.loc13_42.1 -// CHECK:STDOUT: %.loc13_42.3: %B = bind_value %.loc13_42.2 -// CHECK:STDOUT: %b_value: %B = bind_name b_value, %.loc13_42.3 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -597,13 +655,26 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_init.patt: %B = binding_pattern b_init +// CHECK:STDOUT: %.loc22: %B = var_pattern %b_init.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_init.var: ref %B = var b_init +// CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B] // CHECK:STDOUT: %b_init: ref %B = bind_name b_init, %b_init.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] -// CHECK:STDOUT: %.loc6: %A.elem = field_decl y, element1 [template] +// CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %A.elem = var +// CHECK:STDOUT: %.loc6_8: %A.elem = field_decl y, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %A.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x.y.871 [template = constants.%complete_type.70a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -709,6 +780,9 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %A) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_value.patt: %A = binding_pattern a_value +// CHECK:STDOUT: } // CHECK:STDOUT: %a.ref: %A = name_ref a, %a // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] @@ -717,9 +791,10 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %.loc13_43.2: type = converted %.loc13_43.1, constants.%tuple.type.560 [template = constants.%tuple.type.560] // CHECK:STDOUT: %.loc13_23.1: %tuple.type.560 = as_compatible %a.ref // CHECK:STDOUT: %.loc13_23.2: %tuple.type.560 = converted %a.ref, %.loc13_23.1 -// CHECK:STDOUT: %A.ref.loc13: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %A.ref.loc13_49: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %.loc13_46.1: %A = as_compatible %.loc13_23.2 // CHECK:STDOUT: %.loc13_46.2: %A = converted %.loc13_23.2, %.loc13_46.1 +// CHECK:STDOUT: %A.ref.loc13_16: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %a_value: %A = bind_name a_value, %.loc13_46.2 // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -786,8 +861,11 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %A) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_init.patt: %A = binding_pattern a_init +// CHECK:STDOUT: %.loc25_3.1: %A = var_pattern %a_init.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_init.var: ref %A = var a_init -// CHECK:STDOUT: %a_init: ref %A = bind_name a_init, %a_init.var // CHECK:STDOUT: %a.ref: %A = name_ref a, %a // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] @@ -796,16 +874,18 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %.loc25_42.2: type = converted %.loc25_42.1, constants.%tuple.type.560 [template = constants.%tuple.type.560] // CHECK:STDOUT: %.loc25_22.1: %tuple.type.560 = as_compatible %a.ref // CHECK:STDOUT: %.loc25_22.2: %tuple.type.560 = converted %a.ref, %.loc25_22.1 -// CHECK:STDOUT: %A.ref.loc25: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %A.ref.loc25_48: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %.loc25_45.1: %A = as_compatible %.loc25_22.2 // CHECK:STDOUT: %.loc25_45.2: %A = converted %.loc25_22.2, %.loc25_45.1 -// CHECK:STDOUT: %.loc25_49.1: %tuple.type.560 = as_compatible %.loc25_45.2 -// CHECK:STDOUT: %tuple.elem0.loc25_49.1: %i32 = tuple_access %.loc25_49.1, element0 -// CHECK:STDOUT: %.loc25_49.2: ref %tuple.type.560 = as_compatible %a_init.var -// CHECK:STDOUT: %tuple.elem0.loc25_49.2: ref %i32 = tuple_access %.loc25_49.2, element0 -// CHECK:STDOUT: %.loc25_49.3: init %i32 = initialize_from %tuple.elem0.loc25_49.1 to %tuple.elem0.loc25_49.2 -// CHECK:STDOUT: %tuple.elem1: %Noncopyable = tuple_access %.loc25_49.1, element1 +// CHECK:STDOUT: %.loc25_3.2: %tuple.type.560 = as_compatible %.loc25_45.2 +// CHECK:STDOUT: %tuple.elem0.loc25_3.1: %i32 = tuple_access %.loc25_3.2, element0 +// CHECK:STDOUT: %.loc25_3.3: ref %tuple.type.560 = as_compatible %a_init.var +// CHECK:STDOUT: %tuple.elem0.loc25_3.2: ref %i32 = tuple_access %.loc25_3.3, element0 +// CHECK:STDOUT: %.loc25_3.4: init %i32 = initialize_from %tuple.elem0.loc25_3.1 to %tuple.elem0.loc25_3.2 +// CHECK:STDOUT: %tuple.elem1: %Noncopyable = tuple_access %.loc25_3.2, element1 // CHECK:STDOUT: assign %a_init.var, +// CHECK:STDOUT: %A.ref.loc25_15: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %a_init: ref %A = bind_name a_init, %a_init.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -842,12 +922,21 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %B = binding_pattern b +// CHECK:STDOUT: %.loc22: %B = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %B = var b +// CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B] // CHECK:STDOUT: %b: ref %B = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %A.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x.ed6 [template = constants.%complete_type.1ec] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/as/as_type.carbon b/toolchain/check/testdata/as/as_type.carbon index 30e8d3d0b1bd..3c56d448cb87 100644 --- a/toolchain/check/testdata/as/as_type.carbon +++ b/toolchain/check/testdata/as/as_type.carbon @@ -30,9 +30,13 @@ let t: type = (i32, i32) as type; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .t = @__global_init.%t +// CHECK:STDOUT: .t = %t // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t.patt: type = binding_pattern t +// CHECK:STDOUT: } +// CHECK:STDOUT: %t: type = bind_name t, @__global_init.%.loc11_26 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -43,7 +47,6 @@ let t: type = (i32, i32) as type; // CHECK:STDOUT: %i32.loc11_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %.loc11_24: %tuple.type.24b = tuple_literal (%i32.loc11_16, %i32.loc11_21) // CHECK:STDOUT: %.loc11_26: type = converted %.loc11_24, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] -// CHECK:STDOUT: %t: type = bind_name t, %.loc11_26 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/fail_no_conversion.carbon b/toolchain/check/testdata/as/fail_no_conversion.carbon index e2f666594204..b734787fe673 100644 --- a/toolchain/check/testdata/as/fail_no_conversion.carbon +++ b/toolchain/check/testdata/as/fail_no_conversion.carbon @@ -39,9 +39,22 @@ let n: (i32, i32) = 1 as (i32, i32); // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .n = @__global_init.%n +// CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %tuple.type.d07 = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc18_17.1: type = splice_block %.loc18_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc18_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_17.2: %tuple.type.24b = tuple_literal (%i32.loc18_9, %i32.loc18_14) +// CHECK:STDOUT: %.loc18_17.3: type = converted %.loc18_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %tuple.elem0: %i32 = tuple_access @__global_init.%.loc18_23, element0 [template = ] +// CHECK:STDOUT: %n: %tuple.type.d07 = bind_name n, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -54,8 +67,6 @@ let n: (i32, i32) = 1 as (i32, i32); // CHECK:STDOUT: %.loc18_35.1: %tuple.type.24b = tuple_literal (%i32.loc18_27, %i32.loc18_32) // CHECK:STDOUT: %.loc18_35.2: type = converted %.loc18_35.1, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] // CHECK:STDOUT: %.loc18_23: %tuple.type.d07 = converted %int_1, [template = ] -// CHECK:STDOUT: %tuple.elem0: %i32 = tuple_access %.loc18_23, element0 [template = ] -// CHECK:STDOUT: %n: %tuple.type.d07 = bind_name n, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/fail_not_type.carbon b/toolchain/check/testdata/as/fail_not_type.carbon index b0e509487ebd..53f0d3e14062 100644 --- a/toolchain/check/testdata/as/fail_not_type.carbon +++ b/toolchain/check/testdata/as/fail_not_type.carbon @@ -38,9 +38,17 @@ let n: i32 = 1 as 2; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .n = @__global_init.%n +// CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc18: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: %i32 = bind_name n, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -48,7 +56,6 @@ let n: i32 = 1 as 2; // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] // CHECK:STDOUT: %.loc18: type = converted %int_2, [template = ] -// CHECK:STDOUT: %n: %i32 = bind_name n, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/identity.carbon b/toolchain/check/testdata/as/identity.carbon index 16b65a54a7e5..2e5a00ceae3d 100644 --- a/toolchain/check/testdata/as/identity.carbon +++ b/toolchain/check/testdata/as/identity.carbon @@ -76,9 +76,9 @@ fn Initializing() { // CHECK:STDOUT: %p.param_patt: %ptr.d17 = value_param_pattern %p.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %p.param: %ptr.d17 = value_param runtime_param0 -// CHECK:STDOUT: %.loc21: type = splice_block %ptr [template = constants.%ptr.d17] { +// CHECK:STDOUT: %.loc21: type = splice_block %ptr.loc21 [template = constants.%ptr.d17] { // CHECK:STDOUT: %X.ref.loc21: type = name_ref X, file.%X.decl [template = constants.%X] -// CHECK:STDOUT: %ptr: type = ptr_type %X [template = constants.%ptr.d17] +// CHECK:STDOUT: %ptr.loc21: type = ptr_type %X [template = constants.%ptr.d17] // CHECK:STDOUT: } // CHECK:STDOUT: %p: %ptr.d17 = bind_name p, %p.param // CHECK:STDOUT: } @@ -100,18 +100,29 @@ fn Initializing() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Value(%n.param_patt: %X) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %m.patt: %X = binding_pattern m +// CHECK:STDOUT: } // CHECK:STDOUT: %n.ref: %X = name_ref n, %n -// CHECK:STDOUT: %X.ref.loc18: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %X.ref.loc18_19: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %X.ref.loc18_10: type = name_ref X, file.%X.decl [template = constants.%X] // CHECK:STDOUT: %m: %X = bind_name m, %n.ref // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Reference(%p.param_patt: %ptr.d17) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %q.patt: %ptr.d17 = binding_pattern q +// CHECK:STDOUT: } // CHECK:STDOUT: %p.ref: %ptr.d17 = name_ref p, %p -// CHECK:STDOUT: %.loc22: ref %X = deref %p.ref -// CHECK:STDOUT: %X.ref.loc22: type = name_ref X, file.%X.decl [template = constants.%X] -// CHECK:STDOUT: %addr: %ptr.d17 = addr_of %.loc22 +// CHECK:STDOUT: %.loc22_17: ref %X = deref %p.ref +// CHECK:STDOUT: %X.ref.loc22_23: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %addr: %ptr.d17 = addr_of %.loc22_17 +// CHECK:STDOUT: %.loc22_11: type = splice_block %ptr.loc22 [template = constants.%ptr.d17] { +// CHECK:STDOUT: %X.ref.loc22_10: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %ptr.loc22: type = ptr_type %X [template = constants.%ptr.d17] +// CHECK:STDOUT: } // CHECK:STDOUT: %q: %ptr.d17 = bind_name q, %addr // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -120,13 +131,18 @@ fn Initializing() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Initializing() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %X = binding_pattern x +// CHECK:STDOUT: %.loc28_3.1: %X = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %X = var x -// CHECK:STDOUT: %x: ref %X = bind_name x, %x.var // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, file.%Make.decl [template = constants.%Make] -// CHECK:STDOUT: %.loc28: ref %X = splice_block %x.var {} -// CHECK:STDOUT: %Make.call: init %X = call %Make.ref() to %.loc28 -// CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %.loc28_3.2: ref %X = splice_block %x.var {} +// CHECK:STDOUT: %Make.call: init %X = call %Make.ref() to %.loc28_3.2 +// CHECK:STDOUT: %X.ref.loc28_25: type = name_ref X, file.%X.decl [template = constants.%X] // CHECK:STDOUT: assign %x.var, %Make.call +// CHECK:STDOUT: %X.ref.loc28_10: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %x: ref %X = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/no_prelude/tuple.carbon b/toolchain/check/testdata/as/no_prelude/tuple.carbon index 92e518088b4c..0b762538b336 100644 --- a/toolchain/check/testdata/as/no_prelude/tuple.carbon +++ b/toolchain/check/testdata/as/no_prelude/tuple.carbon @@ -69,31 +69,43 @@ fn Var() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Let() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.b67 = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %Make.ref.loc19_20: %Make.type = name_ref Make, file.%Make.decl [template = constants.%Make] // CHECK:STDOUT: %.loc19_25.1: ref %X = temporary_storage // CHECK:STDOUT: %Make.call.loc19_25: init %X = call %Make.ref.loc19_20() to %.loc19_25.1 // CHECK:STDOUT: %Make.ref.loc19_28: %Make.type = name_ref Make, file.%Make.decl [template = constants.%Make] // CHECK:STDOUT: %.loc19_33.1: ref %X = temporary_storage // CHECK:STDOUT: %Make.call.loc19_33: init %X = call %Make.ref.loc19_28() to %.loc19_33.1 -// CHECK:STDOUT: %.loc19_34: %tuple.type.b67 = tuple_literal (%Make.call.loc19_25, %Make.call.loc19_33) +// CHECK:STDOUT: %.loc19_34.1: %tuple.type.b67 = tuple_literal (%Make.call.loc19_25, %Make.call.loc19_33) // CHECK:STDOUT: %X.ref.loc19_40: type = name_ref X, file.%X.decl [template = constants.%X] // CHECK:STDOUT: %X.ref.loc19_43: type = name_ref X, file.%X.decl [template = constants.%X] // CHECK:STDOUT: %.loc19_44.1: %tuple.type.24b = tuple_literal (%X.ref.loc19_40, %X.ref.loc19_43) // CHECK:STDOUT: %.loc19_44.2: type = converted %.loc19_44.1, constants.%tuple.type.b67 [template = constants.%tuple.type.b67] +// CHECK:STDOUT: %.loc19_15.1: type = splice_block %.loc19_15.3 [template = constants.%tuple.type.b67] { +// CHECK:STDOUT: %X.ref.loc19_11: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %X.ref.loc19_14: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %.loc19_15.2: %tuple.type.24b = tuple_literal (%X.ref.loc19_11, %X.ref.loc19_14) +// CHECK:STDOUT: %.loc19_15.3: type = converted %.loc19_15.2, constants.%tuple.type.b67 [template = constants.%tuple.type.b67] +// CHECK:STDOUT: } // CHECK:STDOUT: %.loc19_25.2: ref %X = temporary %.loc19_25.1, %Make.call.loc19_25 // CHECK:STDOUT: %.loc19_25.3: %X = bind_value %.loc19_25.2 // CHECK:STDOUT: %.loc19_33.2: ref %X = temporary %.loc19_33.1, %Make.call.loc19_33 // CHECK:STDOUT: %.loc19_33.3: %X = bind_value %.loc19_33.2 // CHECK:STDOUT: %tuple: %tuple.type.b67 = tuple_value (%.loc19_25.3, %.loc19_33.3) -// CHECK:STDOUT: %.loc19_45: %tuple.type.b67 = converted %.loc19_34, %tuple -// CHECK:STDOUT: %a: %tuple.type.b67 = bind_name a, %.loc19_45 +// CHECK:STDOUT: %.loc19_34.2: %tuple.type.b67 = converted %.loc19_34.1, %tuple +// CHECK:STDOUT: %a: %tuple.type.b67 = bind_name a, %.loc19_34.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Var() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %tuple.type.b67 = binding_pattern b +// CHECK:STDOUT: %.loc24_3.1: %tuple.type.b67 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %tuple.type.b67 = var b -// CHECK:STDOUT: %b: ref %tuple.type.b67 = bind_name b, %b.var // CHECK:STDOUT: %Make.ref.loc24_20: %Make.type = name_ref Make, file.%Make.decl [template = constants.%Make] // CHECK:STDOUT: %tuple.elem0: ref %X = tuple_access %b.var, element0 // CHECK:STDOUT: %Make.call.loc24_25: init %X = call %Make.ref.loc24_20() to %tuple.elem0 @@ -106,8 +118,15 @@ fn Var() { // CHECK:STDOUT: %.loc24_44.1: %tuple.type.24b = tuple_literal (%X.ref.loc24_40, %X.ref.loc24_43) // CHECK:STDOUT: %.loc24_44.2: type = converted %.loc24_44.1, constants.%tuple.type.b67 [template = constants.%tuple.type.b67] // CHECK:STDOUT: %.loc24_34.2: init %tuple.type.b67 = tuple_init (%Make.call.loc24_25, %Make.call.loc24_33) to %b.var -// CHECK:STDOUT: %.loc24_45: init %tuple.type.b67 = converted %.loc24_34.1, %.loc24_34.2 -// CHECK:STDOUT: assign %b.var, %.loc24_45 +// CHECK:STDOUT: %.loc24_3.2: init %tuple.type.b67 = converted %.loc24_34.1, %.loc24_34.2 +// CHECK:STDOUT: assign %b.var, %.loc24_3.2 +// CHECK:STDOUT: %.loc24_15.1: type = splice_block %.loc24_15.3 [template = constants.%tuple.type.b67] { +// CHECK:STDOUT: %X.ref.loc24_11: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %X.ref.loc24_14: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %.loc24_15.2: %tuple.type.24b = tuple_literal (%X.ref.loc24_11, %X.ref.loc24_14) +// CHECK:STDOUT: %.loc24_15.3: type = converted %.loc24_15.2, constants.%tuple.type.b67 [template = constants.%tuple.type.b67] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %tuple.type.b67 = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/as/overloaded.carbon b/toolchain/check/testdata/as/overloaded.carbon index 132775580a62..955d7bcf781f 100644 --- a/toolchain/check/testdata/as/overloaded.carbon +++ b/toolchain/check/testdata/as/overloaded.carbon @@ -67,7 +67,7 @@ let n: i32 = ((4 as i32) as X) as i32; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .X = %X.decl -// CHECK:STDOUT: .n = @__global_init.%n +// CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {} @@ -89,6 +89,14 @@ let n: i32 = ((4 as i32) as X) as i32; // CHECK:STDOUT: %As.type: type = facet_type <@As, @As(constants.%i32)> [template = constants.%As.type.fd4] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness.loc19: = impl_witness (@impl.2.%Convert.decl) [template = constants.%impl_witness.662] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc23: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: %i32 = bind_name n, @__global_init.%.loc23_32.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.1: %i32 as %As.type { @@ -136,7 +144,11 @@ let n: i32 = ((4 as i32) as X) as i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @X { -// CHECK:STDOUT: %.loc12: %X.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc12_8: %X.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %X.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %X.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -155,7 +167,7 @@ let n: i32 = ((4 as i32) as X) as i32; // CHECK:STDOUT: fn @Convert.3[%self.param_patt: %X]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %X = name_ref self, %self -// CHECK:STDOUT: %n.ref: %X.elem = name_ref n, @X.%.loc12 [template = @X.%.loc12] +// CHECK:STDOUT: %n.ref: %X.elem = name_ref n, @X.%.loc12_8 [template = @X.%.loc12_8] // CHECK:STDOUT: %.loc20_45.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc20_45.2: %i32 = bind_value %.loc20_45.1 // CHECK:STDOUT: return %.loc20_45.2 @@ -187,7 +199,6 @@ let n: i32 = ((4 as i32) as X) as i32; // CHECK:STDOUT: %Convert.call.loc23_32: init %i32 = call %Convert.bound.loc23_32(%.loc23_26.4) // CHECK:STDOUT: %.loc23_32.1: %i32 = value_of_initializer %Convert.call.loc23_32 // CHECK:STDOUT: %.loc23_32.2: %i32 = converted %.loc23_26.2, %.loc23_32.1 -// CHECK:STDOUT: %n: %i32 = bind_name n, %.loc23_32.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/builtin_types.carbon b/toolchain/check/testdata/basics/builtin_types.carbon index 8ac4d02228a9..d70f5031fead 100644 --- a/toolchain/check/testdata/basics/builtin_types.carbon +++ b/toolchain/check/testdata/basics/builtin_types.carbon @@ -26,6 +26,9 @@ var test_type: type = i32; // CHECK:STDOUT: %Convert.bound: = bound_method %int_0.5c6, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %float: f64 = float_literal 0.10000000000000001 [template] // CHECK:STDOUT: %str: String = string_literal "Test" [template] // CHECK:STDOUT: } @@ -45,14 +48,40 @@ var test_type: type = i32; // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .test_i32 = %test_i32 // CHECK:STDOUT: .test_f64 = %test_f64 -// CHECK:STDOUT: .test_str = @__global_init.%test_str +// CHECK:STDOUT: .test_str = %test_str // CHECK:STDOUT: .test_type = %test_type // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_i32.patt: %i32 = binding_pattern test_i32 +// CHECK:STDOUT: %.loc11_1: %i32 = var_pattern %test_i32.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i32.var: ref %i32 = var test_i32 +// CHECK:STDOUT: %.loc11_15: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i32: ref %i32 = bind_name test_i32, %test_i32.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_f64.patt: f64 = binding_pattern test_f64 +// CHECK:STDOUT: %.loc12_1: f64 = var_pattern %test_f64.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_f64.var: ref f64 = var test_f64 +// CHECK:STDOUT: %.loc12_15.1: type = splice_block %.loc12_15.3 [template = f64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc12_15.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc12_15.3: type = converted %float.make_type, %.loc12_15.2 [template = f64] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_f64: ref f64 = bind_name test_f64, %test_f64.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_str.patt: String = binding_pattern test_str +// CHECK:STDOUT: } +// CHECK:STDOUT: %test_str: String = bind_name test_str, @__global_init.%str +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_type.patt: type = binding_pattern test_type +// CHECK:STDOUT: %.loc14: type = var_pattern %test_type.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_type.var: ref type = var test_type // CHECK:STDOUT: %test_type: ref type = bind_name test_type, %test_type.var // CHECK:STDOUT: } @@ -69,7 +98,6 @@ var test_type: type = i32; // CHECK:STDOUT: %float: f64 = float_literal 0.10000000000000001 [template = constants.%float] // CHECK:STDOUT: assign file.%test_f64.var, %float // CHECK:STDOUT: %str: String = string_literal "Test" [template = constants.%str] -// CHECK:STDOUT: %test_str: String = bind_name test_str, %str // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: assign file.%test_type.var, %i32 diff --git a/toolchain/check/testdata/basics/fail_non_type_as_type.carbon b/toolchain/check/testdata/basics/fail_non_type_as_type.carbon index 15b53e1135ad..f8f1a8c6259e 100644 --- a/toolchain/check/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/check/testdata/basics/fail_non_type_as_type.carbon @@ -10,10 +10,10 @@ // CHECK:STDERR: fail_non_type_as_type.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure] // CHECK:STDERR: var x: type = 42; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~ // CHECK:STDERR: fail_non_type_as_type.carbon:[[@LINE+4]]:1: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote] // CHECK:STDERR: var x: type = 42; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~ // CHECK:STDERR: var x: type = 42; @@ -37,6 +37,10 @@ var x: type = 42; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: type = binding_pattern x +// CHECK:STDOUT: %.loc18: type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref type = var x // CHECK:STDOUT: %x: ref type = bind_name x, %x.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon b/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon index 2b3f3cc18377..bcd409aa6cfd 100644 --- a/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon +++ b/toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon @@ -8,21 +8,21 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/fail_numeric_literal_overflow.carbon -// CHECK:STDERR: fail_numeric_literal_overflow.carbon:[[@LINE+4]]:1: error: integer value 39999999999999999993 too large for type `i32` [IntTooLargeForType] +// CHECK:STDERR: fail_numeric_literal_overflow.carbon:[[@LINE+4]]:14: error: integer value 39999999999999999993 too large for type `i32` [IntTooLargeForType] // CHECK:STDERR: let a: i32 = 39999999999999999993; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: let a: i32 = 39999999999999999993; -// CHECK:STDERR: fail_numeric_literal_overflow.carbon:[[@LINE+4]]:1: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType] +// CHECK:STDERR: fail_numeric_literal_overflow.carbon:[[@LINE+4]]:14: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType] // CHECK:STDERR: let b: i32 = 2_147_483_648; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: let b: i32 = 2_147_483_648; -// CHECK:STDERR: fail_numeric_literal_overflow.carbon:[[@LINE+4]]:1: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType] +// CHECK:STDERR: fail_numeric_literal_overflow.carbon:[[@LINE+4]]:14: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType] // CHECK:STDERR: let c: i32 = 0x8000_0000; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~ // CHECK:STDERR: let c: i32 = 0x8000_0000; @@ -55,6 +55,9 @@ let e: f64 = 5.0e39999999999999999993; // CHECK:STDOUT: %Convert.bound.85f: = bound_method %int_2147483648.1db, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn.387: = specific_function %Convert.bound.85f, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_2147483648.8df: %i32 = int_value 2147483648 [template] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -70,43 +73,82 @@ let e: f64 = 5.0e39999999999999999993; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .a = @__global_init.%a -// CHECK:STDOUT: .b = @__global_init.%b -// CHECK:STDOUT: .c = @__global_init.%c -// CHECK:STDOUT: .d = @__global_init.%d -// CHECK:STDOUT: .e = @__global_init.%e +// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .c = %c +// CHECK:STDOUT: .d = %d +// CHECK:STDOUT: .e = %e // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15_8: type = splice_block %i32.loc15 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc15: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc15: = bound_method @__global_init.%int_39999999999999999993, %impl.elem0.loc15 [template = constants.%Convert.bound.7ef] +// CHECK:STDOUT: %Convert.specific_fn.loc15: = specific_function %Convert.bound.loc15, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2ed] +// CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %Convert.specific_fn.loc15(@__global_init.%int_39999999999999999993) [template = constants.%int_39999999999999999993.dee] +// CHECK:STDOUT: %.loc15_14.1: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%int_39999999999999999993.dee] +// CHECK:STDOUT: %.loc15_14.2: %i32 = converted @__global_init.%int_39999999999999999993, %.loc15_14.1 [template = constants.%int_39999999999999999993.dee] +// CHECK:STDOUT: %a: %i32 = bind_name a, %.loc15_14.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_8: type = splice_block %i32.loc21 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc21: = bound_method @__global_init.%int_2147483648.loc21, %impl.elem0.loc21 [template = constants.%Convert.bound.85f] +// CHECK:STDOUT: %Convert.specific_fn.loc21: = specific_function %Convert.bound.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.387] +// CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(@__global_init.%int_2147483648.loc21) [template = constants.%int_2147483648.8df] +// CHECK:STDOUT: %.loc21_14.1: %i32 = value_of_initializer %int.convert_checked.loc21 [template = constants.%int_2147483648.8df] +// CHECK:STDOUT: %.loc21_14.2: %i32 = converted @__global_init.%int_2147483648.loc21, %.loc21_14.1 [template = constants.%int_2147483648.8df] +// CHECK:STDOUT: %b: %i32 = bind_name b, %.loc21_14.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc27_8: type = splice_block %i32.loc27 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc27: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc27: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc27: = bound_method @__global_init.%int_2147483648.loc27, %impl.elem0.loc27 [template = constants.%Convert.bound.85f] +// CHECK:STDOUT: %Convert.specific_fn.loc27: = specific_function %Convert.bound.loc27, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.387] +// CHECK:STDOUT: %int.convert_checked.loc27: init %i32 = call %Convert.specific_fn.loc27(@__global_init.%int_2147483648.loc27) [template = constants.%int_2147483648.8df] +// CHECK:STDOUT: %.loc27_14.1: %i32 = value_of_initializer %int.convert_checked.loc27 [template = constants.%int_2147483648.8df] +// CHECK:STDOUT: %.loc27_14.2: %i32 = converted @__global_init.%int_2147483648.loc27, %.loc27_14.1 [template = constants.%int_2147483648.8df] +// CHECK:STDOUT: %c: %i32 = bind_name c, %.loc27_14.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: f64 = binding_pattern d +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc33_8.1: type = splice_block %.loc33_8.3 [template = f64] { +// CHECK:STDOUT: %int_64.loc33: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc33: init type = call constants.%Float(%int_64.loc33) [template = f64] +// CHECK:STDOUT: %.loc33_8.2: type = value_of_initializer %float.make_type.loc33 [template = f64] +// CHECK:STDOUT: %.loc33_8.3: type = converted %float.make_type.loc33, %.loc33_8.2 [template = f64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d: f64 = bind_name d, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: f64 = binding_pattern e +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc39_8.1: type = splice_block %.loc39_8.3 [template = f64] { +// CHECK:STDOUT: %int_64.loc39: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc39: init type = call constants.%Float(%int_64.loc39) [template = f64] +// CHECK:STDOUT: %.loc39_8.2: type = value_of_initializer %float.make_type.loc39 [template = f64] +// CHECK:STDOUT: %.loc39_8.3: type = converted %float.make_type.loc39, %.loc39_8.2 [template = f64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %e: f64 = bind_name e, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_39999999999999999993: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993.af6] -// CHECK:STDOUT: %impl.elem0.loc15: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc15: = bound_method %int_39999999999999999993, %impl.elem0.loc15 [template = constants.%Convert.bound.7ef] -// CHECK:STDOUT: %Convert.specific_fn.loc15: = specific_function %Convert.bound.loc15, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2ed] -// CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %Convert.specific_fn.loc15(%int_39999999999999999993) [template = constants.%int_39999999999999999993.dee] -// CHECK:STDOUT: %.loc15_34.1: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%int_39999999999999999993.dee] -// CHECK:STDOUT: %.loc15_34.2: %i32 = converted %int_39999999999999999993, %.loc15_34.1 [template = constants.%int_39999999999999999993.dee] -// CHECK:STDOUT: %a: %i32 = bind_name a, %.loc15_34.2 // CHECK:STDOUT: %int_2147483648.loc21: Core.IntLiteral = int_value 2147483648 [template = constants.%int_2147483648.1db] -// CHECK:STDOUT: %impl.elem0.loc21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc21: = bound_method %int_2147483648.loc21, %impl.elem0.loc21 [template = constants.%Convert.bound.85f] -// CHECK:STDOUT: %Convert.specific_fn.loc21: = specific_function %Convert.bound.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.387] -// CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(%int_2147483648.loc21) [template = constants.%int_2147483648.8df] -// CHECK:STDOUT: %.loc21_27.1: %i32 = value_of_initializer %int.convert_checked.loc21 [template = constants.%int_2147483648.8df] -// CHECK:STDOUT: %.loc21_27.2: %i32 = converted %int_2147483648.loc21, %.loc21_27.1 [template = constants.%int_2147483648.8df] -// CHECK:STDOUT: %b: %i32 = bind_name b, %.loc21_27.2 // CHECK:STDOUT: %int_2147483648.loc27: Core.IntLiteral = int_value 2147483648 [template = constants.%int_2147483648.1db] -// CHECK:STDOUT: %impl.elem0.loc27: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc27: = bound_method %int_2147483648.loc27, %impl.elem0.loc27 [template = constants.%Convert.bound.85f] -// CHECK:STDOUT: %Convert.specific_fn.loc27: = specific_function %Convert.bound.loc27, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.387] -// CHECK:STDOUT: %int.convert_checked.loc27: init %i32 = call %Convert.specific_fn.loc27(%int_2147483648.loc27) [template = constants.%int_2147483648.8df] -// CHECK:STDOUT: %.loc27_25.1: %i32 = value_of_initializer %int.convert_checked.loc27 [template = constants.%int_2147483648.8df] -// CHECK:STDOUT: %.loc27_25.2: %i32 = converted %int_2147483648.loc27, %.loc27_25.1 [template = constants.%int_2147483648.8df] -// CHECK:STDOUT: %c: %i32 = bind_name c, %.loc27_25.2 -// CHECK:STDOUT: %d: f64 = bind_name d, -// CHECK:STDOUT: %e: f64 = bind_name e, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/numeric_literals.carbon b/toolchain/check/testdata/basics/numeric_literals.carbon index 79b1e436496b..26621cc66555 100644 --- a/toolchain/check/testdata/basics/numeric_literals.carbon +++ b/toolchain/check/testdata/basics/numeric_literals.carbon @@ -62,6 +62,9 @@ fn F() { // CHECK:STDOUT: %int_2147483647.a74: %i32 = int_value 2147483647 [template] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template] // CHECK:STDOUT: %array.ae2: %array_type.d49 = tuple_value (%int_8.98c, %int_9.f88, %int_8.98c, %int_8.98c, %int_2147483647.a74, %int_2147483647.a74) [template] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %array_type.72b: type = array_type %int_6, f64 [template] // CHECK:STDOUT: %float.952: f64 = float_literal 0.90000000000000002 [template] // CHECK:STDOUT: %float.298: f64 = float_literal 8 [template] @@ -94,8 +97,11 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ints.patt: %array_type.d49 = binding_pattern ints +// CHECK:STDOUT: %.loc14_3.1: %array_type.d49 = var_pattern %ints.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ints.var: ref %array_type.d49 = var ints -// CHECK:STDOUT: %ints: ref %array_type.d49 = bind_name ints, %ints.var // CHECK:STDOUT: %int_8.loc15: Core.IntLiteral = int_value 8 [template = constants.%int_8.b85] // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [template = constants.%int_9.988] // CHECK:STDOUT: %int_8.loc17: Core.IntLiteral = int_value 8 [template = constants.%int_8.b85] @@ -152,10 +158,20 @@ fn F() { // CHECK:STDOUT: %.loc21_3.18: ref %i32 = array_index %ints.var, %int_5.loc21 // CHECK:STDOUT: %.loc21_3.19: init %i32 = initialize_from %.loc21_3.17 to %.loc21_3.18 [template = constants.%int_2147483647.a74] // CHECK:STDOUT: %.loc21_3.20: init %array_type.d49 = array_init (%.loc21_3.4, %.loc21_3.7, %.loc21_3.10, %.loc21_3.13, %.loc21_3.16, %.loc21_3.19) to %ints.var [template = constants.%array.ae2] -// CHECK:STDOUT: %.loc21_4: init %array_type.d49 = converted %.loc21_3.1, %.loc21_3.20 [template = constants.%array.ae2] -// CHECK:STDOUT: assign %ints.var, %.loc21_4 +// CHECK:STDOUT: %.loc14_3.2: init %array_type.d49 = converted %.loc21_3.1, %.loc21_3.20 [template = constants.%array.ae2] +// CHECK:STDOUT: assign %ints.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_20: type = splice_block %array_type.loc14 [template = constants.%array_type.d49] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_6.loc14: Core.IntLiteral = int_value 6 [template = constants.%int_6] +// CHECK:STDOUT: %array_type.loc14: type = array_type %int_6.loc14, %i32 [template = constants.%array_type.d49] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ints: ref %array_type.d49 = bind_name ints, %ints.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %floats.patt: %array_type.72b = binding_pattern floats +// CHECK:STDOUT: %.loc22_3.1: %array_type.72b = var_pattern %floats.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %floats.var: ref %array_type.72b = var floats -// CHECK:STDOUT: %floats: ref %array_type.72b = bind_name floats, %floats.var // CHECK:STDOUT: %float.loc23: f64 = float_literal 0.90000000000000002 [template = constants.%float.952] // CHECK:STDOUT: %float.loc24: f64 = float_literal 8 [template = constants.%float.298] // CHECK:STDOUT: %float.loc25: f64 = float_literal 80 [template = constants.%float.dcb] @@ -182,8 +198,17 @@ fn F() { // CHECK:STDOUT: %.loc29_3.12: ref f64 = array_index %floats.var, %int_5.loc29 // CHECK:STDOUT: %.loc29_3.13: init f64 = initialize_from %float.loc28 to %.loc29_3.12 [template = constants.%float.401] // CHECK:STDOUT: %.loc29_3.14: init %array_type.72b = array_init (%.loc29_3.3, %.loc29_3.5, %.loc29_3.7, %.loc29_3.9, %.loc29_3.11, %.loc29_3.13) to %floats.var [template = constants.%array.a2f] -// CHECK:STDOUT: %.loc29_4: init %array_type.72b = converted %.loc29_3.1, %.loc29_3.14 [template = constants.%array.a2f] -// CHECK:STDOUT: assign %floats.var, %.loc29_4 +// CHECK:STDOUT: %.loc22_3.2: init %array_type.72b = converted %.loc29_3.1, %.loc29_3.14 [template = constants.%array.a2f] +// CHECK:STDOUT: assign %floats.var, %.loc22_3.2 +// CHECK:STDOUT: %.loc22_22: type = splice_block %array_type.loc22 [template = constants.%array_type.72b] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %int_6.loc22: Core.IntLiteral = int_value 6 [template = constants.%int_6] +// CHECK:STDOUT: %.loc22_16.1: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc22_16.2: type = converted %float.make_type, %.loc22_16.1 [template = f64] +// CHECK:STDOUT: %array_type.loc22: type = array_type %int_6.loc22, f64 [template = constants.%array_type.72b] +// CHECK:STDOUT: } +// CHECK:STDOUT: %floats: ref %array_type.72b = bind_name floats, %floats.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/parens.carbon b/toolchain/check/testdata/basics/parens.carbon index af70443cef86..e8f371a35078 100644 --- a/toolchain/check/testdata/basics/parens.carbon +++ b/toolchain/check/testdata/basics/parens.carbon @@ -46,9 +46,25 @@ var b: i32 = ((2)); // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc11_8: type = splice_block %i32.loc11 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc12_8: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/basics/type_literals.carbon b/toolchain/check/testdata/basics/type_literals.carbon index b24587b33e42..17dec5698dc9 100644 --- a/toolchain/check/testdata/basics/type_literals.carbon +++ b/toolchain/check/testdata/basics/type_literals.carbon @@ -153,11 +153,35 @@ var test_f128: f128; // CHECK:STDOUT: .test_i64 = %test_i64 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_i8.patt: %i8 = binding_pattern test_i8 +// CHECK:STDOUT: %.loc3_1: %i8 = var_pattern %test_i8.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i8.var: ref %i8 = var test_i8 +// CHECK:STDOUT: %.loc3_14: type = splice_block %i8 [template = constants.%i8] { +// CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [template = constants.%int_8] +// CHECK:STDOUT: %i8: type = class_type @Int, @Int(constants.%int_8) [template = constants.%i8] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i8: ref %i8 = bind_name test_i8, %test_i8.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_i16.patt: %i16 = binding_pattern test_i16 +// CHECK:STDOUT: %.loc4_1: %i16 = var_pattern %test_i16.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i16.var: ref %i16 = var test_i16 +// CHECK:STDOUT: %.loc4_15: type = splice_block %i16 [template = constants.%i16] { +// CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [template = constants.%int_16] +// CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [template = constants.%i16] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i16: ref %i16 = bind_name test_i16, %test_i16.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_i64.patt: %i64 = binding_pattern test_i64 +// CHECK:STDOUT: %.loc5_1: %i64 = var_pattern %test_i64.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i64.var: ref %i64 = var test_i64 +// CHECK:STDOUT: %.loc5_15: type = splice_block %i64 [template = constants.%i64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %i64: type = class_type @Int, @Int(constants.%int_64) [template = constants.%i64] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_i64: ref %i64 = bind_name test_i64, %test_i64.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -195,11 +219,35 @@ var test_f128: f128; // CHECK:STDOUT: .test_u64 = %test_u64 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_u8.patt: %u8 = binding_pattern test_u8 +// CHECK:STDOUT: %.loc3_1: %u8 = var_pattern %test_u8.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_u8.var: ref %u8 = var test_u8 +// CHECK:STDOUT: %.loc3_14: type = splice_block %u8 [template = constants.%u8] { +// CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [template = constants.%int_8] +// CHECK:STDOUT: %u8: type = class_type @UInt, @UInt(constants.%int_8) [template = constants.%u8] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_u8: ref %u8 = bind_name test_u8, %test_u8.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_u16.patt: %u16 = binding_pattern test_u16 +// CHECK:STDOUT: %.loc4_1: %u16 = var_pattern %test_u16.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_u16.var: ref %u16 = var test_u16 +// CHECK:STDOUT: %.loc4_15: type = splice_block %u16 [template = constants.%u16] { +// CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [template = constants.%int_16] +// CHECK:STDOUT: %u16: type = class_type @UInt, @UInt(constants.%int_16) [template = constants.%u16] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_u16: ref %u16 = bind_name test_u16, %test_u16.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %test_u64.patt: %u64 = binding_pattern test_u64 +// CHECK:STDOUT: %.loc5_1: %u64 = var_pattern %test_u64.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %test_u64.var: ref %u64 = var test_u64 +// CHECK:STDOUT: %.loc5_15: type = splice_block %u64 [template = constants.%u64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %u64: type = class_type @UInt, @UInt(constants.%int_64) [template = constants.%u64] +// CHECK:STDOUT: } // CHECK:STDOUT: %test_u64: ref %u64 = bind_name test_u64, %test_u64.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/bool/eq.carbon b/toolchain/check/testdata/builtins/bool/eq.carbon index 4f168181fd39..3e7eb2e6078d 100644 --- a/toolchain/check/testdata/builtins/bool/eq.carbon +++ b/toolchain/check/testdata/builtins/bool/eq.carbon @@ -142,13 +142,69 @@ var d: C(false == false) = True(); // CHECK:STDOUT: %return.param: ref %C.2ba = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C.2ba = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C.a14 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %C.a14 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C.a14 = var a +// CHECK:STDOUT: %.loc11_24.1: type = splice_block %C.loc11 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc11: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Eq.ref.loc11: %Eq.type = name_ref Eq, %Eq.decl [template = constants.%Eq] +// CHECK:STDOUT: %true.loc11_13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %true.loc11_19: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %bool.eq.loc11: init bool = call %Eq.ref.loc11(%true.loc11_13, %true.loc11_19) [template = constants.%true] +// CHECK:STDOUT: %.loc11_24.2: bool = value_of_initializer %bool.eq.loc11 [template = constants.%true] +// CHECK:STDOUT: %.loc11_24.3: bool = converted %bool.eq.loc11, %.loc11_24.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc11: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %C.a14 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %C.2ba = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %C.2ba = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %C.2ba = var b +// CHECK:STDOUT: %.loc12_25.1: type = splice_block %C.loc12 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc12: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Eq.ref.loc12: %Eq.type = name_ref Eq, %Eq.decl [template = constants.%Eq] +// CHECK:STDOUT: %true.loc12: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc12: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %bool.eq.loc12: init bool = call %Eq.ref.loc12(%true.loc12, %false.loc12) [template = constants.%false] +// CHECK:STDOUT: %.loc12_25.2: bool = value_of_initializer %bool.eq.loc12 [template = constants.%false] +// CHECK:STDOUT: %.loc12_25.3: bool = converted %bool.eq.loc12, %.loc12_25.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc12: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %C.2ba = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.2ba = binding_pattern c +// CHECK:STDOUT: %.loc13_1: %C.2ba = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.2ba = var c +// CHECK:STDOUT: %.loc13_25.1: type = splice_block %C.loc13 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc13: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Eq.ref.loc13: %Eq.type = name_ref Eq, %Eq.decl [template = constants.%Eq] +// CHECK:STDOUT: %false.loc13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %true.loc13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %bool.eq.loc13: init bool = call %Eq.ref.loc13(%false.loc13, %true.loc13) [template = constants.%false] +// CHECK:STDOUT: %.loc13_25.2: bool = value_of_initializer %bool.eq.loc13 [template = constants.%false] +// CHECK:STDOUT: %.loc13_25.3: bool = converted %bool.eq.loc13, %.loc13_25.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc13: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.2ba = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %C.a14 = binding_pattern d +// CHECK:STDOUT: %.loc14_1: %C.a14 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %C.a14 = var d +// CHECK:STDOUT: %.loc14_26.1: type = splice_block %C.loc14 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc14: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Eq.ref.loc14: %Eq.type = name_ref Eq, %Eq.decl [template = constants.%Eq] +// CHECK:STDOUT: %false.loc14_13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc14_20: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %bool.eq.loc14: init bool = call %Eq.ref.loc14(%false.loc14_13, %false.loc14_20) [template = constants.%true] +// CHECK:STDOUT: %.loc14_26.2: bool = value_of_initializer %bool.eq.loc14 [template = constants.%true] +// CHECK:STDOUT: %.loc14_26.3: bool = converted %bool.eq.loc14, %.loc14_26.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc14: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %C.a14 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -229,6 +285,12 @@ var d: C(false == false) = True(); // CHECK:STDOUT: %C.2ba: type = class_type @C, @C(%false) [template] // CHECK:STDOUT: %False.type: type = fn_type @False [template] // CHECK:STDOUT: %False: %False.type = struct_value () [template] +// CHECK:STDOUT: %Equal.type.79c: type = fn_type @Equal.1 [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (imports.%import_ref.998, imports.%import_ref.fb6) [template] +// CHECK:STDOUT: %Equal.type.aa3: type = fn_type @Equal.2 [template] +// CHECK:STDOUT: %Equal.6e2: %Equal.type.aa3 = struct_value () [template] +// CHECK:STDOUT: %Equal.bound.fe0: = bound_method %true, %Equal.6e2 [template] +// CHECK:STDOUT: %Equal.bound.d3c: = bound_method %false, %Equal.6e2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -284,13 +346,73 @@ var d: C(false == false) = True(); // CHECK:STDOUT: %return.param: ref %C.2ba = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C.2ba = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C.a14 = binding_pattern a +// CHECK:STDOUT: %.loc9_1: %C.a14 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C.a14 = var a +// CHECK:STDOUT: %.loc9_22.1: type = splice_block %C.loc9 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc9: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %true.loc9_10: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %true.loc9_18: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %impl.elem0.loc9: %Equal.type.79c = impl_witness_access constants.%impl_witness, element0 [template = constants.%Equal.6e2] +// CHECK:STDOUT: %Equal.bound.loc9: = bound_method %true.loc9_10, %impl.elem0.loc9 [template = constants.%Equal.bound.fe0] +// CHECK:STDOUT: %bool.eq.loc9: init bool = call %Equal.bound.loc9(%true.loc9_10, %true.loc9_18) [template = constants.%true] +// CHECK:STDOUT: %.loc9_22.2: bool = value_of_initializer %bool.eq.loc9 [template = constants.%true] +// CHECK:STDOUT: %.loc9_22.3: bool = converted %bool.eq.loc9, %.loc9_22.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc9: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %C.a14 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %C.2ba = binding_pattern b +// CHECK:STDOUT: %.loc10_1: %C.2ba = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %C.2ba = var b +// CHECK:STDOUT: %.loc10_23.1: type = splice_block %C.loc10 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc10: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %true.loc10: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc10: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %impl.elem0.loc10: %Equal.type.79c = impl_witness_access constants.%impl_witness, element0 [template = constants.%Equal.6e2] +// CHECK:STDOUT: %Equal.bound.loc10: = bound_method %true.loc10, %impl.elem0.loc10 [template = constants.%Equal.bound.fe0] +// CHECK:STDOUT: %bool.eq.loc10: init bool = call %Equal.bound.loc10(%true.loc10, %false.loc10) [template = constants.%false] +// CHECK:STDOUT: %.loc10_23.2: bool = value_of_initializer %bool.eq.loc10 [template = constants.%false] +// CHECK:STDOUT: %.loc10_23.3: bool = converted %bool.eq.loc10, %.loc10_23.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc10: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %C.2ba = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.2ba = binding_pattern c +// CHECK:STDOUT: %.loc11_1: %C.2ba = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.2ba = var c +// CHECK:STDOUT: %.loc11_23.1: type = splice_block %C.loc11 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc11: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %false.loc11: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %true.loc11: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %impl.elem0.loc11: %Equal.type.79c = impl_witness_access constants.%impl_witness, element0 [template = constants.%Equal.6e2] +// CHECK:STDOUT: %Equal.bound.loc11: = bound_method %false.loc11, %impl.elem0.loc11 [template = constants.%Equal.bound.d3c] +// CHECK:STDOUT: %bool.eq.loc11: init bool = call %Equal.bound.loc11(%false.loc11, %true.loc11) [template = constants.%false] +// CHECK:STDOUT: %.loc11_23.2: bool = value_of_initializer %bool.eq.loc11 [template = constants.%false] +// CHECK:STDOUT: %.loc11_23.3: bool = converted %bool.eq.loc11, %.loc11_23.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc11: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.2ba = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %C.a14 = binding_pattern d +// CHECK:STDOUT: %.loc12_1: %C.a14 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %C.a14 = var d +// CHECK:STDOUT: %.loc12_24.1: type = splice_block %C.loc12 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc12: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %false.loc12_10: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc12_19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %impl.elem0.loc12: %Equal.type.79c = impl_witness_access constants.%impl_witness, element0 [template = constants.%Equal.6e2] +// CHECK:STDOUT: %Equal.bound.loc12: = bound_method %false.loc12_10, %impl.elem0.loc12 [template = constants.%Equal.bound.d3c] +// CHECK:STDOUT: %bool.eq.loc12: init bool = call %Equal.bound.loc12(%false.loc12_10, %false.loc12_19) [template = constants.%true] +// CHECK:STDOUT: %.loc12_24.2: bool = value_of_initializer %bool.eq.loc12 [template = constants.%true] +// CHECK:STDOUT: %.loc12_24.3: bool = converted %bool.eq.loc12, %.loc12_24.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc12: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %C.a14 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/bool/make_type.carbon b/toolchain/check/testdata/builtins/bool/make_type.carbon index 73ac6f395e40..1c58ef2c3619 100644 --- a/toolchain/check/testdata/builtins/bool/make_type.carbon +++ b/toolchain/check/testdata/builtins/bool/make_type.carbon @@ -77,7 +77,17 @@ var b: Bool() = false; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: bool = binding_pattern b +// CHECK:STDOUT: %.loc6_1: bool = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref bool = var b +// CHECK:STDOUT: %.loc6_13.1: type = splice_block %.loc6_13.3 [template = bool] { +// CHECK:STDOUT: %Bool.ref: %Bool.type = name_ref Bool, imports.%import_ref [template = constants.%Bool] +// CHECK:STDOUT: %bool.make_type: init type = call %Bool.ref() [template = bool] +// CHECK:STDOUT: %.loc6_13.2: type = value_of_initializer %bool.make_type [template = bool] +// CHECK:STDOUT: %.loc6_13.3: type = converted %bool.make_type, %.loc6_13.2 [template = bool] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref bool = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/bool/neq.carbon b/toolchain/check/testdata/builtins/bool/neq.carbon index 0c5820e44429..63f406a0cc2b 100644 --- a/toolchain/check/testdata/builtins/bool/neq.carbon +++ b/toolchain/check/testdata/builtins/bool/neq.carbon @@ -142,13 +142,69 @@ var d: C(false != false) = False(); // CHECK:STDOUT: %return.param: ref %C.2ba = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C.2ba = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C.2ba = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %C.2ba = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C.2ba = var a +// CHECK:STDOUT: %.loc11_25.1: type = splice_block %C.loc11 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc11: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Neq.ref.loc11: %Neq.type = name_ref Neq, %Neq.decl [template = constants.%Neq] +// CHECK:STDOUT: %true.loc11_14: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %true.loc11_20: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %bool.neq.loc11: init bool = call %Neq.ref.loc11(%true.loc11_14, %true.loc11_20) [template = constants.%false] +// CHECK:STDOUT: %.loc11_25.2: bool = value_of_initializer %bool.neq.loc11 [template = constants.%false] +// CHECK:STDOUT: %.loc11_25.3: bool = converted %bool.neq.loc11, %.loc11_25.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc11: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %C.2ba = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %C.a14 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %C.a14 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %C.a14 = var b +// CHECK:STDOUT: %.loc12_26.1: type = splice_block %C.loc12 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc12: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Neq.ref.loc12: %Neq.type = name_ref Neq, %Neq.decl [template = constants.%Neq] +// CHECK:STDOUT: %true.loc12: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc12: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %bool.neq.loc12: init bool = call %Neq.ref.loc12(%true.loc12, %false.loc12) [template = constants.%true] +// CHECK:STDOUT: %.loc12_26.2: bool = value_of_initializer %bool.neq.loc12 [template = constants.%true] +// CHECK:STDOUT: %.loc12_26.3: bool = converted %bool.neq.loc12, %.loc12_26.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc12: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %C.a14 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.a14 = binding_pattern c +// CHECK:STDOUT: %.loc13_1: %C.a14 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.a14 = var c +// CHECK:STDOUT: %.loc13_26.1: type = splice_block %C.loc13 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc13: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Neq.ref.loc13: %Neq.type = name_ref Neq, %Neq.decl [template = constants.%Neq] +// CHECK:STDOUT: %false.loc13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %true.loc13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %bool.neq.loc13: init bool = call %Neq.ref.loc13(%false.loc13, %true.loc13) [template = constants.%true] +// CHECK:STDOUT: %.loc13_26.2: bool = value_of_initializer %bool.neq.loc13 [template = constants.%true] +// CHECK:STDOUT: %.loc13_26.3: bool = converted %bool.neq.loc13, %.loc13_26.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc13: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.a14 = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %C.2ba = binding_pattern d +// CHECK:STDOUT: %.loc14_1: %C.2ba = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %C.2ba = var d +// CHECK:STDOUT: %.loc14_27.1: type = splice_block %C.loc14 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc14: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %Neq.ref.loc14: %Neq.type = name_ref Neq, %Neq.decl [template = constants.%Neq] +// CHECK:STDOUT: %false.loc14_14: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc14_21: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %bool.neq.loc14: init bool = call %Neq.ref.loc14(%false.loc14_14, %false.loc14_21) [template = constants.%false] +// CHECK:STDOUT: %.loc14_27.2: bool = value_of_initializer %bool.neq.loc14 [template = constants.%false] +// CHECK:STDOUT: %.loc14_27.3: bool = converted %bool.neq.loc14, %.loc14_27.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc14: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %C.2ba = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -229,6 +285,12 @@ var d: C(false != false) = False(); // CHECK:STDOUT: %C.2ba: type = class_type @C, @C(%false) [template] // CHECK:STDOUT: %False.type: type = fn_type @False [template] // CHECK:STDOUT: %False: %False.type = struct_value () [template] +// CHECK:STDOUT: %NotEqual.type.e6c: type = fn_type @NotEqual.1 [template] +// CHECK:STDOUT: %impl_witness: = impl_witness (imports.%import_ref.85b, imports.%import_ref.67a) [template] +// CHECK:STDOUT: %NotEqual.type.c0e: type = fn_type @NotEqual.2 [template] +// CHECK:STDOUT: %NotEqual.bf4: %NotEqual.type.c0e = struct_value () [template] +// CHECK:STDOUT: %NotEqual.bound.542: = bound_method %true, %NotEqual.bf4 [template] +// CHECK:STDOUT: %NotEqual.bound.5a9: = bound_method %false, %NotEqual.bf4 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -284,13 +346,73 @@ var d: C(false != false) = False(); // CHECK:STDOUT: %return.param: ref %C.2ba = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C.2ba = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C.2ba = binding_pattern a +// CHECK:STDOUT: %.loc9_1: %C.2ba = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C.2ba = var a +// CHECK:STDOUT: %.loc9_22.1: type = splice_block %C.loc9 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc9: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %true.loc9_10: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %true.loc9_18: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %impl.elem1.loc9: %NotEqual.type.e6c = impl_witness_access constants.%impl_witness, element1 [template = constants.%NotEqual.bf4] +// CHECK:STDOUT: %NotEqual.bound.loc9: = bound_method %true.loc9_10, %impl.elem1.loc9 [template = constants.%NotEqual.bound.542] +// CHECK:STDOUT: %bool.neq.loc9: init bool = call %NotEqual.bound.loc9(%true.loc9_10, %true.loc9_18) [template = constants.%false] +// CHECK:STDOUT: %.loc9_22.2: bool = value_of_initializer %bool.neq.loc9 [template = constants.%false] +// CHECK:STDOUT: %.loc9_22.3: bool = converted %bool.neq.loc9, %.loc9_22.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc9: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %C.2ba = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %C.a14 = binding_pattern b +// CHECK:STDOUT: %.loc10_1: %C.a14 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %C.a14 = var b +// CHECK:STDOUT: %.loc10_23.1: type = splice_block %C.loc10 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc10: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %true.loc10: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc10: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %impl.elem1.loc10: %NotEqual.type.e6c = impl_witness_access constants.%impl_witness, element1 [template = constants.%NotEqual.bf4] +// CHECK:STDOUT: %NotEqual.bound.loc10: = bound_method %true.loc10, %impl.elem1.loc10 [template = constants.%NotEqual.bound.542] +// CHECK:STDOUT: %bool.neq.loc10: init bool = call %NotEqual.bound.loc10(%true.loc10, %false.loc10) [template = constants.%true] +// CHECK:STDOUT: %.loc10_23.2: bool = value_of_initializer %bool.neq.loc10 [template = constants.%true] +// CHECK:STDOUT: %.loc10_23.3: bool = converted %bool.neq.loc10, %.loc10_23.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc10: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %C.a14 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.a14 = binding_pattern c +// CHECK:STDOUT: %.loc11_1: %C.a14 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.a14 = var c +// CHECK:STDOUT: %.loc11_23.1: type = splice_block %C.loc11 [template = constants.%C.a14] { +// CHECK:STDOUT: %C.ref.loc11: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %false.loc11: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %true.loc11: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %impl.elem1.loc11: %NotEqual.type.e6c = impl_witness_access constants.%impl_witness, element1 [template = constants.%NotEqual.bf4] +// CHECK:STDOUT: %NotEqual.bound.loc11: = bound_method %false.loc11, %impl.elem1.loc11 [template = constants.%NotEqual.bound.5a9] +// CHECK:STDOUT: %bool.neq.loc11: init bool = call %NotEqual.bound.loc11(%false.loc11, %true.loc11) [template = constants.%true] +// CHECK:STDOUT: %.loc11_23.2: bool = value_of_initializer %bool.neq.loc11 [template = constants.%true] +// CHECK:STDOUT: %.loc11_23.3: bool = converted %bool.neq.loc11, %.loc11_23.2 [template = constants.%true] +// CHECK:STDOUT: %C.loc11: type = class_type @C, @C(constants.%true) [template = constants.%C.a14] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.a14 = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %C.2ba = binding_pattern d +// CHECK:STDOUT: %.loc12_1: %C.2ba = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %C.2ba = var d +// CHECK:STDOUT: %.loc12_24.1: type = splice_block %C.loc12 [template = constants.%C.2ba] { +// CHECK:STDOUT: %C.ref.loc12: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %false.loc12_10: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc12_19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %impl.elem1.loc12: %NotEqual.type.e6c = impl_witness_access constants.%impl_witness, element1 [template = constants.%NotEqual.bf4] +// CHECK:STDOUT: %NotEqual.bound.loc12: = bound_method %false.loc12_10, %impl.elem1.loc12 [template = constants.%NotEqual.bound.5a9] +// CHECK:STDOUT: %bool.neq.loc12: init bool = call %NotEqual.bound.loc12(%false.loc12_10, %false.loc12_19) [template = constants.%false] +// CHECK:STDOUT: %.loc12_24.2: bool = value_of_initializer %bool.neq.loc12 [template = constants.%false] +// CHECK:STDOUT: %.loc12_24.3: bool = converted %bool.neq.loc12, %.loc12_24.2 [template = constants.%false] +// CHECK:STDOUT: %C.loc12: type = class_type @C, @C(constants.%false) [template = constants.%C.2ba] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %C.2ba = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/float/add.carbon b/toolchain/check/testdata/builtins/float/add.carbon index 1be6b7ff1fd6..003d265ec9c8 100644 --- a/toolchain/check/testdata/builtins/float/add.carbon +++ b/toolchain/check/testdata/builtins/float/add.carbon @@ -144,7 +144,17 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2 // CHECK:STDOUT: %return: ref f64 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: f64 = binding_pattern x +// CHECK:STDOUT: %.loc8_1: f64 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref f64 = var x +// CHECK:STDOUT: %.loc8_8.1: type = splice_block %.loc8_8.3 [template = f64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type, %.loc8_8.2 [template = f64] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref f64 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/float/div.carbon b/toolchain/check/testdata/builtins/float/div.carbon index 1b0efeb68d2e..0a6f2da7b203 100644 --- a/toolchain/check/testdata/builtins/float/div.carbon +++ b/toolchain/check/testdata/builtins/float/div.carbon @@ -86,8 +86,8 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .Div = %Div.decl // CHECK:STDOUT: .RuntimeCallIsValid = %RuntimeCallIsValid.decl // CHECK:STDOUT: .a = %a -// CHECK:STDOUT: .b = @__global_init.%b -// CHECK:STDOUT: .c = @__global_init.%c +// CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] { @@ -152,8 +152,42 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2 // CHECK:STDOUT: %return: ref f64 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: f64 = binding_pattern a +// CHECK:STDOUT: %.loc8_1: f64 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref f64 = var a +// CHECK:STDOUT: %.loc8_8.1: type = splice_block %.loc8_8.3 [template = f64] { +// CHECK:STDOUT: %int_64.loc8: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc8: init type = call constants.%Float(%int_64.loc8) [template = f64] +// CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type.loc8 [template = f64] +// CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type.loc8, %.loc8_8.2 [template = f64] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref f64 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: f64 = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9_8.1: type = splice_block %.loc9_8.3 [template = f64] { +// CHECK:STDOUT: %int_64.loc9: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc9: init type = call constants.%Float(%int_64.loc9) [template = f64] +// CHECK:STDOUT: %.loc9_8.2: type = value_of_initializer %float.make_type.loc9 [template = f64] +// CHECK:STDOUT: %.loc9_8.3: type = converted %float.make_type.loc9, %.loc9_8.2 [template = f64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9_26.1: ref f64 = temporary_storage +// CHECK:STDOUT: %.loc9_26.2: ref f64 = temporary %.loc9_26.1, @__global_init.%float.div.loc9 +// CHECK:STDOUT: %b: ref f64 = bind_name b, %.loc9_26.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: f64 = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10_8.1: type = splice_block %.loc10_8.3 [template = f64] { +// CHECK:STDOUT: %int_64.loc10: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc10: init type = call constants.%Float(%int_64.loc10) [template = f64] +// CHECK:STDOUT: %.loc10_8.2: type = value_of_initializer %float.make_type.loc10 [template = f64] +// CHECK:STDOUT: %.loc10_8.3: type = converted %float.make_type.loc10, %.loc10_8.2 [template = f64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10_26.1: ref f64 = temporary_storage +// CHECK:STDOUT: %.loc10_26.2: ref f64 = temporary %.loc10_26.1, @__global_init.%float.div.loc10 +// CHECK:STDOUT: %c: ref f64 = bind_name c, %.loc10_26.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Div(%a.param_patt: f64, %b.param_patt: f64) -> f64 = "float.div"; @@ -180,16 +214,10 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %float.loc9_18: f64 = float_literal 1 [template = constants.%float.f4e] // CHECK:STDOUT: %float.loc9_23: f64 = float_literal 0 [template = constants.%float.555] // CHECK:STDOUT: %float.div.loc9: init f64 = call %Div.ref.loc9(%float.loc9_18, %float.loc9_23) [template = constants.%float.bd4] -// CHECK:STDOUT: %.loc9_27.1: f64 = value_of_initializer %float.div.loc9 [template = constants.%float.bd4] -// CHECK:STDOUT: %.loc9_27.2: f64 = converted %float.div.loc9, %.loc9_27.1 [template = constants.%float.bd4] -// CHECK:STDOUT: %b: f64 = bind_name b, %.loc9_27.2 // CHECK:STDOUT: %Div.ref.loc10: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div] // CHECK:STDOUT: %float.loc10_18: f64 = float_literal 0 [template = constants.%float.555] // CHECK:STDOUT: %float.loc10_23: f64 = float_literal 0 [template = constants.%float.555] // CHECK:STDOUT: %float.div.loc10: init f64 = call %Div.ref.loc10(%float.loc10_18, %float.loc10_23) [template = constants.%float.8b7] -// CHECK:STDOUT: %.loc10_27.1: f64 = value_of_initializer %float.div.loc10 [template = constants.%float.8b7] -// CHECK:STDOUT: %.loc10_27.2: f64 = converted %float.div.loc10, %.loc10_27.1 [template = constants.%float.8b7] -// CHECK:STDOUT: %c: f64 = bind_name c, %.loc10_27.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/float/make_type.carbon b/toolchain/check/testdata/builtins/float/make_type.carbon index 29bdd34a6db6..4987ebfa8f2a 100644 --- a/toolchain/check/testdata/builtins/float/make_type.carbon +++ b/toolchain/check/testdata/builtins/float/make_type.carbon @@ -94,6 +94,14 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %int_64.fab: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Convert.type.6da: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.b97: = impl_witness (imports.%import_ref.a86), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.ed5: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.16d: %Convert.type.ed5 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_64.fab, %Convert.16d [template] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_64.198: %i32 = int_value 64 [template] // CHECK:STDOUT: %float: f64 = float_literal 0 [template] // CHECK:STDOUT: %GetFloat.type: type = fn_type @GetFloat [template] // CHECK:STDOUT: %GetFloat: %GetFloat.type = struct_value () [template] @@ -118,7 +126,24 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: f64 = binding_pattern f +// CHECK:STDOUT: %.loc6_1: f64 = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref f64 = var f +// CHECK:STDOUT: %.loc6_16.1: type = splice_block %.loc6_16.3 [template = f64] { +// CHECK:STDOUT: %Float.ref: %Float.type = name_ref Float, imports.%import_ref.fb8 [template = constants.%Float] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64.fab] +// CHECK:STDOUT: %impl.elem0: %Convert.type.6da = impl_witness_access constants.%impl_witness.b97, element0 [template = constants.%Convert.16d] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_64, %impl.elem0 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_64) [template = constants.%int_64.198] +// CHECK:STDOUT: %.loc6_14.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_64.198] +// CHECK:STDOUT: %.loc6_14.2: %i32 = converted %int_64, %.loc6_14.1 [template = constants.%int_64.198] +// CHECK:STDOUT: %float.make_type: init type = call %Float.ref(%.loc6_14.2) [template = f64] +// CHECK:STDOUT: %.loc6_16.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc6_16.3: type = converted %float.make_type, %.loc6_16.2 [template = f64] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref f64 = bind_name f, %f.var // CHECK:STDOUT: %GetFloat.decl: %GetFloat.type = fn_decl @GetFloat [template = constants.%GetFloat] { // CHECK:STDOUT: %dyn_size.patt: %i32 = binding_pattern dyn_size @@ -167,6 +192,9 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: %impl_witness.b97: = impl_witness (imports.%import_ref.a86), @impl.1(%int_32.be0) [template] // CHECK:STDOUT: %Convert.type.ed5: type = fn_type @Convert.2, @impl.1(%int_32.be0) [template] // CHECK:STDOUT: %Convert.16d: %Convert.type.ed5 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.cce: = bound_method %int_32.be0, %Convert.16d [template] +// CHECK:STDOUT: %Convert.specific_fn.23b: = specific_function %Convert.bound.cce, @Convert.2(%int_32.be0) [template] +// CHECK:STDOUT: %int_32.4de: %i32 = int_value 32 [template] // CHECK:STDOUT: %int_64.fab: Core.IntLiteral = int_value 64 [template] // CHECK:STDOUT: %Convert.bound.575: = bound_method %int_64.fab, %Convert.16d [template] // CHECK:STDOUT: %Convert.specific_fn.bd8: = specific_function %Convert.bound.575, @Convert.2(%int_32.be0) [template] @@ -193,12 +221,49 @@ var dyn: Float(dyn_size); // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %invalid_float.patt: = binding_pattern invalid_float +// CHECK:STDOUT: %.loc10_1: = var_pattern %invalid_float.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %invalid_float.var: ref = var invalid_float -// CHECK:STDOUT: %invalid_float: ref = bind_name invalid_float, %invalid_float.var +// CHECK:STDOUT: %.loc10_28.1: type = splice_block %.loc10_28.3 [template = ] { +// CHECK:STDOUT: %Float.ref.loc10: %Float.type = name_ref Float, imports.%import_ref.fb8 [template = constants.%Float] +// CHECK:STDOUT: %int_32.loc10: Core.IntLiteral = int_value 32 [template = constants.%int_32.be0] +// CHECK:STDOUT: %impl.elem0: %Convert.type.6da = impl_witness_access constants.%impl_witness.b97, element0 [template = constants.%Convert.16d] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_32.loc10, %impl.elem0 [template = constants.%Convert.bound.cce] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32.be0) [template = constants.%Convert.specific_fn.23b] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_32.loc10) [template = constants.%int_32.4de] +// CHECK:STDOUT: %.loc10_26.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_32.4de] +// CHECK:STDOUT: %.loc10_26.2: %i32 = converted %int_32.loc10, %.loc10_26.1 [template = constants.%int_32.4de] +// CHECK:STDOUT: %float.make_type.loc10: init type = call %Float.ref.loc10(%.loc10_26.2) [template = ] +// CHECK:STDOUT: %.loc10_28.2: type = value_of_initializer %float.make_type.loc10 [template = ] +// CHECK:STDOUT: %.loc10_28.3: type = converted %float.make_type.loc10, %.loc10_28.2 [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %invalid_float: = bind_name invalid_float, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %dyn_size.patt: %i32 = binding_pattern dyn_size +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %dyn_size.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %dyn_size.var: ref %i32 = var dyn_size +// CHECK:STDOUT: %.loc12_15: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32.be0] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32.be0) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %dyn_size: ref %i32 = bind_name dyn_size, %dyn_size.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %dyn.patt: = binding_pattern dyn +// CHECK:STDOUT: %.loc17_1: = var_pattern %dyn.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %dyn.var: ref = var dyn -// CHECK:STDOUT: %dyn: ref = bind_name dyn, %dyn.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Float.ref.loc17: %Float.type = name_ref Float, imports.%import_ref.fb8 [template = constants.%Float] +// CHECK:STDOUT: %dyn_size.ref: ref %i32 = name_ref dyn_size, %dyn_size +// CHECK:STDOUT: %.loc17_16: %i32 = bind_value %dyn_size.ref +// CHECK:STDOUT: %float.make_type.loc17: init type = call %Float.ref.loc17(%.loc17_16) +// CHECK:STDOUT: %.loc17_24.1: type = value_of_initializer %float.make_type.loc17 +// CHECK:STDOUT: %.loc17_24.2: type = converted %float.make_type.loc17, %.loc17_24.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %dyn: = bind_name dyn, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Float(%size.param_patt: %i32) -> type = "float.make_type" [from "types.carbon"]; diff --git a/toolchain/check/testdata/builtins/float/mul.carbon b/toolchain/check/testdata/builtins/float/mul.carbon index 1b91402214b8..989c515babcc 100644 --- a/toolchain/check/testdata/builtins/float/mul.carbon +++ b/toolchain/check/testdata/builtins/float/mul.carbon @@ -144,7 +144,17 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2 // CHECK:STDOUT: %return: ref f64 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: f64 = binding_pattern x +// CHECK:STDOUT: %.loc8_1: f64 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref f64 = var x +// CHECK:STDOUT: %.loc8_8.1: type = splice_block %.loc8_8.3 [template = f64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type, %.loc8_8.2 [template = f64] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref f64 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/float/negate.carbon b/toolchain/check/testdata/builtins/float/negate.carbon index 6f4100994e25..1e0d4a26e03e 100644 --- a/toolchain/check/testdata/builtins/float/negate.carbon +++ b/toolchain/check/testdata/builtins/float/negate.carbon @@ -99,7 +99,7 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Negate = %Negate.decl // CHECK:STDOUT: .RuntimeCallIsValid = %RuntimeCallIsValid.decl -// CHECK:STDOUT: .a = @__global_init.%a +// CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] { @@ -154,6 +154,18 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2 // CHECK:STDOUT: %return: ref f64 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: f64 = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc8_8.1: type = splice_block %.loc8_8.3 [template = f64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type, %.loc8_8.2 [template = f64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc8_24.1: ref f64 = temporary_storage +// CHECK:STDOUT: %.loc8_24.2: ref f64 = temporary %.loc8_24.1, @__global_init.%float.negate +// CHECK:STDOUT: %a: ref f64 = bind_name a, %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Negate(%a.param_patt: f64) -> f64 = "float.negate"; @@ -173,9 +185,6 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %Negate.ref: %Negate.type = name_ref Negate, file.%Negate.decl [template = constants.%Negate] // CHECK:STDOUT: %float: f64 = float_literal 1.5 [template = constants.%float.e93] // CHECK:STDOUT: %float.negate: init f64 = call %Negate.ref(%float) [template = constants.%float.928] -// CHECK:STDOUT: %.loc8_25.1: f64 = value_of_initializer %float.negate [template = constants.%float.928] -// CHECK:STDOUT: %.loc8_25.2: f64 = converted %float.negate, %.loc8_25.1 [template = constants.%float.928] -// CHECK:STDOUT: %a: f64 = bind_name a, %.loc8_25.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/float/sub.carbon b/toolchain/check/testdata/builtins/float/sub.carbon index cefc7dddcaa8..6a00f30ddc71 100644 --- a/toolchain/check/testdata/builtins/float/sub.carbon +++ b/toolchain/check/testdata/builtins/float/sub.carbon @@ -144,7 +144,17 @@ fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool { // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2 // CHECK:STDOUT: %return: ref f64 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: f64 = binding_pattern x +// CHECK:STDOUT: %.loc8_1: f64 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref f64 = var x +// CHECK:STDOUT: %.loc8_8.1: type = splice_block %.loc8_8.3 [template = f64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type, %.loc8_8.2 [template = f64] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref f64 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/builtins/read/int.carbon b/toolchain/check/testdata/builtins/read/int.carbon index 2b19c894268e..15d77521da95 100644 --- a/toolchain/check/testdata/builtins/read/int.carbon +++ b/toolchain/check/testdata/builtins/read/int.carbon @@ -64,17 +64,31 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } // CHECK:STDOUT: %ReadChar.ref.loc16: %ReadChar.type.fa8 = name_ref ReadChar, file.%ReadChar.decl [template = constants.%ReadChar.7f4] // CHECK:STDOUT: %read.char.loc16: init %i32 = call %ReadChar.ref.loc16() -// CHECK:STDOUT: %.loc16_26.1: %i32 = value_of_initializer %read.char.loc16 -// CHECK:STDOUT: %.loc16_26.2: %i32 = converted %read.char.loc16, %.loc16_26.1 -// CHECK:STDOUT: %n: %i32 = bind_name n, %.loc16_26.2 +// CHECK:STDOUT: %.loc16_10: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16_25.1: ref %i32 = temporary_storage +// CHECK:STDOUT: %.loc16_25.2: ref %i32 = temporary %.loc16_25.1, %read.char.loc16 +// CHECK:STDOUT: %n: ref %i32 = bind_name n, %.loc16_25.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %m.patt: %i32 = binding_pattern m +// CHECK:STDOUT: } // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %ReadChar.ref.loc17: %ReadChar.type.9f3 = name_ref ReadChar, imports.%import_ref.ecd [template = constants.%ReadChar.01f] // CHECK:STDOUT: %read.char.loc17: init %i32 = call %ReadChar.ref.loc17() -// CHECK:STDOUT: %.loc17_31.1: %i32 = value_of_initializer %read.char.loc17 -// CHECK:STDOUT: %.loc17_31.2: %i32 = converted %read.char.loc17, %.loc17_31.1 -// CHECK:STDOUT: %m: %i32 = bind_name m, %.loc17_31.2 +// CHECK:STDOUT: %.loc17_10: type = splice_block %i32.loc17 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc17_30.1: ref %i32 = temporary_storage +// CHECK:STDOUT: %.loc17_30.2: ref %i32 = temporary %.loc17_30.1, %read.char.loc17 +// CHECK:STDOUT: %m: ref %i32 = bind_name m, %.loc17_30.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/access_modifers.carbon b/toolchain/check/testdata/class/access_modifers.carbon index 556cc69c269d..ac19ed573cdc 100644 --- a/toolchain/check/testdata/class/access_modifers.carbon +++ b/toolchain/check/testdata/class/access_modifers.carbon @@ -198,15 +198,26 @@ class A { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Circle { -// CHECK:STDOUT: %.loc5: %Circle.elem = field_decl radius, element0 [template] +// CHECK:STDOUT: %.loc5_21: %Circle.elem = field_decl radius, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_11: %Circle.elem = var_pattern %.loc5_21 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Circle.elem = var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %SOME_INTERNAL_CONSTANT.patt: %i32 = binding_pattern SOME_INTERNAL_CONSTANT +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc6_39: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_5, %impl.elem0 [template = constants.%Convert.bound.4e6] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc6_46.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc6_46.2: %i32 = converted %int_5, %.loc6_46.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %SOME_INTERNAL_CONSTANT: %i32 = bind_name SOME_INTERNAL_CONSTANT, %.loc6_46.2 +// CHECK:STDOUT: %.loc6_45.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc6_45.2: %i32 = converted %int_5, %.loc6_45.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %SOME_INTERNAL_CONSTANT: %i32 = bind_name SOME_INTERNAL_CONSTANT, %.loc6_45.2 // CHECK:STDOUT: %SomeInternalFunction.decl: %SomeInternalFunction.type = fn_decl @SomeInternalFunction [template = constants.%SomeInternalFunction] { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 @@ -258,23 +269,33 @@ class A { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Circle.ref: type = name_ref Circle, file.%Circle.decl [template = constants.%Circle] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %circle.patt: %Circle = binding_pattern circle +// CHECK:STDOUT: } +// CHECK:STDOUT: %Circle.ref.loc18_24: type = name_ref Circle, file.%Circle.decl [template = constants.%Circle] // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, @Circle.%Make.decl [template = constants.%Make] // CHECK:STDOUT: %.loc18_36.1: ref %Circle = temporary_storage // CHECK:STDOUT: %Make.call: init %Circle = call %Make.ref() to %.loc18_36.1 +// CHECK:STDOUT: %Circle.ref.loc18_15: type = name_ref Circle, file.%Circle.decl [template = constants.%Circle] // CHECK:STDOUT: %.loc18_36.2: ref %Circle = temporary %.loc18_36.1, %Make.call -// CHECK:STDOUT: %.loc18_36.3: %Circle = bind_value %.loc18_36.2 -// CHECK:STDOUT: %circle: %Circle = bind_name circle, %.loc18_36.3 -// CHECK:STDOUT: %circle.ref.loc26: %Circle = name_ref circle, %circle +// CHECK:STDOUT: %circle: ref %Circle = bind_name circle, %.loc18_36.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %radius.patt: %i32 = binding_pattern radius +// CHECK:STDOUT: } +// CHECK:STDOUT: %circle.ref.loc26: ref %Circle = name_ref circle, %circle // CHECK:STDOUT: %radius.ref.loc26: = name_ref radius, [template = ] +// CHECK:STDOUT: %.loc26: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %radius: %i32 = bind_name radius, -// CHECK:STDOUT: %circle.ref.loc34: %Circle = name_ref circle, %circle +// CHECK:STDOUT: %circle.ref.loc34: ref %Circle = name_ref circle, %circle // CHECK:STDOUT: %radius.ref.loc34: = name_ref radius, [template = ] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] // CHECK:STDOUT: assign %radius.ref.loc34, -// CHECK:STDOUT: %circle.ref.loc42: %Circle = name_ref circle, %circle +// CHECK:STDOUT: %circle.ref.loc42: ref %Circle = name_ref circle, %circle // CHECK:STDOUT: %SOME_INTERNAL_CONSTANT.ref: = name_ref SOME_INTERNAL_CONSTANT, [template = ] -// CHECK:STDOUT: %circle.ref.loc51: %Circle = name_ref circle, %circle +// CHECK:STDOUT: %circle.ref.loc51: ref %Circle = name_ref circle, %circle // CHECK:STDOUT: %SomeInternalFunction.ref: = name_ref SomeInternalFunction, [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -312,15 +333,26 @@ class A { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_18: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_13: %A.elem = var_pattern %.loc5_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type.1ec] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] +// CHECK:STDOUT: %.loc16: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: %i32 = bind_name x, // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -369,7 +401,11 @@ class A { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Circle { -// CHECK:STDOUT: %.loc5: %Circle.elem = field_decl radius, element0 [template] +// CHECK:STDOUT: %.loc5_21: %Circle.elem = field_decl radius, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_11: %Circle.elem = var_pattern %.loc5_21 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Circle.elem = var // CHECK:STDOUT: %GetRadius.decl: %GetRadius.type = fn_decl @GetRadius [template = constants.%GetRadius] { // CHECK:STDOUT: %self.patt: %Circle = binding_pattern self // CHECK:STDOUT: %self.param_patt: %Circle = value_param_pattern %self.patt, runtime_param0 @@ -414,7 +450,7 @@ class A { // CHECK:STDOUT: fn @GetRadius[%self.param_patt: %Circle]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Circle = name_ref self, %self -// CHECK:STDOUT: %radius.ref: %Circle.elem = name_ref radius, @Circle.%.loc5 [template = @Circle.%.loc5] +// CHECK:STDOUT: %radius.ref: %Circle.elem = name_ref radius, @Circle.%.loc5_21 [template = @Circle.%.loc5_21] // CHECK:STDOUT: %.loc8_16.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc8_16.2: %i32 = bind_value %.loc8_16.1 // CHECK:STDOUT: return %.loc8_16.2 @@ -473,21 +509,36 @@ class A { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl -// CHECK:STDOUT: .x = @__global_init.%x +// CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: %i32 = bind_name x, @__global_init.%x.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc5_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_5, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_17.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_17.2: %i32 = converted %int_5, %.loc5_17.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %x: %i32 = bind_name x, %.loc5_17.2 +// CHECK:STDOUT: %.loc5_16.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc5_16.2: %i32 = converted %int_5, %.loc5_16.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %x: %i32 = bind_name x, %.loc5_16.2 // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -496,7 +547,6 @@ class A { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %x.ref: %i32 = name_ref x, @A.%x -// CHECK:STDOUT: %x: %i32 = bind_name x, %x.ref // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -531,30 +581,60 @@ class A { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl -// CHECK:STDOUT: .x = @__global_init.%x -// CHECK:STDOUT: .y = @__global_init.%y +// CHECK:STDOUT: .x = %x +// CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: %i32 = bind_name x, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc24: type = splice_block %i32.loc24 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %y: %i32 = bind_name y, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5.loc5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc5_20: type = splice_block %i32.loc5 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc5: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc5: = bound_method %int_5.loc5, %impl.elem0.loc5 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn.loc5: = specific_function %Convert.bound.loc5, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked.loc5: init %i32 = call %Convert.specific_fn.loc5(%int_5.loc5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_27.1: %i32 = value_of_initializer %int.convert_checked.loc5 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_27.2: %i32 = converted %int_5.loc5, %.loc5_27.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %x: %i32 = bind_name x, %.loc5_27.2 +// CHECK:STDOUT: %.loc5_26.1: %i32 = value_of_initializer %int.convert_checked.loc5 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc5_26.2: %i32 = converted %int_5.loc5, %.loc5_26.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %x: %i32 = bind_name x, %.loc5_26.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5.loc6: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc6_18: type = splice_block %i32.loc6 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc6: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc6: = bound_method %int_5.loc6, %impl.elem0.loc6 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn.loc6: = specific_function %Convert.bound.loc6, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked.loc6: init %i32 = call %Convert.specific_fn.loc6(%int_5.loc6) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc6_25.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc6_25.2: %i32 = converted %int_5.loc6, %.loc6_25.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %y: %i32 = bind_name y, %.loc6_25.2 +// CHECK:STDOUT: %.loc6_24.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc6_24.2: %i32 = converted %int_5.loc6, %.loc6_24.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %y: %i32 = bind_name y, %.loc6_24.2 // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -563,10 +643,8 @@ class A { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %A.ref.loc16: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] -// CHECK:STDOUT: %x: %i32 = bind_name x, // CHECK:STDOUT: %A.ref.loc24: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %y.ref: = name_ref y, [template = ] -// CHECK:STDOUT: %y: %i32 = bind_name y, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/adapter/adapt.carbon b/toolchain/check/testdata/class/adapter/adapt.carbon index 1e3a2d9d368f..27f862bb53f8 100644 --- a/toolchain/check/testdata/class/adapter/adapt.carbon +++ b/toolchain/check/testdata/class/adapter/adapt.carbon @@ -99,8 +99,16 @@ interface I { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @SomeClass { -// CHECK:STDOUT: %.loc5: %SomeClass.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc6: %SomeClass.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc5_8: %SomeClass.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %SomeClass.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %SomeClass.elem = var +// CHECK:STDOUT: %.loc6_8: %SomeClass.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %SomeClass.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %SomeClass.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/adapter/adapt_copy.carbon b/toolchain/check/testdata/class/adapter/adapt_copy.carbon index 56dca0d13609..9af99f2190f4 100644 --- a/toolchain/check/testdata/class/adapter/adapt_copy.carbon +++ b/toolchain/check/testdata/class/adapter/adapt_copy.carbon @@ -86,7 +86,7 @@ class AdaptNoncopyableIndirect { fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect { // CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType] // CHECK:STDERR: var b: AdaptNoncopyableIndirect = a; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+4]]:37: note: in copy of `AdaptNoncopyableIndirect` [InCopy] // CHECK:STDERR: var b: AdaptNoncopyableIndirect = a; // CHECK:STDERR: ^ @@ -203,10 +203,15 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%c.param_patt: %AdaptCopyable) -> %AdaptCopyable { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %AdaptCopyable = binding_pattern d +// CHECK:STDOUT: %.loc11: %AdaptCopyable = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %AdaptCopyable = var d -// CHECK:STDOUT: %d: ref %AdaptCopyable = bind_name d, %d.var // CHECK:STDOUT: %c.ref: %AdaptCopyable = name_ref c, %c // CHECK:STDOUT: assign %d.var, %c.ref +// CHECK:STDOUT: %AdaptCopyable.ref.loc11: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable] +// CHECK:STDOUT: %d: ref %AdaptCopyable = bind_name d, %d.var // CHECK:STDOUT: %d.ref: ref %AdaptCopyable = name_ref d, %d // CHECK:STDOUT: %.loc12: %AdaptCopyable = bind_value %d.ref // CHECK:STDOUT: return %.loc12 @@ -214,8 +219,11 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.2a3) -> %return.param_patt: %tuple.type.2a3 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %tuple.type.2a3 = binding_pattern d +// CHECK:STDOUT: %.loc16_3.1: %tuple.type.2a3 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %tuple.type.2a3 = var d -// CHECK:STDOUT: %d: ref %tuple.type.2a3 = bind_name d, %d.var // CHECK:STDOUT: %c.ref: %tuple.type.2a3 = name_ref c, %c // CHECK:STDOUT: %tuple.elem0.loc16_33.1: %AdaptCopyable = tuple_access %c.ref, element0 // CHECK:STDOUT: %tuple.elem0.loc16_33.2: ref %AdaptCopyable = tuple_access %d.var, element0 @@ -224,8 +232,16 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: %tuple.elem1.loc16_33.2: ref %u32 = tuple_access %d.var, element1 // CHECK:STDOUT: %.loc16_33.2: init %u32 = initialize_from %tuple.elem1.loc16_33.1 to %tuple.elem1.loc16_33.2 // CHECK:STDOUT: %.loc16_33.3: init %tuple.type.2a3 = tuple_init (%.loc16_33.1, %.loc16_33.2) to %d.var -// CHECK:STDOUT: %.loc16_34: init %tuple.type.2a3 = converted %c.ref, %.loc16_33.3 -// CHECK:STDOUT: assign %d.var, %.loc16_34 +// CHECK:STDOUT: %.loc16_3.2: init %tuple.type.2a3 = converted %c.ref, %.loc16_33.3 +// CHECK:STDOUT: assign %d.var, %.loc16_3.2 +// CHECK:STDOUT: %.loc16_29.1: type = splice_block %.loc16_29.3 [template = constants.%tuple.type.2a3] { +// CHECK:STDOUT: %AdaptCopyable.ref.loc16: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable] +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %u32.loc16: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32] +// CHECK:STDOUT: %.loc16_29.2: %tuple.type.24b = tuple_literal (%AdaptCopyable.ref.loc16, %u32.loc16) +// CHECK:STDOUT: %.loc16_29.3: type = converted %.loc16_29.2, constants.%tuple.type.2a3 [template = constants.%tuple.type.2a3] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d: ref %tuple.type.2a3 = bind_name d, %d.var // CHECK:STDOUT: %d.ref: ref %tuple.type.2a3 = name_ref d, %d // CHECK:STDOUT: %tuple.elem0.loc17_10.1: ref %AdaptCopyable = tuple_access %d.ref, element0 // CHECK:STDOUT: %.loc17_10.1: %AdaptCopyable = bind_value %tuple.elem0.loc17_10.1 @@ -327,21 +343,26 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%c.param_patt: %AdaptTuple) -> %return.param_patt: %AdaptTuple { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %AdaptTuple = binding_pattern d +// CHECK:STDOUT: %.loc9_3.1: %AdaptTuple = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %AdaptTuple = var d -// CHECK:STDOUT: %d: ref %AdaptTuple = bind_name d, %d.var // CHECK:STDOUT: %c.ref: %AdaptTuple = name_ref c, %c -// CHECK:STDOUT: %.loc9_24.1: %tuple.type.d07 = as_compatible %c.ref -// CHECK:STDOUT: %tuple.elem0.loc9_24.1: %i32 = tuple_access %.loc9_24.1, element0 -// CHECK:STDOUT: %.loc9_24.2: ref %tuple.type.d07 = as_compatible %d.var -// CHECK:STDOUT: %tuple.elem0.loc9_24.2: ref %i32 = tuple_access %.loc9_24.2, element0 -// CHECK:STDOUT: %.loc9_24.3: init %i32 = initialize_from %tuple.elem0.loc9_24.1 to %tuple.elem0.loc9_24.2 -// CHECK:STDOUT: %tuple.elem1.loc9_24.1: %i32 = tuple_access %.loc9_24.1, element1 -// CHECK:STDOUT: %tuple.elem1.loc9_24.2: ref %i32 = tuple_access %.loc9_24.2, element1 -// CHECK:STDOUT: %.loc9_24.4: init %i32 = initialize_from %tuple.elem1.loc9_24.1 to %tuple.elem1.loc9_24.2 -// CHECK:STDOUT: %.loc9_24.5: init %tuple.type.d07 = tuple_init (%.loc9_24.3, %.loc9_24.4) to %.loc9_24.2 -// CHECK:STDOUT: %.loc9_24.6: init %AdaptTuple = as_compatible %.loc9_24.5 -// CHECK:STDOUT: %.loc9_24.7: init %AdaptTuple = converted %c.ref, %.loc9_24.6 -// CHECK:STDOUT: assign %d.var, %.loc9_24.7 +// CHECK:STDOUT: %.loc9_3.2: %tuple.type.d07 = as_compatible %c.ref +// CHECK:STDOUT: %tuple.elem0.loc9_3.1: %i32 = tuple_access %.loc9_3.2, element0 +// CHECK:STDOUT: %.loc9_3.3: ref %tuple.type.d07 = as_compatible %d.var +// CHECK:STDOUT: %tuple.elem0.loc9_3.2: ref %i32 = tuple_access %.loc9_3.3, element0 +// CHECK:STDOUT: %.loc9_3.4: init %i32 = initialize_from %tuple.elem0.loc9_3.1 to %tuple.elem0.loc9_3.2 +// CHECK:STDOUT: %tuple.elem1.loc9_3.1: %i32 = tuple_access %.loc9_3.2, element1 +// CHECK:STDOUT: %tuple.elem1.loc9_3.2: ref %i32 = tuple_access %.loc9_3.3, element1 +// CHECK:STDOUT: %.loc9_3.5: init %i32 = initialize_from %tuple.elem1.loc9_3.1 to %tuple.elem1.loc9_3.2 +// CHECK:STDOUT: %.loc9_3.6: init %tuple.type.d07 = tuple_init (%.loc9_3.4, %.loc9_3.5) to %.loc9_3.3 +// CHECK:STDOUT: %.loc9_3.7: init %AdaptTuple = as_compatible %.loc9_3.6 +// CHECK:STDOUT: %.loc9_3.8: init %AdaptTuple = converted %c.ref, %.loc9_3.7 +// CHECK:STDOUT: assign %d.var, %.loc9_3.8 +// CHECK:STDOUT: %AdaptTuple.ref.loc9: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple] +// CHECK:STDOUT: %d: ref %AdaptTuple = bind_name d, %d.var // CHECK:STDOUT: %d.ref: ref %AdaptTuple = name_ref d, %d // CHECK:STDOUT: %.loc10_11.1: ref %tuple.type.d07 = as_compatible %d.ref // CHECK:STDOUT: %tuple.elem0.loc10_11.1: ref %i32 = tuple_access %.loc10_11.1, element0 @@ -361,8 +382,11 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.f69) -> %return.param_patt: %tuple.type.f69 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %tuple.type.f69 = binding_pattern d +// CHECK:STDOUT: %.loc14_3.1: %tuple.type.f69 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %tuple.type.f69 = var d -// CHECK:STDOUT: %d: ref %tuple.type.f69 = bind_name d, %d.var // CHECK:STDOUT: %c.ref: %tuple.type.f69 = name_ref c, %c // CHECK:STDOUT: %tuple.elem0.loc14_30.1: %AdaptTuple = tuple_access %c.ref, element0 // CHECK:STDOUT: %.loc14_30.1: %tuple.type.d07 = as_compatible %tuple.elem0.loc14_30.1 @@ -381,8 +405,16 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: %tuple.elem1.loc14_30.4: ref %u32 = tuple_access %d.var, element1 // CHECK:STDOUT: %.loc14_30.8: init %u32 = initialize_from %tuple.elem1.loc14_30.3 to %tuple.elem1.loc14_30.4 // CHECK:STDOUT: %.loc14_30.9: init %tuple.type.f69 = tuple_init (%.loc14_30.7, %.loc14_30.8) to %d.var -// CHECK:STDOUT: %.loc14_31: init %tuple.type.f69 = converted %c.ref, %.loc14_30.9 -// CHECK:STDOUT: assign %d.var, %.loc14_31 +// CHECK:STDOUT: %.loc14_3.2: init %tuple.type.f69 = converted %c.ref, %.loc14_30.9 +// CHECK:STDOUT: assign %d.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_26.1: type = splice_block %.loc14_26.3 [template = constants.%tuple.type.f69] { +// CHECK:STDOUT: %AdaptTuple.ref.loc14: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple] +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %u32.loc14: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32] +// CHECK:STDOUT: %.loc14_26.2: %tuple.type.24b = tuple_literal (%AdaptTuple.ref.loc14, %u32.loc14) +// CHECK:STDOUT: %.loc14_26.3: type = converted %.loc14_26.2, constants.%tuple.type.f69 [template = constants.%tuple.type.f69] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d: ref %tuple.type.f69 = bind_name d, %d.var // CHECK:STDOUT: %d.ref: ref %tuple.type.f69 = name_ref d, %d // CHECK:STDOUT: %tuple.elem0.loc15_10.1: ref %AdaptTuple = tuple_access %d.ref, element0 // CHECK:STDOUT: %.loc15_10.1: ref %tuple.type.d07 = as_compatible %tuple.elem0.loc15_10.1 @@ -465,10 +497,15 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%a.param_patt: %AdaptNoncopyable) -> %return.param_patt: %AdaptNoncopyable { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %AdaptNoncopyable = binding_pattern b +// CHECK:STDOUT: %.loc17: %AdaptNoncopyable = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %AdaptNoncopyable = var b -// CHECK:STDOUT: %b: ref %AdaptNoncopyable = bind_name b, %b.var // CHECK:STDOUT: %a.ref: %AdaptNoncopyable = name_ref a, %a // CHECK:STDOUT: assign %b.var, +// CHECK:STDOUT: %AdaptNoncopyable.ref.loc17: type = name_ref AdaptNoncopyable, file.%AdaptNoncopyable.decl [template = constants.%AdaptNoncopyable] +// CHECK:STDOUT: %b: ref %AdaptNoncopyable = bind_name b, %b.var // CHECK:STDOUT: %b.ref: ref %AdaptNoncopyable = name_ref b, %b // CHECK:STDOUT: %.loc22: %AdaptNoncopyable = bind_value %b.ref // CHECK:STDOUT: return to %return @@ -543,16 +580,21 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @H(%a.param_patt: %AdaptNoncopyableIndirect) -> %return.param_patt: %AdaptNoncopyableIndirect { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %AdaptNoncopyableIndirect = binding_pattern b +// CHECK:STDOUT: %.loc20_3.1: %AdaptNoncopyableIndirect = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %AdaptNoncopyableIndirect = var b -// CHECK:STDOUT: %b: ref %AdaptNoncopyableIndirect = bind_name b, %b.var // CHECK:STDOUT: %a.ref: %AdaptNoncopyableIndirect = name_ref a, %a -// CHECK:STDOUT: %.loc20_38.1: %tuple.type.c9a = as_compatible %a.ref -// CHECK:STDOUT: %tuple.elem0.loc20_38.1: %i32 = tuple_access %.loc20_38.1, element0 -// CHECK:STDOUT: %.loc20_38.2: ref %tuple.type.c9a = as_compatible %b.var -// CHECK:STDOUT: %tuple.elem0.loc20_38.2: ref %i32 = tuple_access %.loc20_38.2, element0 -// CHECK:STDOUT: %.loc20_38.3: init %i32 = initialize_from %tuple.elem0.loc20_38.1 to %tuple.elem0.loc20_38.2 -// CHECK:STDOUT: %tuple.elem1.loc20: %Noncopyable = tuple_access %.loc20_38.1, element1 +// CHECK:STDOUT: %.loc20_3.2: %tuple.type.c9a = as_compatible %a.ref +// CHECK:STDOUT: %tuple.elem0.loc20_3.1: %i32 = tuple_access %.loc20_3.2, element0 +// CHECK:STDOUT: %.loc20_3.3: ref %tuple.type.c9a = as_compatible %b.var +// CHECK:STDOUT: %tuple.elem0.loc20_3.2: ref %i32 = tuple_access %.loc20_3.3, element0 +// CHECK:STDOUT: %.loc20_3.4: init %i32 = initialize_from %tuple.elem0.loc20_3.1 to %tuple.elem0.loc20_3.2 +// CHECK:STDOUT: %tuple.elem1.loc20: %Noncopyable = tuple_access %.loc20_3.2, element1 // CHECK:STDOUT: assign %b.var, +// CHECK:STDOUT: %AdaptNoncopyableIndirect.ref.loc20: type = name_ref AdaptNoncopyableIndirect, file.%AdaptNoncopyableIndirect.decl [template = constants.%AdaptNoncopyableIndirect] +// CHECK:STDOUT: %b: ref %AdaptNoncopyableIndirect = bind_name b, %b.var // CHECK:STDOUT: %b.ref: ref %AdaptNoncopyableIndirect = name_ref b, %b // CHECK:STDOUT: %.loc28_11.1: ref %tuple.type.c9a = as_compatible %b.ref // CHECK:STDOUT: %tuple.elem0.loc28_11.1: ref %i32 = tuple_access %.loc28_11.1, element0 @@ -651,21 +693,26 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @I(%g.param_patt: %AdaptStruct) -> %return.param_patt: %AdaptStruct { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %h.patt: %AdaptStruct = binding_pattern h +// CHECK:STDOUT: %.loc9_3.1: %AdaptStruct = var_pattern %h.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %h.var: ref %AdaptStruct = var h -// CHECK:STDOUT: %h: ref %AdaptStruct = bind_name h, %h.var // CHECK:STDOUT: %g.ref: %AdaptStruct = name_ref g, %g -// CHECK:STDOUT: %.loc9_25.1: %struct_type.e.f = as_compatible %g.ref -// CHECK:STDOUT: %.loc9_25.2: %i32 = struct_access %.loc9_25.1, element0 -// CHECK:STDOUT: %.loc9_25.3: ref %struct_type.e.f = as_compatible %h.var -// CHECK:STDOUT: %.loc9_25.4: ref %i32 = struct_access %.loc9_25.3, element0 -// CHECK:STDOUT: %.loc9_25.5: init %i32 = initialize_from %.loc9_25.2 to %.loc9_25.4 -// CHECK:STDOUT: %.loc9_25.6: %i32 = struct_access %.loc9_25.1, element1 -// CHECK:STDOUT: %.loc9_25.7: ref %i32 = struct_access %.loc9_25.3, element1 -// CHECK:STDOUT: %.loc9_25.8: init %i32 = initialize_from %.loc9_25.6 to %.loc9_25.7 -// CHECK:STDOUT: %.loc9_25.9: init %struct_type.e.f = struct_init (%.loc9_25.5, %.loc9_25.8) to %.loc9_25.3 -// CHECK:STDOUT: %.loc9_25.10: init %AdaptStruct = as_compatible %.loc9_25.9 -// CHECK:STDOUT: %.loc9_25.11: init %AdaptStruct = converted %g.ref, %.loc9_25.10 -// CHECK:STDOUT: assign %h.var, %.loc9_25.11 +// CHECK:STDOUT: %.loc9_3.2: %struct_type.e.f = as_compatible %g.ref +// CHECK:STDOUT: %.loc9_3.3: %i32 = struct_access %.loc9_3.2, element0 +// CHECK:STDOUT: %.loc9_3.4: ref %struct_type.e.f = as_compatible %h.var +// CHECK:STDOUT: %.loc9_3.5: ref %i32 = struct_access %.loc9_3.4, element0 +// CHECK:STDOUT: %.loc9_3.6: init %i32 = initialize_from %.loc9_3.3 to %.loc9_3.5 +// CHECK:STDOUT: %.loc9_3.7: %i32 = struct_access %.loc9_3.2, element1 +// CHECK:STDOUT: %.loc9_3.8: ref %i32 = struct_access %.loc9_3.4, element1 +// CHECK:STDOUT: %.loc9_3.9: init %i32 = initialize_from %.loc9_3.7 to %.loc9_3.8 +// CHECK:STDOUT: %.loc9_3.10: init %struct_type.e.f = struct_init (%.loc9_3.6, %.loc9_3.9) to %.loc9_3.4 +// CHECK:STDOUT: %.loc9_3.11: init %AdaptStruct = as_compatible %.loc9_3.10 +// CHECK:STDOUT: %.loc9_3.12: init %AdaptStruct = converted %g.ref, %.loc9_3.11 +// CHECK:STDOUT: assign %h.var, %.loc9_3.12 +// CHECK:STDOUT: %AdaptStruct.ref.loc9: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct] +// CHECK:STDOUT: %h: ref %AdaptStruct = bind_name h, %h.var // CHECK:STDOUT: %h.ref: ref %AdaptStruct = name_ref h, %h // CHECK:STDOUT: %.loc10_11.1: ref %struct_type.e.f = as_compatible %h.ref // CHECK:STDOUT: %.loc10_11.2: ref %i32 = struct_access %.loc10_11.1, element0 @@ -685,8 +732,11 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.80b) -> %return.param_patt: %tuple.type.80b { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %tuple.type.80b = binding_pattern d +// CHECK:STDOUT: %.loc14_3.1: %tuple.type.80b = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %tuple.type.80b = var d -// CHECK:STDOUT: %d: ref %tuple.type.80b = bind_name d, %d.var // CHECK:STDOUT: %c.ref: %tuple.type.80b = name_ref c, %c // CHECK:STDOUT: %tuple.elem0.loc14_31.1: %AdaptStruct = tuple_access %c.ref, element0 // CHECK:STDOUT: %.loc14_31.1: %struct_type.e.f = as_compatible %tuple.elem0.loc14_31.1 @@ -705,8 +755,16 @@ fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) { // CHECK:STDOUT: %tuple.elem1.loc14_31.2: ref %u32 = tuple_access %d.var, element1 // CHECK:STDOUT: %.loc14_31.12: init %u32 = initialize_from %tuple.elem1.loc14_31.1 to %tuple.elem1.loc14_31.2 // CHECK:STDOUT: %.loc14_31.13: init %tuple.type.80b = tuple_init (%.loc14_31.11, %.loc14_31.12) to %d.var -// CHECK:STDOUT: %.loc14_32: init %tuple.type.80b = converted %c.ref, %.loc14_31.13 -// CHECK:STDOUT: assign %d.var, %.loc14_32 +// CHECK:STDOUT: %.loc14_3.2: init %tuple.type.80b = converted %c.ref, %.loc14_31.13 +// CHECK:STDOUT: assign %d.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_27.1: type = splice_block %.loc14_27.3 [template = constants.%tuple.type.80b] { +// CHECK:STDOUT: %AdaptStruct.ref.loc14: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct] +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %u32.loc14: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32] +// CHECK:STDOUT: %.loc14_27.2: %tuple.type.24b = tuple_literal (%AdaptStruct.ref.loc14, %u32.loc14) +// CHECK:STDOUT: %.loc14_27.3: type = converted %.loc14_27.2, constants.%tuple.type.80b [template = constants.%tuple.type.80b] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d: ref %tuple.type.80b = bind_name d, %d.var // CHECK:STDOUT: %d.ref: ref %tuple.type.80b = name_ref d, %d // CHECK:STDOUT: %tuple.elem0.loc15_10.1: ref %AdaptStruct = tuple_access %d.ref, element0 // CHECK:STDOUT: %.loc15_10.1: ref %struct_type.e.f = as_compatible %tuple.elem0.loc15_10.1 diff --git a/toolchain/check/testdata/class/adapter/extend_adapt.carbon b/toolchain/check/testdata/class/adapter/extend_adapt.carbon index 9c16184fe40d..7b8bc8cbbeb9 100644 --- a/toolchain/check/testdata/class/adapter/extend_adapt.carbon +++ b/toolchain/check/testdata/class/adapter/extend_adapt.carbon @@ -205,8 +205,16 @@ fn F(a: IntAdapter) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @SomeClass { -// CHECK:STDOUT: %.loc7: %SomeClass.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc8: %SomeClass.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc7_8: %SomeClass.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc7_3: %SomeClass.elem = var_pattern %.loc7_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc7: ref %SomeClass.elem = var +// CHECK:STDOUT: %.loc8_8: %SomeClass.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc8_3: %SomeClass.elem = var_pattern %.loc8_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc8: ref %SomeClass.elem = var // CHECK:STDOUT: %StaticMemberFunction.decl: %StaticMemberFunction.type = fn_decl @StaticMemberFunction [template = constants.%StaticMemberFunction] {} {} // CHECK:STDOUT: %AdapterMethod.decl: %AdapterMethod.type = fn_decl @AdapterMethod [template = constants.%AdapterMethod] { // CHECK:STDOUT: %self.patt: %SomeClassAdapter = binding_pattern self @@ -365,8 +373,16 @@ fn F(a: IntAdapter) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @SomeClass { -// CHECK:STDOUT: %.loc5: %SomeClass.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc6: %SomeClass.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc5_8: %SomeClass.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %SomeClass.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %SomeClass.elem = var +// CHECK:STDOUT: %.loc6_8: %SomeClass.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %SomeClass.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %SomeClass.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -381,7 +397,7 @@ fn F(a: IntAdapter) -> i32 { // CHECK:STDOUT: fn @F(%a.param_patt: %SomeClassAdapter) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %SomeClassAdapter = name_ref a, %a -// CHECK:STDOUT: %b.ref: %SomeClass.elem = name_ref b, @SomeClass.%.loc6 [template = @SomeClass.%.loc6] +// CHECK:STDOUT: %b.ref: %SomeClass.elem = name_ref b, @SomeClass.%.loc6_8 [template = @SomeClass.%.loc6_8] // CHECK:STDOUT: %.loc21_11.1: %SomeClass = converted %a.ref, [template = ] // CHECK:STDOUT: %.loc21_11.2: %i32 = class_element_access , element1 [template = ] // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/class/adapter/fail_adapt_with_subobjects.carbon b/toolchain/check/testdata/class/adapter/fail_adapt_with_subobjects.carbon index 06d5edc415a5..055853d4c10a 100644 --- a/toolchain/check/testdata/class/adapter/fail_adapt_with_subobjects.carbon +++ b/toolchain/check/testdata/class/adapter/fail_adapt_with_subobjects.carbon @@ -154,7 +154,11 @@ class AdaptWithBaseAndFields { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: adapt_decl %i32 [template] -// CHECK:STDOUT: %.loc13: %AdaptWithField.elem = field_decl n, element [template] +// CHECK:STDOUT: %.loc13_8: %AdaptWithField.elem = field_decl n, element [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %AdaptWithField.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %AdaptWithField.elem = var // CHECK:STDOUT: complete_type_witness = // CHECK:STDOUT: } // CHECK:STDOUT: @@ -162,9 +166,21 @@ class AdaptWithBaseAndFields { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: adapt_decl %i32 [template] -// CHECK:STDOUT: %.loc25: %AdaptWithFields.elem = field_decl a, element [template] -// CHECK:STDOUT: %.loc26: %AdaptWithFields.elem = field_decl b, element [template] -// CHECK:STDOUT: %.loc27: %AdaptWithFields.elem = field_decl c, element [template] +// CHECK:STDOUT: %.loc25_8: %AdaptWithFields.elem = field_decl a, element [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc25_3: %AdaptWithFields.elem = var_pattern %.loc25_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc25: ref %AdaptWithFields.elem = var +// CHECK:STDOUT: %.loc26_8: %AdaptWithFields.elem = field_decl b, element [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc26_3: %AdaptWithFields.elem = var_pattern %.loc26_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc26: ref %AdaptWithFields.elem = var +// CHECK:STDOUT: %.loc27_8: %AdaptWithFields.elem = field_decl c, element [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc27_3: %AdaptWithFields.elem = var_pattern %.loc27_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc27: ref %AdaptWithFields.elem = var // CHECK:STDOUT: complete_type_witness = // CHECK:STDOUT: } // CHECK:STDOUT: @@ -208,7 +224,11 @@ class AdaptWithBaseAndFields { // CHECK:STDOUT: class @AdaptWithBaseAndFields { // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] // CHECK:STDOUT: %.loc7: %AdaptWithBaseAndFields.elem.767 = base_decl %Base.ref, element [template] -// CHECK:STDOUT: %.loc8: %AdaptWithBaseAndFields.elem.ddf = field_decl n, element [template] +// CHECK:STDOUT: %.loc8_8: %AdaptWithBaseAndFields.elem.ddf = field_decl n, element [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc8_3: %AdaptWithBaseAndFields.elem.ddf = var_pattern %.loc8_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %AdaptWithBaseAndFields.elem.ddf = var // CHECK:STDOUT: %.loc16_10: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc16_11: type = converted %.loc16_10, constants.%empty_struct_type [template = constants.%empty_struct_type] // CHECK:STDOUT: adapt_decl %.loc16_11 [template] diff --git a/toolchain/check/testdata/class/adapter/init_adapt.carbon b/toolchain/check/testdata/class/adapter/init_adapt.carbon index 4d8dca3e220d..fdebedd7898f 100644 --- a/toolchain/check/testdata/class/adapter/init_adapt.carbon +++ b/toolchain/check/testdata/class/adapter/init_adapt.carbon @@ -52,21 +52,21 @@ let a: C = {.a = 1, .b = 2}; // Cannot implicitly convert between a type and an adapter for the type. -// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `C` to `AdaptC` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:17: error: cannot implicitly convert from `C` to `AdaptC` [ImplicitAsConversionFailure] // CHECK:STDERR: let b: AdaptC = a; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:1: note: type `C` does not implement interface `Core.ImplicitAs(AdaptC)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:17: note: type `C` does not implement interface `Core.ImplicitAs(AdaptC)` [MissingImplInMemberAccessNote] // CHECK:STDERR: let b: AdaptC = a; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^ // CHECK:STDERR: let b: AdaptC = a; -// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `AdaptC` to `C` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:12: error: cannot implicitly convert from `AdaptC` to `C` [ImplicitAsConversionFailure] // CHECK:STDERR: let c: C = b; -// CHECK:STDERR: ^~~~~~~~~~~~~ -// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:1: note: type `AdaptC` does not implement interface `Core.ImplicitAs(C)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:12: note: type `AdaptC` does not implement interface `Core.ImplicitAs(C)` [MissingImplInMemberAccessNote] // CHECK:STDERR: let c: C = b; -// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: ^ // CHECK:STDERR: let c: C = b; @@ -76,19 +76,19 @@ fn MakeAdaptC() -> AdaptC; // CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `C` to `AdaptC` [ImplicitAsConversionFailure] // CHECK:STDERR: var d: AdaptC = MakeC(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:1: note: type `C` does not implement interface `Core.ImplicitAs(AdaptC)` [MissingImplInMemberAccessNote] // CHECK:STDERR: var d: AdaptC = MakeC(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: var d: AdaptC = MakeC(); // CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `AdaptC` to `C` [ImplicitAsConversionFailure] // CHECK:STDERR: var e: C = MakeAdaptC(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:1: note: type `AdaptC` does not implement interface `Core.ImplicitAs(C)` [MissingImplInMemberAccessNote] // CHECK:STDERR: var e: C = MakeAdaptC(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: var e: C = MakeAdaptC(); @@ -136,9 +136,9 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .AdaptC = %AdaptC.decl -// CHECK:STDOUT: .a = @__global_init.%a -// CHECK:STDOUT: .b = @__global_init.%b -// CHECK:STDOUT: .c = @__global_init.%c +// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .c = %c // CHECK:STDOUT: .MakeC = %MakeC.decl // CHECK:STDOUT: .MakeAdaptC = %MakeAdaptC.decl // CHECK:STDOUT: .d = %d @@ -147,6 +147,39 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %AdaptC.decl: type = class_decl @AdaptC [template = constants.%AdaptC] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %impl.elem0.loc13_27.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc13_27.1: = bound_method @__global_init.%int_1, %impl.elem0.loc13_27.1 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc13_27.1: = specific_function %Convert.bound.loc13_27.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc13_27.1: init %i32 = call %Convert.specific_fn.loc13_27.1(@__global_init.%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_27.1: init %i32 = converted @__global_init.%int_1, %int.convert_checked.loc13_27.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_27.2: ref %C = temporary_storage +// CHECK:STDOUT: %.loc13_27.3: ref %i32 = class_element_access %.loc13_27.2, element0 +// CHECK:STDOUT: %.loc13_27.4: init %i32 = initialize_from %.loc13_27.1 to %.loc13_27.3 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc13_27.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc13_27.2: = bound_method @__global_init.%int_2, %impl.elem0.loc13_27.2 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc13_27.2: = specific_function %Convert.bound.loc13_27.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc13_27.2: init %i32 = call %Convert.specific_fn.loc13_27.2(@__global_init.%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_27.5: init %i32 = converted @__global_init.%int_2, %int.convert_checked.loc13_27.2 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_27.6: ref %i32 = class_element_access %.loc13_27.2, element1 +// CHECK:STDOUT: %.loc13_27.7: init %i32 = initialize_from %.loc13_27.5 to %.loc13_27.6 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_27.8: init %C = class_init (%.loc13_27.4, %.loc13_27.7), %.loc13_27.2 [template = constants.%C.val] +// CHECK:STDOUT: %.loc13_27.9: ref %C = temporary %.loc13_27.2, %.loc13_27.8 +// CHECK:STDOUT: %.loc13_27.10: ref %C = converted @__global_init.%.loc13, %.loc13_27.9 +// CHECK:STDOUT: %a: ref %C = bind_name a, %.loc13_27.10 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %AdaptC = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %AdaptC.ref.loc15: type = name_ref AdaptC, %AdaptC.decl [template = constants.%AdaptC] +// CHECK:STDOUT: %b: ref %AdaptC = bind_name b, @__global_init.%.loc15_19.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref.loc17: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, @__global_init.%.loc17_14.2 // CHECK:STDOUT: %MakeC.decl: %MakeC.type = fn_decl @MakeC [template = constants.%MakeC] { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 @@ -163,15 +196,33 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: %return.param: ref %AdaptC = out_param runtime_param0 // CHECK:STDOUT: %return: ref %AdaptC = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %AdaptC = binding_pattern d +// CHECK:STDOUT: %.loc23: %AdaptC = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %AdaptC = var d +// CHECK:STDOUT: %AdaptC.ref.loc23: type = name_ref AdaptC, %AdaptC.decl [template = constants.%AdaptC] // CHECK:STDOUT: %d: ref %AdaptC = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %C = binding_pattern e +// CHECK:STDOUT: %.loc25: %C = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %C = var e +// CHECK:STDOUT: %C.ref.loc25: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %e: ref %C = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc6: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %C.elem = var +// CHECK:STDOUT: %.loc6_8: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %C.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -191,47 +242,25 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc13_27.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) -// CHECK:STDOUT: %impl.elem0.loc13_27.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc13_27.1: = bound_method %int_1, %impl.elem0.loc13_27.1 [template = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %Convert.specific_fn.loc13_27.1: = specific_function %Convert.bound.loc13_27.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc13_27.1: init %i32 = call %Convert.specific_fn.loc13_27.1(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_27.2: init %i32 = converted %int_1, %int.convert_checked.loc13_27.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_27.3: ref %C = temporary_storage -// CHECK:STDOUT: %.loc13_27.4: ref %i32 = class_element_access %.loc13_27.3, element0 -// CHECK:STDOUT: %.loc13_27.5: init %i32 = initialize_from %.loc13_27.2 to %.loc13_27.4 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc13_27.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc13_27.2: = bound_method %int_2, %impl.elem0.loc13_27.2 [template = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %Convert.specific_fn.loc13_27.2: = specific_function %Convert.bound.loc13_27.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc13_27.2: init %i32 = call %Convert.specific_fn.loc13_27.2(%int_2) [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_27.6: init %i32 = converted %int_2, %int.convert_checked.loc13_27.2 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_27.7: ref %i32 = class_element_access %.loc13_27.3, element1 -// CHECK:STDOUT: %.loc13_27.8: init %i32 = initialize_from %.loc13_27.6 to %.loc13_27.7 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_27.9: init %C = class_init (%.loc13_27.5, %.loc13_27.8), %.loc13_27.3 [template = constants.%C.val] -// CHECK:STDOUT: %.loc13_27.10: ref %C = temporary %.loc13_27.3, %.loc13_27.9 -// CHECK:STDOUT: %.loc13_28.1: ref %C = converted %.loc13_27.1, %.loc13_27.10 -// CHECK:STDOUT: %.loc13_28.2: %C = bind_value %.loc13_28.1 -// CHECK:STDOUT: %a: %C = bind_name a, %.loc13_28.2 -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a +// CHECK:STDOUT: %.loc13: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) +// CHECK:STDOUT: %a.ref: ref %C = name_ref a, file.%a // CHECK:STDOUT: %AdaptC.ref.loc15: type = name_ref AdaptC, file.%AdaptC.decl [template = constants.%AdaptC] -// CHECK:STDOUT: %.loc15_19.1: %AdaptC = as_compatible %a.ref -// CHECK:STDOUT: %.loc15_19.2: %AdaptC = converted %a.ref, %.loc15_19.1 -// CHECK:STDOUT: %b: %AdaptC = bind_name b, %.loc15_19.2 -// CHECK:STDOUT: %b.ref: %AdaptC = name_ref b, %b +// CHECK:STDOUT: %.loc15_19.1: ref %AdaptC = as_compatible %a.ref +// CHECK:STDOUT: %.loc15_19.2: ref %AdaptC = converted %a.ref, %.loc15_19.1 +// CHECK:STDOUT: %b.ref: ref %AdaptC = name_ref b, file.%b // CHECK:STDOUT: %C.ref.loc17: type = name_ref C, file.%C.decl [template = constants.%C] -// CHECK:STDOUT: %.loc17_14.1: %C = as_compatible %b.ref -// CHECK:STDOUT: %.loc17_14.2: %C = converted %b.ref, %.loc17_14.1 -// CHECK:STDOUT: %c: %C = bind_name c, %.loc17_14.2 +// CHECK:STDOUT: %.loc17_14.1: ref %C = as_compatible %b.ref +// CHECK:STDOUT: %.loc17_14.2: ref %C = converted %b.ref, %.loc17_14.1 // CHECK:STDOUT: %MakeC.ref: %MakeC.type = name_ref MakeC, file.%MakeC.decl [template = constants.%MakeC] -// CHECK:STDOUT: %.loc23_5: ref %AdaptC = splice_block file.%d.var {} -// CHECK:STDOUT: %MakeC.call: init %C = call %MakeC.ref() to %.loc23_5 +// CHECK:STDOUT: %.loc23_1: ref %AdaptC = splice_block file.%d.var {} +// CHECK:STDOUT: %MakeC.call: init %C = call %MakeC.ref() to %.loc23_1 // CHECK:STDOUT: %AdaptC.ref.loc23: type = name_ref AdaptC, file.%AdaptC.decl [template = constants.%AdaptC] // CHECK:STDOUT: %.loc23_25.1: init %AdaptC = as_compatible %MakeC.call // CHECK:STDOUT: %.loc23_25.2: init %AdaptC = converted %MakeC.call, %.loc23_25.1 // CHECK:STDOUT: assign file.%d.var, %.loc23_25.2 // CHECK:STDOUT: %MakeAdaptC.ref: %MakeAdaptC.type = name_ref MakeAdaptC, file.%MakeAdaptC.decl [template = constants.%MakeAdaptC] -// CHECK:STDOUT: %.loc25_5: ref %C = splice_block file.%e.var {} -// CHECK:STDOUT: %MakeAdaptC.call: init %AdaptC = call %MakeAdaptC.ref() to %.loc25_5 +// CHECK:STDOUT: %.loc25_1: ref %C = splice_block file.%e.var {} +// CHECK:STDOUT: %MakeAdaptC.call: init %AdaptC = call %MakeAdaptC.ref() to %.loc25_1 // CHECK:STDOUT: %C.ref.loc25: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %.loc25_25.1: init %C = as_compatible %MakeAdaptC.call // CHECK:STDOUT: %.loc25_25.2: init %C = converted %MakeAdaptC.call, %.loc25_25.1 @@ -283,9 +312,9 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .AdaptC = %AdaptC.decl -// CHECK:STDOUT: .a = @__global_init.%a -// CHECK:STDOUT: .b = @__global_init.%b -// CHECK:STDOUT: .c = @__global_init.%c +// CHECK:STDOUT: .a = %a +// CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .c = %c // CHECK:STDOUT: .MakeC = %MakeC.decl // CHECK:STDOUT: .MakeAdaptC = %MakeAdaptC.decl // CHECK:STDOUT: .d = %d @@ -294,6 +323,41 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %AdaptC.decl: type = class_decl @AdaptC [template = constants.%AdaptC] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %impl.elem0.loc13_27.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc13_27.1: = bound_method @__global_init.%int_1, %impl.elem0.loc13_27.1 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc13_27.1: = specific_function %Convert.bound.loc13_27.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc13_27.1: init %i32 = call %Convert.specific_fn.loc13_27.1(@__global_init.%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_27.1: init %i32 = converted @__global_init.%int_1, %int.convert_checked.loc13_27.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_27.2: ref %C = temporary_storage +// CHECK:STDOUT: %.loc13_27.3: ref %i32 = class_element_access %.loc13_27.2, element0 +// CHECK:STDOUT: %.loc13_27.4: init %i32 = initialize_from %.loc13_27.1 to %.loc13_27.3 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc13_27.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc13_27.2: = bound_method @__global_init.%int_2, %impl.elem0.loc13_27.2 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc13_27.2: = specific_function %Convert.bound.loc13_27.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc13_27.2: init %i32 = call %Convert.specific_fn.loc13_27.2(@__global_init.%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_27.5: init %i32 = converted @__global_init.%int_2, %int.convert_checked.loc13_27.2 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_27.6: ref %i32 = class_element_access %.loc13_27.2, element1 +// CHECK:STDOUT: %.loc13_27.7: init %i32 = initialize_from %.loc13_27.5 to %.loc13_27.6 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_27.8: init %C = class_init (%.loc13_27.4, %.loc13_27.7), %.loc13_27.2 [template = constants.%C.val] +// CHECK:STDOUT: %.loc13_27.9: ref %C = temporary %.loc13_27.2, %.loc13_27.8 +// CHECK:STDOUT: %.loc13_27.10: ref %C = converted @__global_init.%.loc13, %.loc13_27.9 +// CHECK:STDOUT: %a: ref %C = bind_name a, %.loc13_27.10 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %AdaptC = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %AdaptC.ref.loc24: type = name_ref AdaptC, %AdaptC.decl [template = constants.%AdaptC] +// CHECK:STDOUT: %.loc24: %AdaptC = converted @__global_init.%a.ref, [template = ] +// CHECK:STDOUT: %b: %AdaptC = bind_name b, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref.loc33: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc33: %C = converted @__global_init.%b.ref, [template = ] +// CHECK:STDOUT: %c: %C = bind_name c, // CHECK:STDOUT: %MakeC.decl: %MakeC.type = fn_decl @MakeC [template = constants.%MakeC] { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 @@ -310,15 +374,33 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: %return.param: ref %AdaptC = out_param runtime_param0 // CHECK:STDOUT: %return: ref %AdaptC = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %AdaptC = binding_pattern d +// CHECK:STDOUT: %.loc46: %AdaptC = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %AdaptC = var d +// CHECK:STDOUT: %AdaptC.ref.loc46: type = name_ref AdaptC, %AdaptC.decl [template = constants.%AdaptC] // CHECK:STDOUT: %d: ref %AdaptC = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %C = binding_pattern e +// CHECK:STDOUT: %.loc55: %C = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %C = var e +// CHECK:STDOUT: %C.ref.loc55: type = name_ref C, %C.decl [template = constants.%C] // CHECK:STDOUT: %e: ref %C = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc6: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %C.elem = var +// CHECK:STDOUT: %.loc6_8: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %C.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -338,42 +420,18 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc13_27.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) -// CHECK:STDOUT: %impl.elem0.loc13_27.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc13_27.1: = bound_method %int_1, %impl.elem0.loc13_27.1 [template = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %Convert.specific_fn.loc13_27.1: = specific_function %Convert.bound.loc13_27.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc13_27.1: init %i32 = call %Convert.specific_fn.loc13_27.1(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_27.2: init %i32 = converted %int_1, %int.convert_checked.loc13_27.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc13_27.3: ref %C = temporary_storage -// CHECK:STDOUT: %.loc13_27.4: ref %i32 = class_element_access %.loc13_27.3, element0 -// CHECK:STDOUT: %.loc13_27.5: init %i32 = initialize_from %.loc13_27.2 to %.loc13_27.4 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc13_27.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc13_27.2: = bound_method %int_2, %impl.elem0.loc13_27.2 [template = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %Convert.specific_fn.loc13_27.2: = specific_function %Convert.bound.loc13_27.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc13_27.2: init %i32 = call %Convert.specific_fn.loc13_27.2(%int_2) [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_27.6: init %i32 = converted %int_2, %int.convert_checked.loc13_27.2 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_27.7: ref %i32 = class_element_access %.loc13_27.3, element1 -// CHECK:STDOUT: %.loc13_27.8: init %i32 = initialize_from %.loc13_27.6 to %.loc13_27.7 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13_27.9: init %C = class_init (%.loc13_27.5, %.loc13_27.8), %.loc13_27.3 [template = constants.%C.val] -// CHECK:STDOUT: %.loc13_27.10: ref %C = temporary %.loc13_27.3, %.loc13_27.9 -// CHECK:STDOUT: %.loc13_28.1: ref %C = converted %.loc13_27.1, %.loc13_27.10 -// CHECK:STDOUT: %.loc13_28.2: %C = bind_value %.loc13_28.1 -// CHECK:STDOUT: %a: %C = bind_name a, %.loc13_28.2 -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %.loc24: %AdaptC = converted %a.ref, [template = ] -// CHECK:STDOUT: %b: %AdaptC = bind_name b, -// CHECK:STDOUT: %b.ref: %AdaptC = name_ref b, %b -// CHECK:STDOUT: %.loc33: %C = converted %b.ref, [template = ] -// CHECK:STDOUT: %c: %C = bind_name c, +// CHECK:STDOUT: %.loc13: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) +// CHECK:STDOUT: %a.ref: ref %C = name_ref a, file.%a +// CHECK:STDOUT: %b.ref: %AdaptC = name_ref b, file.%b // CHECK:STDOUT: %MakeC.ref: %MakeC.type = name_ref MakeC, file.%MakeC.decl [template = constants.%MakeC] // CHECK:STDOUT: %.loc46_23: ref %C = temporary_storage // CHECK:STDOUT: %MakeC.call: init %C = call %MakeC.ref() to %.loc46_23 -// CHECK:STDOUT: %.loc46_24: %AdaptC = converted %MakeC.call, [template = ] +// CHECK:STDOUT: %.loc46_1: %AdaptC = converted %MakeC.call, [template = ] // CHECK:STDOUT: assign file.%d.var, // CHECK:STDOUT: %MakeAdaptC.ref: %MakeAdaptC.type = name_ref MakeAdaptC, file.%MakeAdaptC.decl [template = constants.%MakeAdaptC] // CHECK:STDOUT: %.loc55_23: ref %AdaptC = temporary_storage // CHECK:STDOUT: %MakeAdaptC.call: init %AdaptC = call %MakeAdaptC.ref() to %.loc55_23 -// CHECK:STDOUT: %.loc55_24: %C = converted %MakeAdaptC.call, [template = ] +// CHECK:STDOUT: %.loc55_1: %C = converted %MakeAdaptC.call, [template = ] // CHECK:STDOUT: assign file.%e.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/base.carbon b/toolchain/check/testdata/class/base.carbon index 5abff4b389d3..88f8453669eb 100644 --- a/toolchain/check/testdata/class/base.carbon +++ b/toolchain/check/testdata/class/base.carbon @@ -132,7 +132,11 @@ class Derived { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc4: %Base.elem = field_decl b, element0 [template] +// CHECK:STDOUT: %.loc4_8: %Base.elem = field_decl b, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc4_3: %Base.elem = var_pattern %.loc4_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Base.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.b.0a3 [template = constants.%complete_type.ba8] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -140,7 +144,11 @@ class Derived { // CHECK:STDOUT: class @Derived { // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] // CHECK:STDOUT: %.loc8: %Derived.elem.69e = base_decl %Base.ref, element0 [template] -// CHECK:STDOUT: %.loc10: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc10_8: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: %Derived.elem.344 = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Derived.elem.344 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.d.f8f [template = constants.%complete_type.da6] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -176,14 +184,14 @@ class Derived { // CHECK:STDOUT: fn @Access(%d.param_patt: %Derived) -> %return.param_patt: %tuple.type.d07 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %d.ref.loc18_11: %Derived = name_ref d, %d -// CHECK:STDOUT: %d.ref.loc18_12: %Derived.elem.344 = name_ref d, @Derived.%.loc10 [template = @Derived.%.loc10] +// CHECK:STDOUT: %d.ref.loc18_12: %Derived.elem.344 = name_ref d, @Derived.%.loc10_8 [template = @Derived.%.loc10_8] // CHECK:STDOUT: %.loc18_12.1: ref %i32 = class_element_access %d.ref.loc18_11, element1 // CHECK:STDOUT: %.loc18_12.2: %i32 = bind_value %.loc18_12.1 // CHECK:STDOUT: %d.ref.loc18_16: %Derived = name_ref d, %d // CHECK:STDOUT: %base.ref: %Derived.elem.69e = name_ref base, @Derived.%.loc8 [template = @Derived.%.loc8] // CHECK:STDOUT: %.loc18_17.1: ref %Base = class_element_access %d.ref.loc18_16, element0 // CHECK:STDOUT: %.loc18_17.2: %Base = bind_value %.loc18_17.1 -// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc4 [template = @Base.%.loc4] +// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc4_8 [template = @Base.%.loc4_8] // CHECK:STDOUT: %.loc18_22.1: ref %i32 = class_element_access %.loc18_17.2, element0 // CHECK:STDOUT: %.loc18_22.2: %i32 = bind_value %.loc18_22.1 // CHECK:STDOUT: %.loc18_24.1: %tuple.type.d07 = tuple_literal (%.loc18_12.2, %.loc18_22.2) @@ -235,7 +243,11 @@ class Derived { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Derived { -// CHECK:STDOUT: %.loc7: %Derived.elem = field_decl d, element0 [template] +// CHECK:STDOUT: %.loc7_8: %Derived.elem = field_decl d, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc7_3: %Derived.elem = var_pattern %.loc7_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Derived.elem = var // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.d [template = constants.%complete_type.860] // CHECK:STDOUT: complete_type_witness = %complete_type diff --git a/toolchain/check/testdata/class/base_field.carbon b/toolchain/check/testdata/class/base_field.carbon index 7a90a40f08ff..79e2b3e362db 100644 --- a/toolchain/check/testdata/class/base_field.carbon +++ b/toolchain/check/testdata/class/base_field.carbon @@ -84,9 +84,21 @@ fn Access(p: Derived*) -> i32* { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc12: %Base.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %Base.elem = field_decl b, element1 [template] -// CHECK:STDOUT: %.loc14: %Base.elem = field_decl c, element2 [template] +// CHECK:STDOUT: %.loc12_8: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Base.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Base.elem = var +// CHECK:STDOUT: %.loc13_8: %Base.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Base.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Base.elem = var +// CHECK:STDOUT: %.loc14_8: %Base.elem = field_decl c, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc14_3: %Base.elem = var_pattern %.loc14_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc14: ref %Base.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.c [template = constants.%complete_type.ebc] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -94,8 +106,16 @@ fn Access(p: Derived*) -> i32* { // CHECK:STDOUT: class @Derived { // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] // CHECK:STDOUT: %.loc18: %Derived.elem.69e = base_decl %Base.ref, element0 [template] -// CHECK:STDOUT: %.loc20: %Derived.elem.344 = field_decl d, element1 [template] -// CHECK:STDOUT: %.loc21: %Derived.elem.344 = field_decl e, element2 [template] +// CHECK:STDOUT: %.loc20_8: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc20_3: %Derived.elem.344 = var_pattern %.loc20_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc20: ref %Derived.elem.344 = var +// CHECK:STDOUT: %.loc21_8: %Derived.elem.344 = field_decl e, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc21_3: %Derived.elem.344 = var_pattern %.loc21_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc21: ref %Derived.elem.344 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.d.e.6a7 [template = constants.%complete_type.401] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -104,7 +124,7 @@ fn Access(p: Derived*) -> i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p // CHECK:STDOUT: %.loc25_12: ref %Derived = deref %p.ref -// CHECK:STDOUT: %c.ref: %Base.elem = name_ref c, @Base.%.loc14 [template = @Base.%.loc14] +// CHECK:STDOUT: %c.ref: %Base.elem = name_ref c, @Base.%.loc14_8 [template = @Base.%.loc14_8] // CHECK:STDOUT: %.loc25_15.1: ref %Base = class_element_access %.loc25_12, element0 // CHECK:STDOUT: %.loc25_15.2: ref %Base = converted %.loc25_12, %.loc25_15.1 // CHECK:STDOUT: %.loc25_15.3: ref %i32 = class_element_access %.loc25_15.2, element2 diff --git a/toolchain/check/testdata/class/base_method.carbon b/toolchain/check/testdata/class/base_method.carbon index f2890f89b646..6c2ae4c9b287 100644 --- a/toolchain/check/testdata/class/base_method.carbon +++ b/toolchain/check/testdata/class/base_method.carbon @@ -101,7 +101,11 @@ fn Call(p: Derived*) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc12: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Base.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Base.elem = var // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %self.patt: %ptr.11f = binding_pattern self // CHECK:STDOUT: %self.param_patt: %ptr.11f = value_param_pattern %self.patt, runtime_param0 @@ -129,7 +133,7 @@ fn Call(p: Derived*) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %ptr.11f = name_ref self, %self.loc17 // CHECK:STDOUT: %.loc18_4: ref %Base = deref %self.ref -// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc12 [template = @Base.%.loc12] +// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc12_8 [template = @Base.%.loc12_8] // CHECK:STDOUT: %.loc18_10: ref %i32 = class_element_access %.loc18_4, element0 // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] diff --git a/toolchain/check/testdata/class/basic.carbon b/toolchain/check/testdata/class/basic.carbon index 9dfe16204e35..3a15bd69690d 100644 --- a/toolchain/check/testdata/class/basic.carbon +++ b/toolchain/check/testdata/class/basic.carbon @@ -133,7 +133,11 @@ fn Run() -> i32 { // CHECK:STDOUT: %return.param.loc16: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return.loc16: ref %i32 = return_slot %return.param.loc16 // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc18: %Class.elem = field_decl k, element0 [template] +// CHECK:STDOUT: %.loc18_8: %Class.elem = field_decl k, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc18_3: %Class.elem = var_pattern %.loc18_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.k [template = constants.%complete_type.954] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/complete_in_member_fn.carbon b/toolchain/check/testdata/class/complete_in_member_fn.carbon index 0c2e01721163..b0f2450cc796 100644 --- a/toolchain/check/testdata/class/complete_in_member_fn.carbon +++ b/toolchain/check/testdata/class/complete_in_member_fn.carbon @@ -59,7 +59,11 @@ class C { // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc14: %C.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc14_8: %C.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc14_3: %C.elem = var_pattern %.loc14_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -67,7 +71,7 @@ class C { // CHECK:STDOUT: fn @F(%c.param_patt: %C) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %a.ref: %C.elem = name_ref a, @C.%.loc14 [template = @C.%.loc14] +// CHECK:STDOUT: %a.ref: %C.elem = name_ref a, @C.%.loc14_8 [template = @C.%.loc14_8] // CHECK:STDOUT: %.loc12_31.1: ref %i32 = class_element_access %c.ref, element0 // CHECK:STDOUT: %.loc12_31.2: %i32 = bind_value %.loc12_31.1 // CHECK:STDOUT: return %.loc12_31.2 diff --git a/toolchain/check/testdata/class/compound_field.carbon b/toolchain/check/testdata/class/compound_field.carbon index aaa2316281b6..bb044d4dd457 100644 --- a/toolchain/check/testdata/class/compound_field.carbon +++ b/toolchain/check/testdata/class/compound_field.carbon @@ -151,9 +151,21 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc12: %Base.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %Base.elem = field_decl b, element1 [template] -// CHECK:STDOUT: %.loc14: %Base.elem = field_decl c, element2 [template] +// CHECK:STDOUT: %.loc12_8: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Base.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Base.elem = var +// CHECK:STDOUT: %.loc13_8: %Base.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Base.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Base.elem = var +// CHECK:STDOUT: %.loc14_8: %Base.elem = field_decl c, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc14_3: %Base.elem = var_pattern %.loc14_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc14: ref %Base.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.c [template = constants.%complete_type.ebc] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -161,8 +173,16 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: class @Derived { // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] // CHECK:STDOUT: %.loc18: %Derived.elem.69e = base_decl %Base.ref, element0 [template] -// CHECK:STDOUT: %.loc20: %Derived.elem.344 = field_decl d, element1 [template] -// CHECK:STDOUT: %.loc21: %Derived.elem.344 = field_decl e, element2 [template] +// CHECK:STDOUT: %.loc20_8: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc20_3: %Derived.elem.344 = var_pattern %.loc20_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc20: ref %Derived.elem.344 = var +// CHECK:STDOUT: %.loc21_8: %Derived.elem.344 = field_decl e, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc21_3: %Derived.elem.344 = var_pattern %.loc21_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc21: ref %Derived.elem.344 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.d.e.6a7 [template = constants.%complete_type.401] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -171,7 +191,7 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %d.ref.loc25_10: %Derived = name_ref d, %d // CHECK:STDOUT: %Derived.ref.loc25: type = name_ref Derived, file.%Derived.decl [template = constants.%Derived] -// CHECK:STDOUT: %d.ref.loc25_20: %Derived.elem.344 = name_ref d, @Derived.%.loc20 [template = @Derived.%.loc20] +// CHECK:STDOUT: %d.ref.loc25_20: %Derived.elem.344 = name_ref d, @Derived.%.loc20_8 [template = @Derived.%.loc20_8] // CHECK:STDOUT: %.loc25_11.1: ref %i32 = class_element_access %d.ref.loc25_10, element1 // CHECK:STDOUT: %.loc25_11.2: %i32 = bind_value %.loc25_11.1 // CHECK:STDOUT: return %.loc25_11.2 @@ -181,7 +201,7 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %d.ref: %Derived = name_ref d, %d // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] -// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc13 [template = @Base.%.loc13] +// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc13_8 [template = @Base.%.loc13_8] // CHECK:STDOUT: %.loc29_11.1: ref %Base = class_element_access %d.ref, element0 // CHECK:STDOUT: %.loc29_11.2: ref %Base = converted %d.ref, %.loc29_11.1 // CHECK:STDOUT: %.loc29_11.3: ref %i32 = class_element_access %.loc29_11.2, element1 @@ -193,7 +213,7 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p // CHECK:STDOUT: %Derived.ref.loc33: type = name_ref Derived, file.%Derived.decl [template = constants.%Derived] -// CHECK:STDOUT: %d.ref: %Derived.elem.344 = name_ref d, @Derived.%.loc20 [template = @Derived.%.loc20] +// CHECK:STDOUT: %d.ref: %Derived.elem.344 = name_ref d, @Derived.%.loc20_8 [template = @Derived.%.loc20_8] // CHECK:STDOUT: %.loc33_12.1: ref %Derived = deref %p.ref // CHECK:STDOUT: %.loc33_12.2: ref %i32 = class_element_access %.loc33_12.1, element1 // CHECK:STDOUT: %addr: %ptr.235 = addr_of %.loc33_12.2 @@ -204,7 +224,7 @@ fn AccessBaseIndirect(p: Derived*) -> i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p // CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [template = constants.%Base] -// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc13 [template = @Base.%.loc13] +// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc13_8 [template = @Base.%.loc13_8] // CHECK:STDOUT: %.loc37_12.1: ref %Derived = deref %p.ref // CHECK:STDOUT: %.loc37_12.2: ref %Base = class_element_access %.loc37_12.1, element0 // CHECK:STDOUT: %.loc37_12.3: ref %Base = converted %.loc37_12.1, %.loc37_12.2 diff --git a/toolchain/check/testdata/class/cross_package_import.carbon b/toolchain/check/testdata/class/cross_package_import.carbon index 6dcef1f2b8d6..6cad56964262 100644 --- a/toolchain/check/testdata/class/cross_package_import.carbon +++ b/toolchain/check/testdata/class/cross_package_import.carbon @@ -199,6 +199,7 @@ var c: Other.C = {}; // CHECK:STDOUT: .C = %import_ref.3b0 // CHECK:STDOUT: import Other//other_define // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3b0: type = import_ref Other//other_define, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.8f2: = import_ref Other//other_define, loc4_10, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -210,7 +211,15 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc6_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -222,14 +231,15 @@ var c: Other.C = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_19.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_19.2: init %C = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_20: init %C = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_20 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_extern.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -242,6 +252,7 @@ var c: Other.C = {}; // CHECK:STDOUT: .C = %import_ref // CHECK:STDOUT: import Other//other_extern // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref: type = import_ref Other//other_extern, C, loaded [template = constants.%C] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -252,8 +263,16 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc14_1: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: %.loc14_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref [template = constants.%C] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C [from "other_extern.carbon"]; @@ -284,6 +303,7 @@ var c: Other.C = {}; // CHECK:STDOUT: import Other//other_define // CHECK:STDOUT: import Other//other_extern // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3b0: type = import_ref Other//other_define, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.8f2: = import_ref Other//other_define, loc4_10, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -295,7 +315,15 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc19_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc19_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -307,8 +335,8 @@ var c: Other.C = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc19_19.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc19_19.2: init %C = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc19_20: init %C = converted %.loc19_19.1, %.loc19_19.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc19_20 +// CHECK:STDOUT: %.loc19_1: init %C = converted %.loc19_19.1, %.loc19_19.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc19_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -331,6 +359,7 @@ var c: Other.C = {}; // CHECK:STDOUT: import Other//other_define // CHECK:STDOUT: import Other//other_conflict // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3b0: type = import_ref Other//other_define, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.8f2: = import_ref Other//other_define, loc4_10, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -342,7 +371,15 @@ var c: Other.C = {}; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc19_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc19_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -354,8 +391,8 @@ var c: Other.C = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc19_19.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc19_19.2: init %C = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc19_20: init %C = converted %.loc19_19.1, %.loc19_19.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc19_20 +// CHECK:STDOUT: %.loc19_1: init %C = converted %.loc19_19.1, %.loc19_19.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc19_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/derived_to_base.carbon b/toolchain/check/testdata/class/derived_to_base.carbon index 6f9947c22bf8..58d3501593a3 100644 --- a/toolchain/check/testdata/class/derived_to_base.carbon +++ b/toolchain/check/testdata/class/derived_to_base.carbon @@ -202,7 +202,11 @@ fn ConvertInit() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc12: %A.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: %A.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %A.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.ba9 [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -210,7 +214,11 @@ fn ConvertInit() { // CHECK:STDOUT: class @B { // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %.loc16: %B.elem.e38 = base_decl %A.ref, element0 [template] -// CHECK:STDOUT: %.loc17: %B.elem.5c3 = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc17_8: %B.elem.5c3 = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc17_3: %B.elem.5c3 = var_pattern %.loc17_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem.5c3 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.b.b44 [template = constants.%complete_type.725] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -218,7 +226,11 @@ fn ConvertInit() { // CHECK:STDOUT: class @C { // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] // CHECK:STDOUT: %.loc21: %C.elem.f0c = base_decl %B.ref, element0 [template] -// CHECK:STDOUT: %.loc22: %C.elem.646 = field_decl c, element1 [template] +// CHECK:STDOUT: %.loc22_8: %C.elem.646 = field_decl c, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc22_3: %C.elem.646 = var_pattern %.loc22_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem.646 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.c.8e2 [template = constants.%complete_type.58a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -256,12 +268,15 @@ fn ConvertInit() { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConvertValue(%c.param_patt: %C) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %.loc30_15.1: ref %B = class_element_access %c.ref, element0 -// CHECK:STDOUT: %.loc30_15.2: ref %A = class_element_access %.loc30_15.1, element0 -// CHECK:STDOUT: %.loc30_15.3: ref %A = converted %c.ref, %.loc30_15.2 -// CHECK:STDOUT: %.loc30_15.4: %A = bind_value %.loc30_15.3 -// CHECK:STDOUT: %a: %A = bind_name a, %.loc30_15.4 +// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %.loc30_14.1: ref %B = class_element_access %c.ref, element0 +// CHECK:STDOUT: %.loc30_14.2: ref %A = class_element_access %.loc30_14.1, element0 +// CHECK:STDOUT: %.loc30_14.3: ref %A = converted %c.ref, %.loc30_14.2 +// CHECK:STDOUT: %a: ref %A = bind_name a, %.loc30_14.3 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -279,6 +294,9 @@ fn ConvertInit() { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConvertInit() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc38_39.1: %struct_type.a.a6c = struct_literal (%int_1) // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] @@ -316,12 +334,12 @@ fn ConvertInit() { // CHECK:STDOUT: %.loc38_57.7: init %i32 = initialize_from %.loc38_57.5 to %.loc38_57.6 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc38_57.8: init %C = class_init (%.loc38_57.4, %.loc38_57.7), %.loc38_57.2 [template = constants.%C.val] // CHECK:STDOUT: %.loc38_57.9: ref %C = temporary %.loc38_57.2, %.loc38_57.8 -// CHECK:STDOUT: %.loc38_59: ref %C = converted %.loc38_57.1, %.loc38_57.9 -// CHECK:STDOUT: %.loc38_63.1: ref %B = class_element_access %.loc38_59, element0 -// CHECK:STDOUT: %.loc38_63.2: ref %A = class_element_access %.loc38_63.1, element0 -// CHECK:STDOUT: %.loc38_63.3: ref %A = converted %.loc38_59, %.loc38_63.2 -// CHECK:STDOUT: %.loc38_63.4: %A = bind_value %.loc38_63.3 -// CHECK:STDOUT: %a: %A = bind_name a, %.loc38_63.4 +// CHECK:STDOUT: %.loc38_59.1: ref %C = converted %.loc38_57.1, %.loc38_57.9 +// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %.loc38_59.2: ref %B = class_element_access %.loc38_59.1, element0 +// CHECK:STDOUT: %.loc38_59.3: ref %A = class_element_access %.loc38_59.2, element0 +// CHECK:STDOUT: %.loc38_59.4: ref %A = converted %.loc38_59.1, %.loc38_59.3 +// CHECK:STDOUT: %a: ref %A = bind_name a, %.loc38_59.4 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_abstract.carbon b/toolchain/check/testdata/class/fail_abstract.carbon index 81fa095f5006..9ba6268d9472 100644 --- a/toolchain/check/testdata/class/fail_abstract.carbon +++ b/toolchain/check/testdata/class/fail_abstract.carbon @@ -16,7 +16,7 @@ abstract class Abstract { } class Contains { - // CHECK:STDERR: fail_abstract_field.carbon:[[@LINE+7]]:10: error: field has abstract type `Abstract` [AbstractTypeInVarDecl] + // CHECK:STDERR: fail_abstract_field.carbon:[[@LINE+7]]:10: error: field has abstract type `Abstract` [AbstractTypeInFieldDecl] // CHECK:STDERR: var a: Abstract; // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_abstract_field.carbon:[[@LINE-7]]:1: note: class was declared abstract here [ClassAbstractHere] @@ -222,7 +222,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Contains { -// CHECK:STDOUT: %.loc15: = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc15_8: = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc15_3: = var_pattern %.loc15_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref = var // CHECK:STDOUT: %complete_type: = complete_type_witness [template = ] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -262,8 +266,13 @@ fn CallReturnAbstract() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Var() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: %.loc15: = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref = var v -// CHECK:STDOUT: %v: ref = bind_name v, %v.var +// CHECK:STDOUT: %Abstract.ref: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] +// CHECK:STDOUT: %v: = bind_name v, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -297,7 +306,7 @@ fn CallReturnAbstract() { // CHECK:STDOUT: %a.param_patt: %Abstract = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %a.param: %Abstract = value_param runtime_param0 -// CHECK:STDOUT: %Abstract.ref: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] +// CHECK:STDOUT: %Abstract.ref.loc7: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] // CHECK:STDOUT: %a: %Abstract = bind_name a, %a.param // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -309,7 +318,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %Abstract) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %l.patt: %Abstract = binding_pattern l +// CHECK:STDOUT: } // CHECK:STDOUT: %a.ref: %Abstract = name_ref a, %a +// CHECK:STDOUT: %Abstract.ref.loc8: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] // CHECK:STDOUT: %l: %Abstract = bind_name l, // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -472,7 +485,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: class @Derived { // CHECK:STDOUT: %Abstract.ref: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] // CHECK:STDOUT: %.loc8: %Derived.elem.513 = base_decl %Abstract.ref, element0 [template] -// CHECK:STDOUT: %.loc10: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc10_8: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: %Derived.elem.344 = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Derived.elem.344 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.d.c44 [template = constants.%complete_type.32a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -544,7 +561,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: class @Derived { // CHECK:STDOUT: %Abstract.ref: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] // CHECK:STDOUT: %.loc8: %Derived.elem.513 = base_decl %Abstract.ref, element0 [template] -// CHECK:STDOUT: %.loc10: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc10_8: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: %Derived.elem.344 = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Derived.elem.344 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.d [template = constants.%complete_type.32a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -608,7 +629,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Abstract { -// CHECK:STDOUT: %.loc5: %Abstract.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc5_8: %Abstract.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %Abstract.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Abstract.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -616,7 +641,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: class @Derived { // CHECK:STDOUT: %Abstract.ref: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] // CHECK:STDOUT: %.loc9: %Derived.elem.513 = base_decl %Abstract.ref, element0 [template] -// CHECK:STDOUT: %.loc11: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc11_8: %Derived.elem.344 = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc11_3: %Derived.elem.344 = var_pattern %.loc11_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Derived.elem.344 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.d.c44 [template = constants.%complete_type.32a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -665,7 +694,11 @@ fn CallReturnAbstract() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %l.patt: %Abstract = binding_pattern l +// CHECK:STDOUT: } // CHECK:STDOUT: %.loc8: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %Abstract.ref: type = name_ref Abstract, file.%Abstract.decl [template = constants.%Abstract] // CHECK:STDOUT: %l: %Abstract = bind_name l, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_base_bad_type.carbon b/toolchain/check/testdata/class/fail_base_bad_type.carbon index 2d768ab66ca5..64ce3f397fa6 100644 --- a/toolchain/check/testdata/class/fail_base_bad_type.carbon +++ b/toolchain/check/testdata/class/fail_base_bad_type.carbon @@ -796,7 +796,11 @@ fn AccessMemberWithInvalidBaseFinal_NoMember(p: DeriveFromFinal*) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Final { -// CHECK:STDOUT: %.loc5: %Final.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc5_8: %Final.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %Final.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Final.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -822,7 +826,7 @@ fn AccessMemberWithInvalidBaseFinal_NoMember(p: DeriveFromFinal*) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %p.ref: %ptr.160 = name_ref p, %p // CHECK:STDOUT: %.loc22_11: ref %DeriveFromFinal = deref %p.ref -// CHECK:STDOUT: %a.ref: %Final.elem = name_ref a, @Final.%.loc5 [template = @Final.%.loc5] +// CHECK:STDOUT: %a.ref: %Final.elem = name_ref a, @Final.%.loc5_8 [template = @Final.%.loc5_8] // CHECK:STDOUT: %.loc22_14.1: ref %Final = class_element_access %.loc22_11, element0 // CHECK:STDOUT: %.loc22_14.2: ref %Final = converted %.loc22_11, %.loc22_14.1 // CHECK:STDOUT: %.loc22_14.3: ref %i32 = class_element_access %.loc22_14.2, element0 diff --git a/toolchain/check/testdata/class/fail_base_unbound.carbon b/toolchain/check/testdata/class/fail_base_unbound.carbon index 5c714270d034..f7e2db9ed437 100644 --- a/toolchain/check/testdata/class/fail_base_unbound.carbon +++ b/toolchain/check/testdata/class/fail_base_unbound.carbon @@ -44,11 +44,16 @@ let b: B = C.base; // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .B = %B.decl // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .b = @__global_init.%b +// CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %B = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B] +// CHECK:STDOUT: %b: %B = bind_name b, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @B { @@ -67,7 +72,6 @@ let b: B = C.base; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %base.ref: %C.elem = name_ref base, @C.%.loc14 [template = @C.%.loc14] -// CHECK:STDOUT: %b: %B = bind_name b, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon b/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon index 453fc7ce4fe5..60c1a86bc6b6 100644 --- a/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon +++ b/toolchain/check/testdata/class/fail_compound_type_mismatch.carbon @@ -80,13 +80,21 @@ fn AccessBInA(a: A) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc12: %A.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: %A.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %A.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @B { -// CHECK:STDOUT: %.loc16: %B.elem = field_decl b, element0 [template] +// CHECK:STDOUT: %.loc16_8: %B.elem = field_decl b, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc16_3: %B.elem = var_pattern %.loc16_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.b [template = constants.%complete_type.ba8] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -95,7 +103,7 @@ fn AccessBInA(a: A) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %A = name_ref a, %a // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] -// CHECK:STDOUT: %b.ref: %B.elem = name_ref b, @B.%.loc16 [template = @B.%.loc16] +// CHECK:STDOUT: %b.ref: %B.elem = name_ref b, @B.%.loc16_8 [template = @B.%.loc16_8] // CHECK:STDOUT: %.loc27_11.1: %B = converted %a.ref, [template = ] // CHECK:STDOUT: %.loc27_11.2: %i32 = class_element_access , element0 [template = ] // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/class/fail_convert_to_invalid.carbon b/toolchain/check/testdata/class/fail_convert_to_invalid.carbon index c3c8b763ff43..82d83ad80b7d 100644 --- a/toolchain/check/testdata/class/fail_convert_to_invalid.carbon +++ b/toolchain/check/testdata/class/fail_convert_to_invalid.carbon @@ -56,7 +56,11 @@ fn Make() -> C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc16: = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc16_8: = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc16_3: = var_pattern %.loc16_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref = var // CHECK:STDOUT: %complete_type: = complete_type_witness [template = ] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_derived_to_base.carbon b/toolchain/check/testdata/class/fail_derived_to_base.carbon index dfb9ccd9c9f7..83ff2d0dd5e0 100644 --- a/toolchain/check/testdata/class/fail_derived_to_base.carbon +++ b/toolchain/check/testdata/class/fail_derived_to_base.carbon @@ -129,13 +129,21 @@ fn ConvertIncomplete(p: Incomplete*) -> A2* { return p; } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A1 { -// CHECK:STDOUT: %.loc12: %A1.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: %A1.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %A1.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A1.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A2 { -// CHECK:STDOUT: %.loc16: %A2.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc16_8: %A2.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc16_3: %A2.elem = var_pattern %.loc16_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A2.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -143,7 +151,11 @@ fn ConvertIncomplete(p: Incomplete*) -> A2* { return p; } // CHECK:STDOUT: class @B2 { // CHECK:STDOUT: %A2.ref: type = name_ref A2, file.%A2.decl [template = constants.%A2] // CHECK:STDOUT: %.loc20: %B2.elem.a92 = base_decl %A2.ref, element0 [template] -// CHECK:STDOUT: %.loc21: %B2.elem.4b2 = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc21_8: %B2.elem.4b2 = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc21_3: %B2.elem.4b2 = var_pattern %.loc21_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B2.elem.4b2 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.base.b.618 [template = constants.%complete_type.92f] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_extend_cycle.carbon b/toolchain/check/testdata/class/fail_extend_cycle.carbon index 1c2091fd97eb..ab29dacab3d8 100644 --- a/toolchain/check/testdata/class/fail_extend_cycle.carbon +++ b/toolchain/check/testdata/class/fail_extend_cycle.carbon @@ -80,7 +80,11 @@ base class A { // CHECK:STDOUT: class @.1 { // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] // CHECK:STDOUT: %.loc27: %.elem = base_decl %A.ref, element0 [template] -// CHECK:STDOUT: %.loc32: = field_decl c, element1 [template] +// CHECK:STDOUT: %.loc32_8: = field_decl c, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc32_3: = var_pattern %.loc32_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref = var // CHECK:STDOUT: %complete_type: = complete_type_witness [template = ] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_field_modifiers.carbon b/toolchain/check/testdata/class/fail_field_modifiers.carbon index fc174d10cfda..19eba3cb0273 100644 --- a/toolchain/check/testdata/class/fail_field_modifiers.carbon +++ b/toolchain/check/testdata/class/fail_field_modifiers.carbon @@ -77,24 +77,46 @@ class Class { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc17: %Class.elem = field_decl j, element0 [template] -// CHECK:STDOUT: %.loc23: %Class.elem = field_decl k, element1 [template] +// CHECK:STDOUT: %.loc17_16: %Class.elem = field_decl j, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc17_11: %Class.elem = var_pattern %.loc17_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc17: ref %Class.elem = var +// CHECK:STDOUT: %.loc23_14: %Class.elem = field_decl k, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc23_9: %Class.elem = var_pattern %.loc23_14 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc23: ref %Class.elem = var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %l.patt: %i32 = binding_pattern l +// CHECK:STDOUT: } // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc29_18: type = splice_block %i32.loc29 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc29: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc29: = bound_method %int_0, %impl.elem0.loc29 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc29: = specific_function %Convert.bound.loc29, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc29: init %i32 = call %Convert.specific_fn.loc29(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc29_25.1: %i32 = value_of_initializer %int.convert_checked.loc29 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc29_25.2: %i32 = converted %int_0, %.loc29_25.1 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %l: %i32 = bind_name l, %.loc29_25.2 +// CHECK:STDOUT: %.loc29_24.1: %i32 = value_of_initializer %int.convert_checked.loc29 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc29_24.2: %i32 = converted %int_0, %.loc29_24.1 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %l: %i32 = bind_name l, %.loc29_24.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %m.patt: %i32 = binding_pattern m +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc35_16: type = splice_block %i32.loc35 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc35: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc35: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc35: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc35: = bound_method %int_1, %impl.elem0.loc35 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc35: = specific_function %Convert.bound.loc35, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc35: init %i32 = call %Convert.specific_fn.loc35(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc35_23.1: %i32 = value_of_initializer %int.convert_checked.loc35 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc35_23.2: %i32 = converted %int_1, %.loc35_23.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %m: %i32 = bind_name m, %.loc35_23.2 +// CHECK:STDOUT: %.loc35_22.1: %i32 = value_of_initializer %int.convert_checked.loc35 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc35_22.2: %i32 = converted %int_1, %.loc35_22.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %m: %i32 = bind_name m, %.loc35_22.2 // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.j.k [template = constants.%complete_type.cf7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_generic_method.carbon b/toolchain/check/testdata/class/fail_generic_method.carbon index fcdfbe2f5404..a2fb77f29fa1 100644 --- a/toolchain/check/testdata/class/fail_generic_method.carbon +++ b/toolchain/check/testdata/class/fail_generic_method.carbon @@ -110,7 +110,11 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: %complete_type.loc14_1.2: = complete_type_witness @Class.%struct_type.a (%struct_type.a) [symbolic = %complete_type.loc14_1.2 (constants.%complete_type.f1b)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc12: @Class.%Class.elem (%Class.elem) = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: @Class.%Class.elem (%Class.elem) = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: @Class.%Class.elem (%Class.elem) = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem) = var // CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = @Class.%F (constants.%F)] { // CHECK:STDOUT: %self.patt: @F.%Class (%Class) = binding_pattern self // CHECK:STDOUT: %self.param_patt: @F.%Class (%Class) = value_param_pattern %self.patt, runtime_param0 diff --git a/toolchain/check/testdata/class/fail_import_misuses.carbon b/toolchain/check/testdata/class/fail_import_misuses.carbon index 5df8a33ad997..ffb3f1ae7de9 100644 --- a/toolchain/check/testdata/class/fail_import_misuses.carbon +++ b/toolchain/check/testdata/class/fail_import_misuses.carbon @@ -108,8 +108,13 @@ var a: Incomplete; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.a95] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc25: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %Incomplete.ref: type = name_ref Incomplete, imports.%import_ref.9b0 [template = constants.%Incomplete] +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Empty [from "a.carbon"] { diff --git a/toolchain/check/testdata/class/fail_incomplete.carbon b/toolchain/check/testdata/class/fail_incomplete.carbon index 7adfa1de309f..b979c26d7f5d 100644 --- a/toolchain/check/testdata/class/fail_incomplete.carbon +++ b/toolchain/check/testdata/class/fail_incomplete.carbon @@ -164,7 +164,7 @@ fn CallIncompleteAddrSelf(p: Class*) { library "[[@TEST_NAME]]"; class C { - // CHECK:STDERR: fail_in_definition.carbon:[[@LINE+7]]:10: error: field has incomplete type `C` [IncompleteTypeInVarDecl] + // CHECK:STDERR: fail_in_definition.carbon:[[@LINE+7]]:10: error: field has incomplete type `C` [IncompleteTypeInFieldDecl] // CHECK:STDERR: var c: C; // CHECK:STDERR: ^ // CHECK:STDERR: fail_in_definition.carbon:[[@LINE-4]]:1: note: class is incomplete within its definition [ClassIncompleteWithinDefinition] @@ -243,8 +243,13 @@ class C { // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {} // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.d85] {} {} // CHECK:STDOUT: %CallClassFunction.decl: %CallClassFunction.type = fn_decl @CallClassFunction [template = constants.%CallClassFunction] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %global_var.patt: = binding_pattern global_var +// CHECK:STDOUT: %.loc33: = var_pattern %global_var.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %global_var.var: ref = var global_var -// CHECK:STDOUT: %global_var: ref = bind_name global_var, %global_var.var +// CHECK:STDOUT: %Class.ref: type = name_ref Class, %Class.decl [template = constants.%Class] +// CHECK:STDOUT: %global_var: = bind_name global_var, // CHECK:STDOUT: %ConvertFromStruct.decl: %ConvertFromStruct.type = fn_decl @ConvertFromStruct [template = constants.%ConvertFromStruct] { // CHECK:STDOUT: %return.patt: %Class = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %Class = out_param_pattern %return.patt, runtime_param0 @@ -309,7 +314,7 @@ class C { // CHECK:STDOUT: } { // CHECK:STDOUT: %p.param: %ptr.e71 = value_param runtime_param0 // CHECK:STDOUT: %.loc77: type = splice_block %ptr [template = constants.%ptr.e71] { -// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] +// CHECK:STDOUT: %Class.ref.loc77: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %ptr: type = ptr_type %Class [template = constants.%ptr.e71] // CHECK:STDOUT: } // CHECK:STDOUT: %p: %ptr.e71 = bind_name p, %p.param @@ -416,8 +421,12 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: fn @Let(%p.param_patt: %ptr.e71) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: } // CHECK:STDOUT: %p.ref: %ptr.e71 = name_ref p, %p // CHECK:STDOUT: %.loc85: ref %Class = deref %p.ref +// CHECK:STDOUT: %Class.ref.loc85: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -482,7 +491,11 @@ class C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc12: = field_decl c, element0 [template] +// CHECK:STDOUT: %.loc12_8: = field_decl c, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref = var // CHECK:STDOUT: %complete_type: = complete_type_witness [template = ] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_init.carbon b/toolchain/check/testdata/class/fail_init.carbon index 41c788be0a3c..2bce4ac24f23 100644 --- a/toolchain/check/testdata/class/fail_init.carbon +++ b/toolchain/check/testdata/class/fail_init.carbon @@ -78,8 +78,16 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %Class.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Class.elem = var +// CHECK:STDOUT: %.loc13_8: %Class.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Class.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_init_as_inplace.carbon b/toolchain/check/testdata/class/fail_init_as_inplace.carbon index 66adc4e9ee77..f07cf5a8defd 100644 --- a/toolchain/check/testdata/class/fail_init_as_inplace.carbon +++ b/toolchain/check/testdata/class/fail_init_as_inplace.carbon @@ -91,8 +91,16 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %Class.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Class.elem = var +// CHECK:STDOUT: %.loc13_8: %Class.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Class.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -101,12 +109,15 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %Class = binding_pattern c +// CHECK:STDOUT: %.loc26_3: %Class = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %Class = var c -// CHECK:STDOUT: %c: ref %Class = bind_name c, %c.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc26_33.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) -// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] +// CHECK:STDOUT: %Class.ref.loc26_38: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %impl.elem0.loc26_33.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc26_33.1: = bound_method %int_1, %impl.elem0.loc26_33.1 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc26_33.1: = specific_function %Convert.bound.loc26_33.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] @@ -127,6 +138,8 @@ fn F() { // CHECK:STDOUT: %.loc26_35.1: ref %Class = converted %.loc26_33.1, %.loc26_33.10 // CHECK:STDOUT: %.loc26_35.2: %Class = bind_value %.loc26_35.1 // CHECK:STDOUT: assign %c.var, +// CHECK:STDOUT: %Class.ref.loc26_10: type = name_ref Class, file.%Class.decl [template = constants.%Class] +// CHECK:STDOUT: %c: ref %Class = bind_name c, %c.var // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [template = constants.%G] // CHECK:STDOUT: %c.ref: ref %Class = name_ref c, %c // CHECK:STDOUT: %addr: %ptr.e71 = addr_of %c.ref diff --git a/toolchain/check/testdata/class/fail_memaccess_category.carbon b/toolchain/check/testdata/class/fail_memaccess_category.carbon index b0d206d007b4..a4f772294079 100644 --- a/toolchain/check/testdata/class/fail_memaccess_category.carbon +++ b/toolchain/check/testdata/class/fail_memaccess_category.carbon @@ -110,7 +110,11 @@ fn F(s: {.a: A}, b: B) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @B { -// CHECK:STDOUT: %.loc16: %B.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc16_8: %B.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc16_3: %B.elem = var_pattern %.loc16_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.72c [template = constants.%complete_type.2b9] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -125,7 +129,7 @@ fn F(s: {.a: A}, b: B) { // CHECK:STDOUT: %F.bound.loc28: = bound_method %.loc28, %F.ref.loc28 // CHECK:STDOUT: %F.call.loc28: init %empty_tuple.type = call %F.bound.loc28() // CHECK:STDOUT: %b.ref: %B = name_ref b, %b -// CHECK:STDOUT: %a.ref: %B.elem = name_ref a, @B.%.loc16 [template = @B.%.loc16] +// CHECK:STDOUT: %a.ref: %B.elem = name_ref a, @B.%.loc16_8 [template = @B.%.loc16_8] // CHECK:STDOUT: %.loc39_4.1: ref %A = class_element_access %b.ref, element0 // CHECK:STDOUT: %.loc39_4.2: %A = bind_value %.loc39_4.1 // CHECK:STDOUT: %F.ref.loc39: %F.type.649 = name_ref F, @A.%F.decl [template = constants.%F.485] diff --git a/toolchain/check/testdata/class/fail_member_of_let.carbon b/toolchain/check/testdata/class/fail_member_of_let.carbon index f227873961e7..7cc39fd24d6a 100644 --- a/toolchain/check/testdata/class/fail_member_of_let.carbon +++ b/toolchain/check/testdata/class/fail_member_of_let.carbon @@ -52,10 +52,14 @@ fn T.F() {} // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl -// CHECK:STDOUT: .T = @__global_init.%T +// CHECK:STDOUT: .T = %T // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = binding_pattern T +// CHECK:STDOUT: } +// CHECK:STDOUT: %T: type = bind_name T, @__global_init.%Class.ref // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.d85] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -83,7 +87,6 @@ fn T.F() {} // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] -// CHECK:STDOUT: %T: type = bind_name T, %Class.ref // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_self.carbon b/toolchain/check/testdata/class/fail_self.carbon index 656a178316e7..c4eb6bd1a58b 100644 --- a/toolchain/check/testdata/class/fail_self.carbon +++ b/toolchain/check/testdata/class/fail_self.carbon @@ -159,7 +159,12 @@ fn CallWrongSelf(ws: WrongSelf) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return.param_patt: %Class { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %self.patt: %Class = binding_pattern self +// CHECK:STDOUT: %.loc33: %Class = var_pattern %self.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %self.var: ref %Class = var self +// CHECK:STDOUT: %Self.ref.loc33: type = name_ref Self, constants.%Class [template = constants.%Class] // CHECK:STDOUT: %self: ref %Class = bind_name self, %self.var // CHECK:STDOUT: %self.ref: ref %Class = name_ref self, %self // CHECK:STDOUT: %.loc38: %Class = bind_value %self.ref diff --git a/toolchain/check/testdata/class/fail_self_param.carbon b/toolchain/check/testdata/class/fail_self_param.carbon index 8a73a5ac3f2d..37be623c5cc0 100644 --- a/toolchain/check/testdata/class/fail_self_param.carbon +++ b/toolchain/check/testdata/class/fail_self_param.carbon @@ -23,6 +23,7 @@ var v: C(0); // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -47,8 +48,16 @@ var v: C(0); // CHECK:STDOUT: %self.ref: = name_ref self, [template = ] // CHECK:STDOUT: %x: = bind_symbolic_name x, 0, %x.param [template = ] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: %.loc16: = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref = var v -// CHECK:STDOUT: %v: ref = bind_name v, %v.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: = bind_name v, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @C(%x: ) { diff --git a/toolchain/check/testdata/class/fail_self_type_member.carbon b/toolchain/check/testdata/class/fail_self_type_member.carbon index a22737d3eb16..a6a7bbca9e9d 100644 --- a/toolchain/check/testdata/class/fail_self_type_member.carbon +++ b/toolchain/check/testdata/class/fail_self_type_member.carbon @@ -38,7 +38,11 @@ fn F() -> bool { // CHECK:STDOUT: file {} // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl b, element0 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl b, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.b [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_unbound_field.carbon b/toolchain/check/testdata/class/fail_unbound_field.carbon index bf0d1be4d999..c6101ffeda3f 100644 --- a/toolchain/check/testdata/class/fail_unbound_field.carbon +++ b/toolchain/check/testdata/class/fail_unbound_field.carbon @@ -70,7 +70,11 @@ fn G() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl field, element0 [template] +// CHECK:STDOUT: %.loc12_12: %Class.elem = field_decl field, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_12 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 @@ -86,14 +90,14 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %field.ref: %Class.elem = name_ref field, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %field.ref: %Class.elem = name_ref field, @Class.%.loc12_12 [template = @Class.%.loc12_12] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] -// CHECK:STDOUT: %field.ref: %Class.elem = name_ref field, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %field.ref: %Class.elem = name_ref field, @Class.%.loc12_12 [template = @Class.%.loc12_12] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/fail_unknown_member.carbon b/toolchain/check/testdata/class/fail_unknown_member.carbon index 42dfc06697cf..a96d8075c103 100644 --- a/toolchain/check/testdata/class/fail_unknown_member.carbon +++ b/toolchain/check/testdata/class/fail_unknown_member.carbon @@ -67,7 +67,11 @@ fn G(c: Class) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/field_access.carbon b/toolchain/check/testdata/class/field_access.carbon index 2bb9d2855079..5ca309f7ea2b 100644 --- a/toolchain/check/testdata/class/field_access.carbon +++ b/toolchain/check/testdata/class/field_access.carbon @@ -67,18 +67,31 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl j, element0 [template] -// CHECK:STDOUT: %.loc13: %Class.elem = field_decl k, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl j, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Class.elem = var +// CHECK:STDOUT: %.loc13_8: %Class.elem = field_decl k, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Class.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.j.k [template = constants.%complete_type.cf7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %Class = binding_pattern c +// CHECK:STDOUT: %.loc17: %Class = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %Class = var c +// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %c: ref %Class = bind_name c, %c.var // CHECK:STDOUT: %c.ref.loc18: ref %Class = name_ref c, %c -// CHECK:STDOUT: %j.ref.loc18: %Class.elem = name_ref j, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %j.ref.loc18: %Class.elem = name_ref j, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc18_4: ref %i32 = class_element_access %c.ref.loc18, element0 // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc18: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -88,7 +101,7 @@ fn Run() { // CHECK:STDOUT: %.loc18_7: init %i32 = converted %int_1, %int.convert_checked.loc18 [template = constants.%int_1.5d2] // CHECK:STDOUT: assign %.loc18_4, %.loc18_7 // CHECK:STDOUT: %c.ref.loc19: ref %Class = name_ref c, %c -// CHECK:STDOUT: %k.ref.loc19: %Class.elem = name_ref k, @Class.%.loc13 [template = @Class.%.loc13] +// CHECK:STDOUT: %k.ref.loc19: %Class.elem = name_ref k, @Class.%.loc13_8 [template = @Class.%.loc13_8] // CHECK:STDOUT: %.loc19_4: ref %i32 = class_element_access %c.ref.loc19, element1 // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %impl.elem0.loc19: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -97,20 +110,36 @@ fn Run() { // CHECK:STDOUT: %int.convert_checked.loc19: init %i32 = call %Convert.specific_fn.loc19(%int_2) [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc19_7: init %i32 = converted %int_2, %int.convert_checked.loc19 [template = constants.%int_2.ef8] // CHECK:STDOUT: assign %.loc19_4, %.loc19_7 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cj.patt: %i32 = binding_pattern cj +// CHECK:STDOUT: %.loc20_3: %i32 = var_pattern %cj.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %cj.var: ref %i32 = var cj -// CHECK:STDOUT: %cj: ref %i32 = bind_name cj, %cj.var // CHECK:STDOUT: %c.ref.loc20: ref %Class = name_ref c, %c -// CHECK:STDOUT: %j.ref.loc20: %Class.elem = name_ref j, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %j.ref.loc20: %Class.elem = name_ref j, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc20_18.1: ref %i32 = class_element_access %c.ref.loc20, element0 // CHECK:STDOUT: %.loc20_18.2: %i32 = bind_value %.loc20_18.1 // CHECK:STDOUT: assign %cj.var, %.loc20_18.2 +// CHECK:STDOUT: %.loc20_11: type = splice_block %i32.loc20 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cj: ref %i32 = bind_name cj, %cj.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ck.patt: %i32 = binding_pattern ck +// CHECK:STDOUT: %.loc21_3: %i32 = var_pattern %ck.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ck.var: ref %i32 = var ck -// CHECK:STDOUT: %ck: ref %i32 = bind_name ck, %ck.var // CHECK:STDOUT: %c.ref.loc21: ref %Class = name_ref c, %c -// CHECK:STDOUT: %k.ref.loc21: %Class.elem = name_ref k, @Class.%.loc13 [template = @Class.%.loc13] +// CHECK:STDOUT: %k.ref.loc21: %Class.elem = name_ref k, @Class.%.loc13_8 [template = @Class.%.loc13_8] // CHECK:STDOUT: %.loc21_18.1: ref %i32 = class_element_access %c.ref.loc21, element1 // CHECK:STDOUT: %.loc21_18.2: %i32 = bind_value %.loc21_18.1 // CHECK:STDOUT: assign %ck.var, %.loc21_18.2 +// CHECK:STDOUT: %.loc21_11: type = splice_block %i32.loc21 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ck: ref %i32 = bind_name ck, %ck.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/field_access_in_value.carbon b/toolchain/check/testdata/class/field_access_in_value.carbon index a406f7d9fb32..74c8dabd257d 100644 --- a/toolchain/check/testdata/class/field_access_in_value.carbon +++ b/toolchain/check/testdata/class/field_access_in_value.carbon @@ -68,18 +68,31 @@ fn Test() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl j, element0 [template] -// CHECK:STDOUT: %.loc13: %Class.elem = field_decl k, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl j, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Class.elem = var +// CHECK:STDOUT: %.loc13_8: %Class.elem = field_decl k, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Class.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.j.k [template = constants.%complete_type.cf7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Test() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cv.patt: %Class = binding_pattern cv +// CHECK:STDOUT: %.loc17: %Class = var_pattern %cv.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %cv.var: ref %Class = var cv +// CHECK:STDOUT: %Class.ref.loc17: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %cv: ref %Class = bind_name cv, %cv.var // CHECK:STDOUT: %cv.ref.loc18: ref %Class = name_ref cv, %cv -// CHECK:STDOUT: %j.ref.loc18: %Class.elem = name_ref j, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %j.ref.loc18: %Class.elem = name_ref j, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc18_5: ref %i32 = class_element_access %cv.ref.loc18, element0 // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc18: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -89,7 +102,7 @@ fn Test() { // CHECK:STDOUT: %.loc18_8: init %i32 = converted %int_1, %int.convert_checked.loc18 [template = constants.%int_1.5d2] // CHECK:STDOUT: assign %.loc18_5, %.loc18_8 // CHECK:STDOUT: %cv.ref.loc19: ref %Class = name_ref cv, %cv -// CHECK:STDOUT: %k.ref.loc19: %Class.elem = name_ref k, @Class.%.loc13 [template = @Class.%.loc13] +// CHECK:STDOUT: %k.ref.loc19: %Class.elem = name_ref k, @Class.%.loc13_8 [template = @Class.%.loc13_8] // CHECK:STDOUT: %.loc19_5: ref %i32 = class_element_access %cv.ref.loc19, element1 // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %impl.elem0.loc19: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -98,23 +111,42 @@ fn Test() { // CHECK:STDOUT: %int.convert_checked.loc19: init %i32 = call %Convert.specific_fn.loc19(%int_2) [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc19_8: init %i32 = converted %int_2, %int.convert_checked.loc19 [template = constants.%int_2.ef8] // CHECK:STDOUT: assign %.loc19_5, %.loc19_8 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %Class = binding_pattern c +// CHECK:STDOUT: } // CHECK:STDOUT: %cv.ref.loc20: ref %Class = name_ref cv, %cv -// CHECK:STDOUT: %.loc20: %Class = bind_value %cv.ref.loc20 -// CHECK:STDOUT: %c: %Class = bind_name c, %.loc20 +// CHECK:STDOUT: %Class.ref.loc20: type = name_ref Class, file.%Class.decl [template = constants.%Class] +// CHECK:STDOUT: %c: ref %Class = bind_name c, %cv.ref.loc20 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cj.patt: %i32 = binding_pattern cj +// CHECK:STDOUT: %.loc21_3: %i32 = var_pattern %cj.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %cj.var: ref %i32 = var cj -// CHECK:STDOUT: %cj: ref %i32 = bind_name cj, %cj.var -// CHECK:STDOUT: %c.ref.loc21: %Class = name_ref c, %c -// CHECK:STDOUT: %j.ref.loc21: %Class.elem = name_ref j, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %c.ref.loc21: ref %Class = name_ref c, %c +// CHECK:STDOUT: %j.ref.loc21: %Class.elem = name_ref j, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc21_18.1: ref %i32 = class_element_access %c.ref.loc21, element0 // CHECK:STDOUT: %.loc21_18.2: %i32 = bind_value %.loc21_18.1 // CHECK:STDOUT: assign %cj.var, %.loc21_18.2 +// CHECK:STDOUT: %.loc21_11: type = splice_block %i32.loc21 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cj: ref %i32 = bind_name cj, %cj.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ck.patt: %i32 = binding_pattern ck +// CHECK:STDOUT: %.loc22_3: %i32 = var_pattern %ck.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ck.var: ref %i32 = var ck -// CHECK:STDOUT: %ck: ref %i32 = bind_name ck, %ck.var -// CHECK:STDOUT: %c.ref.loc22: %Class = name_ref c, %c -// CHECK:STDOUT: %k.ref.loc22: %Class.elem = name_ref k, @Class.%.loc13 [template = @Class.%.loc13] +// CHECK:STDOUT: %c.ref.loc22: ref %Class = name_ref c, %c +// CHECK:STDOUT: %k.ref.loc22: %Class.elem = name_ref k, @Class.%.loc13_8 [template = @Class.%.loc13_8] // CHECK:STDOUT: %.loc22_18.1: ref %i32 = class_element_access %c.ref.loc22, element1 // CHECK:STDOUT: %.loc22_18.2: %i32 = bind_value %.loc22_18.1 // CHECK:STDOUT: assign %ck.var, %.loc22_18.2 +// CHECK:STDOUT: %.loc22_11: type = splice_block %i32.loc22 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ck: ref %i32 = bind_name ck, %ck.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/adapt.carbon b/toolchain/check/testdata/class/generic/adapt.carbon index 7fdb5bf91bb2..2b227bdbca17 100644 --- a/toolchain/check/testdata/class/generic/adapt.carbon +++ b/toolchain/check/testdata/class/generic/adapt.carbon @@ -198,7 +198,11 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @C.%C.elem (%C.elem.66c) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @C.%C.elem (%C.elem.66c) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } @@ -223,7 +227,7 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a] // CHECK:STDOUT: %.loc13_13.1: %C.98a = as_compatible %a.ref // CHECK:STDOUT: %.loc13_13.2: %C.98a = converted %a.ref, %.loc13_13.1 -// CHECK:STDOUT: %x.ref: %C.elem.476 = name_ref x, @C.%.loc5 [template = @C.%.loc5] +// CHECK:STDOUT: %x.ref: %C.elem.476 = name_ref x, @C.%.loc5_8 [template = @C.%.loc5_8] // CHECK:STDOUT: %.loc13_23.1: ref %i32 = class_element_access %.loc13_13.2, element0 // CHECK:STDOUT: %.loc13_23.2: %i32 = bind_value %.loc13_23.1 // CHECK:STDOUT: return %.loc13_23.2 @@ -445,7 +449,11 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @C.%C.elem (%C.elem.66c) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @C.%C.elem (%C.elem.66c) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } @@ -464,7 +472,7 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: fn @Access(%a.param_patt: %Adapter) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %Adapter = name_ref a, %a -// CHECK:STDOUT: %x.ref: %C.elem.476 = name_ref x, @C.%.loc5 [template = @C.%.loc5] +// CHECK:STDOUT: %x.ref: %C.elem.476 = name_ref x, @C.%.loc5_8 [template = @C.%.loc5_8] // CHECK:STDOUT: %.loc21_11.1: %C.98a = converted %a.ref, [template = ] // CHECK:STDOUT: %.loc21_11.2: %i32 = class_element_access , element0 [template = ] // CHECK:STDOUT: return @@ -549,7 +557,11 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: %complete_type.loc9_1.2: = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc9_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc8: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc8_8: @C.%C.elem (%C.elem.66c) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc8_3: @C.%C.elem (%C.elem.66c) = var_pattern %.loc8_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @C.%C.elem (%C.elem.66c) = var // CHECK:STDOUT: %complete_type.loc9_1.1: = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc9_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc9_1.1 // CHECK:STDOUT: } @@ -899,7 +911,11 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc11: %C.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc11_8: %C.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc11_3: %C.elem = var_pattern %.loc11_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -920,7 +936,7 @@ fn ImportedConvertLocal(a: Adapter(C)) -> i32 { // CHECK:STDOUT: %C.ref.loc15: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %.loc15_13.1: %C = as_compatible %a.ref // CHECK:STDOUT: %.loc15_13.2: %C = converted %a.ref, %.loc15_13.1 -// CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc11 [template = @C.%.loc11] +// CHECK:STDOUT: %n.ref: %C.elem = name_ref n, @C.%.loc11_8 [template = @C.%.loc11_8] // CHECK:STDOUT: %.loc15_18.1: ref %i32 = class_element_access %.loc15_13.2, element0 // CHECK:STDOUT: %.loc15_18.2: %i32 = bind_value %.loc15_18.1 // CHECK:STDOUT: return %.loc15_18.2 diff --git a/toolchain/check/testdata/class/generic/base_is_generic.carbon b/toolchain/check/testdata/class/generic/base_is_generic.carbon index 81522f720c2d..4b1a2aefc851 100644 --- a/toolchain/check/testdata/class/generic/base_is_generic.carbon +++ b/toolchain/check/testdata/class/generic/base_is_generic.carbon @@ -169,14 +169,22 @@ fn H() { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @Base.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @Base.%Base.elem (%Base.elem.9af) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: @Base.%Base.elem (%Base.elem.9af) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @Base.%Base.elem (%Base.elem.9af) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Base.%Base.elem (%Base.elem.9af) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Param { -// CHECK:STDOUT: %.loc9: %Param.elem = field_decl y, element0 [template] +// CHECK:STDOUT: %.loc9_8: %Param.elem = field_decl y, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc9_3: %Param.elem = var_pattern %.loc9_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Param.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.y [template = constants.%complete_type.0f9] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -193,11 +201,11 @@ fn H() { // CHECK:STDOUT: fn @DoubleFieldAccess(%d.param_patt: %Derived) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %d.ref: %Derived = name_ref d, %d -// CHECK:STDOUT: %x.ref: %Base.elem.d1f = name_ref x, @Base.%.loc5 [template = @Base.%.loc5] +// CHECK:STDOUT: %x.ref: %Base.elem.d1f = name_ref x, @Base.%.loc5_8 [template = @Base.%.loc5_8] // CHECK:STDOUT: %.loc17_11.1: ref %Base.7a8 = class_element_access %d.ref, element0 // CHECK:STDOUT: %.loc17_11.2: ref %Base.7a8 = converted %d.ref, %.loc17_11.1 // CHECK:STDOUT: %.loc17_11.3: ref %Param = class_element_access %.loc17_11.2, element0 -// CHECK:STDOUT: %y.ref: %Param.elem = name_ref y, @Param.%.loc9 [template = @Param.%.loc9] +// CHECK:STDOUT: %y.ref: %Param.elem = name_ref y, @Param.%.loc9_8 [template = @Param.%.loc9_8] // CHECK:STDOUT: %.loc17_13.1: ref %i32 = class_element_access %.loc17_11.3, element0 // CHECK:STDOUT: %.loc17_13.2: %i32 = bind_value %.loc17_13.1 // CHECK:STDOUT: return %.loc17_13.2 @@ -582,17 +590,24 @@ fn H() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %i32 = binding_pattern i +// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.generic] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc13_18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13_18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a] // CHECK:STDOUT: %.loc13_22: %G.type.862 = specific_constant @X.%G.decl, @X(constants.%i32) [template = constants.%G.d5e] // CHECK:STDOUT: %G.ref: %G.type.862 = name_ref G, %.loc13_22 [template = constants.%G.d5e] // CHECK:STDOUT: %G.specific_fn: = specific_function %G.ref, @G(constants.%i32) [template = constants.%G.specific_fn.7a3] // CHECK:STDOUT: %G.call: init %i32 = call %G.specific_fn() -// CHECK:STDOUT: %.loc13_26.1: %i32 = value_of_initializer %G.call -// CHECK:STDOUT: %.loc13_26.2: %i32 = converted %G.call, %.loc13_26.1 -// CHECK:STDOUT: %i: %i32 = bind_name i, %.loc13_26.2 +// CHECK:STDOUT: %.loc13_10: type = splice_block %i32.loc13_10 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13_10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc13_25.1: ref %i32 = temporary_storage +// CHECK:STDOUT: %.loc13_25.2: ref %i32 = temporary %.loc13_25.1, %G.call +// CHECK:STDOUT: %i: ref %i32 = bind_name i, %.loc13_25.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -769,17 +784,24 @@ fn H() { // CHECK:STDOUT: // CHECK:STDOUT: fn @H() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %j.patt: %i32 = binding_pattern j +// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc7_18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7_18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.98a] // CHECK:STDOUT: %.loc7_22: %G.type.862 = specific_constant imports.%import_ref.b8a, @X(constants.%i32) [template = constants.%G.d5e] // CHECK:STDOUT: %G.ref: %G.type.862 = name_ref G, %.loc7_22 [template = constants.%G.d5e] // CHECK:STDOUT: %G.specific_fn: = specific_function %G.ref, @G(constants.%i32) [template = constants.%G.specific_fn.7a3] // CHECK:STDOUT: %G.call: init %i32 = call %G.specific_fn() -// CHECK:STDOUT: %.loc7_26.1: %i32 = value_of_initializer %G.call -// CHECK:STDOUT: %.loc7_26.2: %i32 = converted %G.call, %.loc7_26.1 -// CHECK:STDOUT: %j: %i32 = bind_name j, %.loc7_26.2 +// CHECK:STDOUT: %.loc7_10: type = splice_block %i32.loc7_10 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc7_10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc7_25.1: ref %i32 = temporary_storage +// CHECK:STDOUT: %.loc7_25.2: ref %i32 = temporary %.loc7_25.1, %G.call +// CHECK:STDOUT: %j: ref %i32 = bind_name j, %.loc7_25.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/basic.carbon b/toolchain/check/testdata/class/generic/basic.carbon index aa8c5bfb8b36..cf67e1cae6d3 100644 --- a/toolchain/check/testdata/class/generic/basic.carbon +++ b/toolchain/check/testdata/class/generic/basic.carbon @@ -129,7 +129,11 @@ class Declaration(T:! type); // CHECK:STDOUT: %return.param: ref @GetValue.%T (%T) = out_param runtime_param1 // CHECK:STDOUT: %return: ref @GetValue.%T (%T) = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc21: @Class.%Class.elem (%Class.elem) = field_decl k, element0 [template] +// CHECK:STDOUT: %.loc21_8: @Class.%Class.elem (%Class.elem) = field_decl k, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc21_3: @Class.%Class.elem (%Class.elem) = var_pattern %.loc21_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem) = var // CHECK:STDOUT: %complete_type.loc22_1.1: = complete_type_witness %struct_type.k [symbolic = %complete_type.loc22_1.2 (constants.%complete_type)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc22_1.1 // CHECK:STDOUT: } @@ -158,7 +162,7 @@ class Declaration(T:! type); // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @GetAddr.%ptr.loc12_29.1 (%ptr.955) = name_ref self, %self // CHECK:STDOUT: %.loc13_17.1: ref @GetAddr.%Class (%Class) = deref %self.ref -// CHECK:STDOUT: %k.ref: @GetAddr.%Class.elem (%Class.elem) = name_ref k, @Class.%.loc21 [template = @Class.%.loc21] +// CHECK:STDOUT: %k.ref: @GetAddr.%Class.elem (%Class.elem) = name_ref k, @Class.%.loc21_8 [template = @Class.%.loc21_8] // CHECK:STDOUT: %.loc13_17.2: ref @GetAddr.%T (%T) = class_element_access %.loc13_17.1, element0 // CHECK:STDOUT: %addr: @GetAddr.%ptr.loc12_38.1 (%ptr.79f) = addr_of %.loc13_17.2 // CHECK:STDOUT: return %addr @@ -177,7 +181,7 @@ class Declaration(T:! type); // CHECK:STDOUT: fn[%self.param_patt: @GetValue.%Class (%Class)]() -> @GetValue.%T (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @GetValue.%Class (%Class) = name_ref self, %self -// CHECK:STDOUT: %k.ref: @GetValue.%Class.elem (%Class.elem) = name_ref k, @Class.%.loc21 [template = @Class.%.loc21] +// CHECK:STDOUT: %k.ref: @GetValue.%Class.elem (%Class.elem) = name_ref k, @Class.%.loc21_8 [template = @Class.%.loc21_8] // CHECK:STDOUT: %.loc18_16.1: ref @GetValue.%T (%T) = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc18_16.2: @GetValue.%T (%T) = bind_value %.loc18_16.1 // CHECK:STDOUT: return %.loc18_16.2 diff --git a/toolchain/check/testdata/class/generic/call.carbon b/toolchain/check/testdata/class/generic/call.carbon index eb70faa00951..bf66ce2e4fc9 100644 --- a/toolchain/check/testdata/class/generic/call.carbon +++ b/toolchain/check/testdata/class/generic/call.carbon @@ -101,8 +101,18 @@ class Outer(T:! type) { // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [template] +// CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [template] +// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.4e6: = bound_method %int_5.64b, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.ba9: = specific_function %Convert.bound.4e6, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [template] // CHECK:STDOUT: %Class.f29: type = class_type @Class, @Class(%ptr.235, %int_5.0f6) [template] +// CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template] +// CHECK:STDOUT: %Convert.bound.d04: = bound_method %int_0.5c6, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.d62: = specific_function %Convert.bound.d04, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template] // CHECK:STDOUT: %Class.dd4: type = class_type @Class, @Class(%empty_tuple.type, %int_0.6a9) [template] // CHECK:STDOUT: } @@ -139,9 +149,44 @@ class Outer(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc4_23.1: %i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc4_23.2 (constants.%N.356)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %Class.f29 = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %Class.f29 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %Class.f29 = var a +// CHECK:STDOUT: %.loc6_21.1: type = splice_block %Class.loc6 [template = constants.%Class.f29] { +// CHECK:STDOUT: %Class.ref.loc6: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %impl.elem0.loc6: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc6: = bound_method %int_5, %impl.elem0.loc6 [template = constants.%Convert.bound.4e6] +// CHECK:STDOUT: %Convert.specific_fn.loc6: = specific_function %Convert.bound.loc6, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9] +// CHECK:STDOUT: %int.convert_checked.loc6: init %i32 = call %Convert.specific_fn.loc6(%int_5) [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc6_21.2: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc6_21.3: %i32 = converted %int_5, %.loc6_21.2 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %Class.loc6: type = class_type @Class, @Class(constants.%ptr.235, constants.%int_5.0f6) [template = constants.%Class.f29] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %Class.f29 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %Class.dd4 = binding_pattern b +// CHECK:STDOUT: %.loc9_1: %Class.dd4 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %Class.dd4 = var b +// CHECK:STDOUT: %.loc9_19.1: type = splice_block %Class.loc9 [template = constants.%Class.dd4] { +// CHECK:STDOUT: %Class.ref.loc9: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %.loc9_15: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc9_19.2: type = converted %.loc9_15, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %impl.elem0.loc9: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc9: = bound_method %int_0, %impl.elem0.loc9 [template = constants.%Convert.bound.d04] +// CHECK:STDOUT: %Convert.specific_fn.loc9: = specific_function %Convert.bound.loc9, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] +// CHECK:STDOUT: %int.convert_checked.loc9: init %i32 = call %Convert.specific_fn.loc9(%int_0) [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc9_19.3: %i32 = value_of_initializer %int.convert_checked.loc9 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc9_19.4: %i32 = converted %int_0, %.loc9_19.3 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %Class.loc9: type = class_type @Class, @Class(constants.%empty_tuple.type, constants.%int_0.6a9) [template = constants.%Class.dd4] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %Class.dd4 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -197,6 +242,7 @@ class Outer(T:! type) { // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -229,8 +275,18 @@ class Outer(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc4_23.1: %i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc4_23.2 (constants.%N.356)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc13: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @Class(%T.loc4_13.1: type, %N.loc4_23.1: %i32) { @@ -267,6 +323,9 @@ class Outer(T:! type) { // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -299,8 +358,20 @@ class Outer(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc4_23.1: %i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc4_23.2 (constants.%N.356)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc13: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @Class(%T.loc4_13.1: type, %N.loc4_23.1: %i32) { @@ -337,6 +408,8 @@ class Outer(T:! type) { // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -370,8 +443,20 @@ class Outer(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc4_23.1: %i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc4_23.2 (constants.%N.356)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc16_1: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, %Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: %.loc16_21: type = converted %int_5, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @Class(%T.loc4_13.1: type, %N.loc4_23.1: %i32) { diff --git a/toolchain/check/testdata/class/generic/complete_in_conversion.carbon b/toolchain/check/testdata/class/generic/complete_in_conversion.carbon index 38b53e508424..be5c11260fd8 100644 --- a/toolchain/check/testdata/class/generic/complete_in_conversion.carbon +++ b/toolchain/check/testdata/class/generic/complete_in_conversion.carbon @@ -24,9 +24,9 @@ class A(N:! i32) { } fn F(a: A(0)*) { - // CHECK:STDERR: fail_derived_to_base.carbon:[[@LINE+4]]:3: note: in `A(0)` used here [ResolvingSpecificHere] + // CHECK:STDERR: fail_derived_to_base.carbon:[[@LINE+4]]:15: note: in `A(0)` used here [ResolvingSpecificHere] // CHECK:STDERR: let b: B* = a; - // CHECK:STDERR: ^~~~~~~~~~~~~~ + // CHECK:STDERR: ^ // CHECK:STDERR: let b: B* = a; } @@ -132,7 +132,7 @@ fn F(a: A(0)*) { // CHECK:STDOUT: %a.param_patt: %ptr.b65 = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %a.param: %ptr.b65 = value_param runtime_param0 -// CHECK:STDOUT: %.loc15_13: type = splice_block %ptr [template = constants.%ptr.b65] { +// CHECK:STDOUT: %.loc15_13: type = splice_block %ptr.loc15 [template = constants.%ptr.b65] { // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A.generic] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -142,7 +142,7 @@ fn F(a: A(0)*) { // CHECK:STDOUT: %.loc15_12.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc15_12.2: %i32 = converted %int_0, %.loc15_12.1 [template = constants.%int_0.6a9] // CHECK:STDOUT: %A: type = class_type @A, @A(constants.%int_0.6a9) [template = constants.%A.6fc] -// CHECK:STDOUT: %ptr: type = ptr_type %A.6fc [template = constants.%ptr.b65] +// CHECK:STDOUT: %ptr.loc15: type = ptr_type %A.6fc [template = constants.%ptr.b65] // CHECK:STDOUT: } // CHECK:STDOUT: %a: %ptr.b65 = bind_name a, %a.param // CHECK:STDOUT: } @@ -172,7 +172,11 @@ fn F(a: A(0)*) { // CHECK:STDOUT: class { // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] // CHECK:STDOUT: %.loc7: @A.%A.elem.loc7 (%A.elem.500) = base_decl %B.ref, element0 [template] -// CHECK:STDOUT: %.loc12: @A.%A.elem.loc12 (%A.elem.d60) = field_decl n, element1 [template] +// CHECK:STDOUT: %.loc12_8: @A.%A.elem.loc12 (%A.elem.d60) = field_decl n, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: @A.%A.elem.loc12 (%A.elem.d60) = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @A.%A.elem.loc12 (%A.elem.d60) = var // CHECK:STDOUT: %complete_type.loc13_1.1: = complete_type_witness %struct_type.base.n [symbolic = %complete_type.loc13_1.2 (constants.%complete_type.547)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc13_1.1 // CHECK:STDOUT: } @@ -182,12 +186,19 @@ fn F(a: A(0)*) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %ptr.b65) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %ptr.e79 = binding_pattern b +// CHECK:STDOUT: } // CHECK:STDOUT: %a.ref: %ptr.b65 = name_ref a, %a -// CHECK:STDOUT: %.loc20_16.1: ref %A.6fc = deref %a.ref -// CHECK:STDOUT: %.loc20_16.2: ref %B = class_element_access %.loc20_16.1, element0 -// CHECK:STDOUT: %addr: %ptr.e79 = addr_of %.loc20_16.2 -// CHECK:STDOUT: %.loc20_16.3: %ptr.e79 = converted %a.ref, %addr -// CHECK:STDOUT: %b: %ptr.e79 = bind_name b, %.loc20_16.3 +// CHECK:STDOUT: %.loc20_11: type = splice_block %ptr.loc20 [template = constants.%ptr.e79] { +// CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] +// CHECK:STDOUT: %ptr.loc20: type = ptr_type %B [template = constants.%ptr.e79] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc20_15.1: ref %A.6fc = deref %a.ref +// CHECK:STDOUT: %.loc20_15.2: ref %B = class_element_access %.loc20_15.1, element0 +// CHECK:STDOUT: %addr: %ptr.e79 = addr_of %.loc20_15.2 +// CHECK:STDOUT: %.loc20_15.3: %ptr.e79 = converted %a.ref, %addr +// CHECK:STDOUT: %b: %ptr.e79 = bind_name b, %.loc20_15.3 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/field.carbon b/toolchain/check/testdata/class/generic/field.carbon index 9cc7eec0f0d4..658b7ffbb003 100644 --- a/toolchain/check/testdata/class/generic/field.carbon +++ b/toolchain/check/testdata/class/generic/field.carbon @@ -160,7 +160,11 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: %complete_type.loc13_1.2: = complete_type_witness @Class.%struct_type.x (%struct_type.x.2ac3f0.1) [symbolic = %complete_type.loc13_1.2 (constants.%complete_type.4339b3.1)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc12: @Class.%Class.elem (%Class.elem.e262de.1) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc12_8: @Class.%Class.elem (%Class.elem.e262de.1) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: @Class.%Class.elem (%Class.elem.e262de.1) = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem.e262de.1) = var // CHECK:STDOUT: %complete_type.loc13_1.1: = complete_type_witness %struct_type.x.2ac3f0.1 [symbolic = %complete_type.loc13_1.2 (constants.%complete_type.4339b3.1)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc13_1.1 // CHECK:STDOUT: } @@ -169,7 +173,7 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: fn @F(%c.param_patt: %Class.247) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %Class.247 = name_ref c, %c -// CHECK:STDOUT: %x.ref: %Class.elem.2d8 = name_ref x, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %x.ref: %Class.elem.2d8 = name_ref x, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc16_11.1: ref %i32 = class_element_access %c.ref, element0 // CHECK:STDOUT: %.loc16_11.2: %i32 = bind_value %.loc16_11.1 // CHECK:STDOUT: return %.loc16_11.2 @@ -188,7 +192,7 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: fn(%T.param_patt: type, %c.param_patt: @G.%Class.loc19_26.2 (%Class.fe1b2d.1)) -> @G.%T.loc19_6.2 (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: @G.%Class.loc19_26.2 (%Class.fe1b2d.1) = name_ref c, %c -// CHECK:STDOUT: %x.ref: @G.%Class.elem (%Class.elem.e262de.1) = name_ref x, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %x.ref: @G.%Class.elem (%Class.elem.e262de.1) = name_ref x, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc20_11.1: ref @G.%T.loc19_6.2 (%T) = class_element_access %c.ref, element0 // CHECK:STDOUT: %.loc20_11.2: @G.%T.loc19_6.2 (%T) = bind_value %.loc20_11.1 // CHECK:STDOUT: return %.loc20_11.2 @@ -208,7 +212,7 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: fn(%U.param_patt: type, %c.param_patt: @H.%Class.loc23_26.2 (%Class.fe1b2d.2)) -> @H.%U.loc23_6.2 (%U) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: @H.%Class.loc23_26.2 (%Class.fe1b2d.2) = name_ref c, %c -// CHECK:STDOUT: %x.ref: @H.%Class.elem (%Class.elem.e262de.2) = name_ref x, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %x.ref: @H.%Class.elem (%Class.elem.e262de.2) = name_ref x, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc24_11.1: ref @H.%U.loc23_6.2 (%U) = class_element_access %c.ref, element0 // CHECK:STDOUT: %.loc24_11.2: @H.%U.loc23_6.2 (%U) = bind_value %.loc24_11.1 // CHECK:STDOUT: return %.loc24_11.2 diff --git a/toolchain/check/testdata/class/generic/import.carbon b/toolchain/check/testdata/class/generic/import.carbon index ce7df86ab5f3..5bf368f521de 100644 --- a/toolchain/check/testdata/class/generic/import.carbon +++ b/toolchain/check/testdata/class/generic/import.carbon @@ -57,10 +57,10 @@ fn Use() { // TODO: Include the generic arguments in the formatted type name. // CHECK:STDERR: fail_generic_arg_mismatch.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `CompleteClass(i32)` to `CompleteClass(i32*)` [ImplicitAsConversionFailure] // CHECK:STDERR: var v: CompleteClass(i32*) = F(); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_generic_arg_mismatch.carbon:[[@LINE+4]]:3: note: type `CompleteClass(i32)` does not implement interface `Core.ImplicitAs(CompleteClass(i32*))` [MissingImplInMemberAccessNote] // CHECK:STDERR: var v: CompleteClass(i32*) = F(); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var v: CompleteClass(i32*) = F(); } @@ -177,7 +177,11 @@ class Class(U:! type) { // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.14f) = struct_value () [symbolic = %F (constants.%F.874)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc7: @CompleteClass.%CompleteClass.elem (%CompleteClass.elem) = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc7_8: @CompleteClass.%CompleteClass.elem (%CompleteClass.elem) = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc7_3: @CompleteClass.%CompleteClass.elem (%CompleteClass.elem) = var_pattern %.loc7_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @CompleteClass.%CompleteClass.elem (%CompleteClass.elem) = var // CHECK:STDOUT: %F.decl: @CompleteClass.%F.type (%F.type.14f) = fn_decl @F.1 [symbolic = @CompleteClass.%F (constants.%F.874)] { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 @@ -328,7 +332,11 @@ class Class(U:! type) { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @Class.%struct_type.x (%struct_type.x) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @Class.%Class.elem (%Class.elem) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: @Class.%Class.elem (%Class.elem) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @Class.%Class.elem (%Class.elem) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.x [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } @@ -461,8 +469,8 @@ class Class(U:! type) { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -470,8 +478,8 @@ class Class(U:! type) { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -494,12 +502,22 @@ class Class(U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: fn @UseMethod() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %CompleteClass.e9e = binding_pattern v +// CHECK:STDOUT: %.loc6_3.1: %CompleteClass.e9e = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %CompleteClass.e9e = var v -// CHECK:STDOUT: %v: ref %CompleteClass.e9e = bind_name v, %v.var // CHECK:STDOUT: %F.ref.loc6: %F.type.b25 = name_ref F, imports.%import_ref.b37 [template = constants.%F.c41] -// CHECK:STDOUT: %.loc6: ref %CompleteClass.e9e = splice_block %v.var {} -// CHECK:STDOUT: %F.call.loc6: init %CompleteClass.e9e = call %F.ref.loc6() to %.loc6 +// CHECK:STDOUT: %.loc6_3.2: ref %CompleteClass.e9e = splice_block %v.var {} +// CHECK:STDOUT: %F.call.loc6: init %CompleteClass.e9e = call %F.ref.loc6() to %.loc6_3.2 // CHECK:STDOUT: assign %v.var, %F.call.loc6 +// CHECK:STDOUT: %.loc6_27: type = splice_block %CompleteClass [template = constants.%CompleteClass.e9e] { +// CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.cfa [template = constants.%CompleteClass.generic] +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(constants.%i32) [template = constants.%CompleteClass.e9e] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %CompleteClass.e9e = bind_name v, %v.var // CHECK:STDOUT: %v.ref: ref %CompleteClass.e9e = name_ref v, %v // CHECK:STDOUT: %.loc7_11: %F.type.1bc = specific_constant imports.%import_ref.a52, @CompleteClass(constants.%i32) [template = constants.%F.f7c] // CHECK:STDOUT: %F.ref.loc7: %F.type.1bc = name_ref F, %.loc7_11 [template = constants.%F.f7c] @@ -520,12 +538,22 @@ class Class(U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: fn @UseField() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %CompleteClass.e9e = binding_pattern v +// CHECK:STDOUT: %.loc11_3.1: %CompleteClass.e9e = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %CompleteClass.e9e = var v -// CHECK:STDOUT: %v: ref %CompleteClass.e9e = bind_name v, %v.var // CHECK:STDOUT: %F.ref: %F.type.b25 = name_ref F, imports.%import_ref.b37 [template = constants.%F.c41] -// CHECK:STDOUT: %.loc11: ref %CompleteClass.e9e = splice_block %v.var {} -// CHECK:STDOUT: %F.call: init %CompleteClass.e9e = call %F.ref() to %.loc11 +// CHECK:STDOUT: %.loc11_3.2: ref %CompleteClass.e9e = splice_block %v.var {} +// CHECK:STDOUT: %F.call: init %CompleteClass.e9e = call %F.ref() to %.loc11_3.2 // CHECK:STDOUT: assign %v.var, %F.call +// CHECK:STDOUT: %.loc11_27: type = splice_block %CompleteClass [template = constants.%CompleteClass.e9e] { +// CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.cfa [template = constants.%CompleteClass.generic] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(constants.%i32) [template = constants.%CompleteClass.e9e] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %CompleteClass.e9e = bind_name v, %v.var // CHECK:STDOUT: %v.ref: ref %CompleteClass.e9e = name_ref v, %v // CHECK:STDOUT: %n.ref: %CompleteClass.elem.7fc = name_ref n, imports.%import_ref.e76 [template = imports.%.364] // CHECK:STDOUT: %.loc12_11.1: ref %i32 = class_element_access %v.ref, element0 @@ -636,13 +664,24 @@ class Class(U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Use() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %CompleteClass.0fe = binding_pattern v +// CHECK:STDOUT: %.loc14_3.1: %CompleteClass.0fe = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %CompleteClass.0fe = var v -// CHECK:STDOUT: %v: ref %CompleteClass.0fe = bind_name v, %v.var // CHECK:STDOUT: %F.ref: %F.type.b25 = name_ref F, imports.%import_ref.b37 [template = constants.%F.c41] // CHECK:STDOUT: %.loc14_34: ref %CompleteClass.a06 = temporary_storage // CHECK:STDOUT: %F.call: init %CompleteClass.a06 = call %F.ref() to %.loc14_34 -// CHECK:STDOUT: %.loc14_35: %CompleteClass.0fe = converted %F.call, [template = ] +// CHECK:STDOUT: %.loc14_3.2: %CompleteClass.0fe = converted %F.call, [template = ] // CHECK:STDOUT: assign %v.var, +// CHECK:STDOUT: %.loc14_28: type = splice_block %CompleteClass [template = constants.%CompleteClass.0fe] { +// CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.cfa [template = constants.%CompleteClass.generic] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.9e1] +// CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(constants.%ptr.9e1) [template = constants.%CompleteClass.0fe] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %CompleteClass.0fe = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -747,7 +786,11 @@ class Class(U:! type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc17: = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc17_8: = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc17_3: = var_pattern %.loc17_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref = var // CHECK:STDOUT: %complete_type: = complete_type_witness [template = ] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/generic/init.carbon b/toolchain/check/testdata/class/generic/init.carbon index 89e92c1e07f1..dba94b05cb9a 100644 --- a/toolchain/check/testdata/class/generic/init.carbon +++ b/toolchain/check/testdata/class/generic/init.carbon @@ -140,7 +140,11 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @Class.%struct_type.k (%struct_type.k.b21) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.b9e)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @Class.%Class.elem (%Class.elem.e26) = field_decl k, element0 [template] +// CHECK:STDOUT: %.loc5_8: @Class.%Class.elem (%Class.elem.e26) = field_decl k, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @Class.%Class.elem (%Class.elem.e26) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem.e26) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.k.b21 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.b9e)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } @@ -152,24 +156,33 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %require_complete.loc8: = require_complete_type @InitFromStructGeneric.%T.loc8_26.2 (%T) [symbolic = %require_complete.loc8 (constants.%require_complete.4ae)] -// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.loc8_26.2) [symbolic = %Class (constants.%Class.fe1)] -// CHECK:STDOUT: %require_complete.loc9: = require_complete_type @InitFromStructGeneric.%Class (%Class.fe1) [symbolic = %require_complete.loc9 (constants.%require_complete.4f8)] +// CHECK:STDOUT: %Class.loc9_17.2: type = class_type @Class, @Class(%T.loc8_26.2) [symbolic = %Class.loc9_17.2 (constants.%Class.fe1)] +// CHECK:STDOUT: %require_complete.loc9: = require_complete_type @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) [symbolic = %require_complete.loc9 (constants.%require_complete.4f8)] // CHECK:STDOUT: %struct_type.k: type = struct_type {.k: @InitFromStructGeneric.%T.loc8_26.2 (%T)} [symbolic = %struct_type.k (constants.%struct_type.k.b21)] -// CHECK:STDOUT: %Class.elem: type = unbound_element_type @InitFromStructGeneric.%Class (%Class.fe1), @InitFromStructGeneric.%T.loc8_26.2 (%T) [symbolic = %Class.elem (constants.%Class.elem.e26)] +// CHECK:STDOUT: %Class.elem: type = unbound_element_type @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1), @InitFromStructGeneric.%T.loc8_26.2 (%T) [symbolic = %Class.elem (constants.%Class.elem.e26)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type, %x.param_patt: @InitFromStructGeneric.%T.loc8_26.2 (%T)) -> @InitFromStructGeneric.%T.loc8_26.2 (%T) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %v.var: ref @InitFromStructGeneric.%Class (%Class.fe1) = var v -// CHECK:STDOUT: %v: ref @InitFromStructGeneric.%Class (%Class.fe1) = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = binding_pattern v +// CHECK:STDOUT: %.loc9_3.1: @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = var_pattern %v.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %v.var: ref @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = var v // CHECK:STDOUT: %x.ref: @InitFromStructGeneric.%T.loc8_26.2 (%T) = name_ref x, %x // CHECK:STDOUT: %.loc9_28.1: @InitFromStructGeneric.%struct_type.k (%struct_type.k.b21) = struct_literal (%x.ref) // CHECK:STDOUT: %.loc9_28.2: ref @InitFromStructGeneric.%T.loc8_26.2 (%T) = class_element_access %v.var, element0 // CHECK:STDOUT: %.loc9_28.3: init @InitFromStructGeneric.%T.loc8_26.2 (%T) = initialize_from %x.ref to %.loc9_28.2 -// CHECK:STDOUT: %.loc9_28.4: init @InitFromStructGeneric.%Class (%Class.fe1) = class_init (%.loc9_28.3), %v.var -// CHECK:STDOUT: %.loc9_29: init @InitFromStructGeneric.%Class (%Class.fe1) = converted %.loc9_28.1, %.loc9_28.4 -// CHECK:STDOUT: assign %v.var, %.loc9_29 -// CHECK:STDOUT: %v.ref: ref @InitFromStructGeneric.%Class (%Class.fe1) = name_ref v, %v -// CHECK:STDOUT: %k.ref: @InitFromStructGeneric.%Class.elem (%Class.elem.e26) = name_ref k, @Class.%.loc5 [template = @Class.%.loc5] +// CHECK:STDOUT: %.loc9_28.4: init @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = class_init (%.loc9_28.3), %v.var +// CHECK:STDOUT: %.loc9_3.2: init @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = converted %.loc9_28.1, %.loc9_28.4 +// CHECK:STDOUT: assign %v.var, %.loc9_3.2 +// CHECK:STDOUT: %.loc9_17: type = splice_block %Class.loc9_17.1 [symbolic = %Class.loc9_17.2 (constants.%Class.fe1)] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %T.ref.loc9: type = name_ref T, %T.loc8_26.1 [symbolic = %T.loc8_26.2 (constants.%T)] +// CHECK:STDOUT: %Class.loc9_17.1: type = class_type @Class, @Class(constants.%T) [symbolic = %Class.loc9_17.2 (constants.%Class.fe1)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = bind_name v, %v.var +// CHECK:STDOUT: %v.ref: ref @InitFromStructGeneric.%Class.loc9_17.2 (%Class.fe1) = name_ref v, %v +// CHECK:STDOUT: %k.ref: @InitFromStructGeneric.%Class.elem (%Class.elem.e26) = name_ref k, @Class.%.loc5_8 [template = @Class.%.loc5_8] // CHECK:STDOUT: %.loc10_11.1: ref @InitFromStructGeneric.%T.loc8_26.2 (%T) = class_element_access %v.ref, element0 // CHECK:STDOUT: %.loc10_11.2: @InitFromStructGeneric.%T.loc8_26.2 (%T) = bind_value %.loc10_11.1 // CHECK:STDOUT: return %.loc10_11.2 @@ -178,17 +191,27 @@ fn InitFromAdaptedSpecific(x: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @InitFromStructSpecific(%x.param_patt: %i32) -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %Class.247 = binding_pattern v +// CHECK:STDOUT: %.loc14_3.1: %Class.247 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %Class.247 = var v -// CHECK:STDOUT: %v: ref %Class.247 = bind_name v, %v.var // CHECK:STDOUT: %x.ref: %i32 = name_ref x, %x // CHECK:STDOUT: %.loc14_30.1: %struct_type.k.0bf = struct_literal (%x.ref) // CHECK:STDOUT: %.loc14_30.2: ref %i32 = class_element_access %v.var, element0 // CHECK:STDOUT: %.loc14_30.3: init %i32 = initialize_from %x.ref to %.loc14_30.2 // CHECK:STDOUT: %.loc14_30.4: init %Class.247 = class_init (%.loc14_30.3), %v.var -// CHECK:STDOUT: %.loc14_31: init %Class.247 = converted %.loc14_30.1, %.loc14_30.4 -// CHECK:STDOUT: assign %v.var, %.loc14_31 +// CHECK:STDOUT: %.loc14_3.2: init %Class.247 = converted %.loc14_30.1, %.loc14_30.4 +// CHECK:STDOUT: assign %v.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_19: type = splice_block %Class [template = constants.%Class.247] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%i32) [template = constants.%Class.247] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %Class.247 = bind_name v, %v.var // CHECK:STDOUT: %v.ref: ref %Class.247 = name_ref v, %v -// CHECK:STDOUT: %k.ref: %Class.elem.2d8 = name_ref k, @Class.%.loc5 [template = @Class.%.loc5] +// CHECK:STDOUT: %k.ref: %Class.elem.2d8 = name_ref k, @Class.%.loc5_8 [template = @Class.%.loc5_8] // CHECK:STDOUT: %.loc15_11.1: ref %i32 = class_element_access %v.ref, element0 // CHECK:STDOUT: %.loc15_11.2: %i32 = bind_value %.loc15_11.1 // CHECK:STDOUT: return %.loc15_11.2 diff --git a/toolchain/check/testdata/class/generic/member_access.carbon b/toolchain/check/testdata/class/generic/member_access.carbon index f902bf4019bc..b8b3af71ceb2 100644 --- a/toolchain/check/testdata/class/generic/member_access.carbon +++ b/toolchain/check/testdata/class/generic/member_access.carbon @@ -194,7 +194,11 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) { // CHECK:STDOUT: %complete_type.loc8_1.2: = complete_type_witness @Class.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc8_1.2 (constants.%complete_type.433)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc3: @Class.%Class.elem (%Class.elem.e26) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc3_8: @Class.%Class.elem (%Class.elem.e26) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc3_3: @Class.%Class.elem (%Class.elem.e26) = var_pattern %.loc3_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem.e26) = var // CHECK:STDOUT: %Get.decl: @Class.%Get.type (%Get.type.fd9) = fn_decl @Get [symbolic = @Class.%Get (constants.%Get.cf9)] { // CHECK:STDOUT: %self.patt: @Get.%Class (%Class.fe1) = binding_pattern self // CHECK:STDOUT: %self.param_patt: @Get.%Class (%Class.fe1) = value_param_pattern %self.patt, runtime_param0 @@ -247,7 +251,7 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) { // CHECK:STDOUT: fn[%self.param_patt: @Get.%Class (%Class.fe1)]() -> @Get.%T (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @Get.%Class (%Class.fe1) = name_ref self, %self -// CHECK:STDOUT: %x.ref: @Get.%Class.elem (%Class.elem.e26) = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %x.ref: @Get.%Class.elem (%Class.elem.e26) = name_ref x, @Class.%.loc3_8 [template = @Class.%.loc3_8] // CHECK:STDOUT: %.loc5_42.1: ref @Get.%T (%T) = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc5_42.2: @Get.%T (%T) = bind_value %.loc5_42.1 // CHECK:STDOUT: return %.loc5_42.2 @@ -270,7 +274,7 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @GetAddr.%ptr.loc7_29.1 (%ptr.955) = name_ref self, %self // CHECK:STDOUT: %.loc7_54.1: ref @GetAddr.%Class (%Class.fe1) = deref %self.ref -// CHECK:STDOUT: %x.ref: @GetAddr.%Class.elem (%Class.elem.e26) = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %x.ref: @GetAddr.%Class.elem (%Class.elem.e26) = name_ref x, @Class.%.loc3_8 [template = @Class.%.loc3_8] // CHECK:STDOUT: %.loc7_54.2: ref @GetAddr.%T (%T) = class_element_access %.loc7_54.1, element0 // CHECK:STDOUT: %addr: @GetAddr.%ptr.loc7_38.1 (%ptr.79f) = addr_of %.loc7_54.2 // CHECK:STDOUT: return %addr @@ -280,7 +284,7 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) { // CHECK:STDOUT: fn @DirectFieldAccess(%x.param_patt: %Class.247) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref.loc11_10: %Class.247 = name_ref x, %x -// CHECK:STDOUT: %x.ref.loc11_11: %Class.elem.2d8 = name_ref x, @Class.%.loc3 [template = @Class.%.loc3] +// CHECK:STDOUT: %x.ref.loc11_11: %Class.elem.2d8 = name_ref x, @Class.%.loc3_8 [template = @Class.%.loc3_8] // CHECK:STDOUT: %.loc11_11.1: ref %i32 = class_element_access %x.ref.loc11_10, element0 // CHECK:STDOUT: %.loc11_11.2: %i32 = bind_value %.loc11_11.1 // CHECK:STDOUT: return %.loc11_11.2 diff --git a/toolchain/check/testdata/class/generic/member_inline.carbon b/toolchain/check/testdata/class/generic/member_inline.carbon index cb54ec4f4e89..197eab27595e 100644 --- a/toolchain/check/testdata/class/generic/member_inline.carbon +++ b/toolchain/check/testdata/class/generic/member_inline.carbon @@ -125,7 +125,11 @@ class C(T:! type) { // CHECK:STDOUT: %return.param: ref @G.%T (%T) = out_param runtime_param1 // CHECK:STDOUT: %return: ref @G.%T (%T) = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc13: @Class.%Class.elem (%Class.elem) = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc13_8: @Class.%Class.elem (%Class.elem) = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: @Class.%Class.elem (%Class.elem) = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem) = var // CHECK:STDOUT: %complete_type.loc14_1.1: = complete_type_witness %struct_type.n [symbolic = %complete_type.loc14_1.2 (constants.%complete_type)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc14_1.1 // CHECK:STDOUT: } @@ -156,7 +160,7 @@ class C(T:! type) { // CHECK:STDOUT: fn[%self.param_patt: @G.%Class (%Class)]() -> @G.%T (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @G.%Class (%Class) = name_ref self, %self -// CHECK:STDOUT: %n.ref: @G.%Class.elem (%Class.elem) = name_ref n, @Class.%.loc13 [template = @Class.%.loc13] +// CHECK:STDOUT: %n.ref: @G.%Class.elem (%Class.elem) = name_ref n, @Class.%.loc13_8 [template = @Class.%.loc13_8] // CHECK:STDOUT: %.loc10_16.1: ref @G.%T (%T) = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc10_16.2: @G.%T (%T) = bind_value %.loc10_16.1 // CHECK:STDOUT: return %.loc10_16.2 @@ -242,7 +246,11 @@ class C(T:! type) { // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: %F.decl: @C.%F.type (%F.type) = fn_decl @F [symbolic = @C.%F (constants.%F)] {} {} -// CHECK:STDOUT: %.loc12: @C.%C.elem (%C.elem) = field_decl data, element0 [template] +// CHECK:STDOUT: %.loc12_11: @C.%C.elem (%C.elem) = field_decl data, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: @C.%C.elem (%C.elem) = var_pattern %.loc12_11 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @C.%C.elem (%C.elem) = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.data [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -256,7 +264,7 @@ class C(T:! type) { // CHECK:STDOUT: // CHECK:STDOUT: fn() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %data.ref: @F.%C.elem (%C.elem) = name_ref data, @C.%.loc12 [template = @C.%.loc12] +// CHECK:STDOUT: %data.ref: @F.%C.elem (%C.elem) = name_ref data, @C.%.loc12_11 [template = @C.%.loc12_11] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/generic/member_lookup.carbon b/toolchain/check/testdata/class/generic/member_lookup.carbon index fdc5abda45b3..0ec270c57bf7 100644 --- a/toolchain/check/testdata/class/generic/member_lookup.carbon +++ b/toolchain/check/testdata/class/generic/member_lookup.carbon @@ -219,7 +219,11 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @Base.%struct_type.b (%struct_type.b.f69) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.eaf)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @Base.%Base.elem (%Base.elem.9af) = field_decl b, element0 [template] +// CHECK:STDOUT: %.loc5_8: @Base.%Base.elem (%Base.elem.9af) = field_decl b, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @Base.%Base.elem (%Base.elem.9af) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Base.%Base.elem (%Base.elem.9af) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.b.f69 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.eaf)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } @@ -244,7 +248,11 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc8_15.1 [symbolic = %T.loc8_15.2 (constants.%T)] // CHECK:STDOUT: %Base.loc9_22.1: type = class_type @Base, @Base(constants.%T) [symbolic = %Base.loc9_22.2 (constants.%Base.370)] // CHECK:STDOUT: %.loc9: @Derived.%Derived.elem.loc9 (%Derived.elem.8b3) = base_decl %Base.loc9_22.1, element0 [template] -// CHECK:STDOUT: %.loc10: @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc10_8: @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = var // CHECK:STDOUT: %complete_type.loc11_1.1: = complete_type_witness %struct_type.base.d.37c [symbolic = %complete_type.loc11_1.2 (constants.%complete_type.8ad)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc11_1.1 // CHECK:STDOUT: } @@ -263,7 +271,7 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: fn[%T.param_patt: type](%x.param_patt: @AccessDerived.%Derived.loc13_40.2 (%Derived.85c)) -> @AccessDerived.%T.loc13_18.2 (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: @AccessDerived.%Derived.loc13_40.2 (%Derived.85c) = name_ref x, %x -// CHECK:STDOUT: %d.ref: @AccessDerived.%Derived.elem (%Derived.elem.6d2) = name_ref d, @Derived.%.loc10 [template = @Derived.%.loc10] +// CHECK:STDOUT: %d.ref: @AccessDerived.%Derived.elem (%Derived.elem.6d2) = name_ref d, @Derived.%.loc10_8 [template = @Derived.%.loc10_8] // CHECK:STDOUT: %.loc14_11.1: ref @AccessDerived.%T.loc13_18.2 (%T) = class_element_access %x.ref, element1 // CHECK:STDOUT: %.loc14_11.2: @AccessDerived.%T.loc13_18.2 (%T) = bind_value %.loc14_11.1 // CHECK:STDOUT: return %.loc14_11.2 @@ -285,7 +293,7 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: fn[%T.param_patt: type](%x.param_patt: @AccessBase.%Derived.loc17_37.2 (%Derived.85c)) -> @AccessBase.%T.loc17_15.2 (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: @AccessBase.%Derived.loc17_37.2 (%Derived.85c) = name_ref x, %x -// CHECK:STDOUT: %b.ref: @AccessBase.%Base.elem (%Base.elem.9af) = name_ref b, @Base.%.loc5 [template = @Base.%.loc5] +// CHECK:STDOUT: %b.ref: @AccessBase.%Base.elem (%Base.elem.9af) = name_ref b, @Base.%.loc5_8 [template = @Base.%.loc5_8] // CHECK:STDOUT: %.loc18_11.1: ref @AccessBase.%Base (%Base.370) = class_element_access %x.ref, element0 // CHECK:STDOUT: %.loc18_11.2: ref @AccessBase.%Base (%Base.370) = converted %x.ref, %.loc18_11.1 // CHECK:STDOUT: %.loc18_11.3: ref @AccessBase.%T.loc17_15.2 (%T) = class_element_access %.loc18_11.2, element0 @@ -297,7 +305,7 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: fn @AccessConcrete(%x.param_patt: %Derived.115) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.ref: %Derived.115 = name_ref x, %x -// CHECK:STDOUT: %b.ref: %Base.elem.a98 = name_ref b, @Base.%.loc5 [template = @Base.%.loc5] +// CHECK:STDOUT: %b.ref: %Base.elem.a98 = name_ref b, @Base.%.loc5_8 [template = @Base.%.loc5_8] // CHECK:STDOUT: %.loc22_11.1: ref %Base.10a = class_element_access %x.ref, element0 // CHECK:STDOUT: %.loc22_11.2: ref %Base.10a = converted %x.ref, %.loc22_11.1 // CHECK:STDOUT: %.loc22_11.3: ref %i32 = class_element_access %.loc22_11.2, element0 @@ -532,7 +540,11 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: %complete_type.loc6_1.2: = complete_type_witness @Base.%struct_type.b (%struct_type.b.f69) [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.eaf)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc5: @Base.%Base.elem (%Base.elem.9af) = field_decl b, element0 [template] +// CHECK:STDOUT: %.loc5_8: @Base.%Base.elem (%Base.elem.9af) = field_decl b, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: @Base.%Base.elem (%Base.elem.9af) = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Base.%Base.elem (%Base.elem.9af) = var // CHECK:STDOUT: %complete_type.loc6_1.1: = complete_type_witness %struct_type.b.f69 [symbolic = %complete_type.loc6_1.2 (constants.%complete_type.eaf)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc6_1.1 // CHECK:STDOUT: } @@ -557,7 +569,11 @@ fn AccessMissingConcrete(x: Derived(i32)) -> i32 { // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc8_15.1 [symbolic = %T.loc8_15.2 (constants.%T)] // CHECK:STDOUT: %Base.loc9_22.1: type = class_type @Base, @Base(constants.%T) [symbolic = %Base.loc9_22.2 (constants.%Base.370)] // CHECK:STDOUT: %.loc9: @Derived.%Derived.elem.loc9 (%Derived.elem.8b3) = base_decl %Base.loc9_22.1, element0 [template] -// CHECK:STDOUT: %.loc10: @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc10_8: @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Derived.%Derived.elem.loc10 (%Derived.elem.6d2) = var // CHECK:STDOUT: %complete_type.loc11_1.1: = complete_type_witness %struct_type.base.d.37c [symbolic = %complete_type.loc11_1.2 (constants.%complete_type.8ad)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc11_1.1 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/generic/member_out_of_line.carbon b/toolchain/check/testdata/class/generic/member_out_of_line.carbon index c2b7c2b40187..331797634b1b 100644 --- a/toolchain/check/testdata/class/generic/member_out_of_line.carbon +++ b/toolchain/check/testdata/class/generic/member_out_of_line.carbon @@ -225,7 +225,11 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: %return.param.loc6: ref @G.%T.loc6 (%T) = out_param runtime_param1 // CHECK:STDOUT: %return.loc6: ref @G.%T.loc6 (%T) = return_slot %return.param.loc6 // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: @Class.%Class.elem (%Class.elem) = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc7_8: @Class.%Class.elem (%Class.elem) = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc7_3: @Class.%Class.elem (%Class.elem) = var_pattern %.loc7_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem) = var // CHECK:STDOUT: %complete_type.loc8_1.1: = complete_type_witness %struct_type.n [symbolic = %complete_type.loc8_1.2 (constants.%complete_type)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc8_1.1 // CHECK:STDOUT: } @@ -256,7 +260,7 @@ fn Generic(T:! ()).WrongType() {} // CHECK:STDOUT: fn[%self.param_patt: %Class]() -> %T { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @G.%Class (%Class) = name_ref self, %self.loc14 -// CHECK:STDOUT: %n.ref: @G.%Class.elem (%Class.elem) = name_ref n, @Class.%.loc7 [template = @Class.%.loc7] +// CHECK:STDOUT: %n.ref: @G.%Class.elem (%Class.elem) = name_ref n, @Class.%.loc7_8 [template = @Class.%.loc7_8] // CHECK:STDOUT: %.loc15_14.1: ref @G.%T.loc6 (%T) = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc15_14.2: @G.%T.loc6 (%T) = bind_value %.loc15_14.1 // CHECK:STDOUT: return %.loc15_14.2 diff --git a/toolchain/check/testdata/class/generic/self.carbon b/toolchain/check/testdata/class/generic/self.carbon index 85e273b047c2..a25da0f6899a 100644 --- a/toolchain/check/testdata/class/generic/self.carbon +++ b/toolchain/check/testdata/class/generic/self.carbon @@ -138,8 +138,8 @@ class Class(T:! type) { // CHECK:STDOUT: generic fn @F(@Class.%T.loc11_13.1: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] -// CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class)] -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%Class (%Class) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: %Class.loc17_19.2: type = class_type @Class, @Class(%T) [symbolic = %Class.loc17_19.2 (constants.%Class)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%Class.loc17_19.2 (%Class) [symbolic = %require_complete (constants.%require_complete)] // CHECK:STDOUT: %MakeSelf.type: type = fn_type @MakeSelf, @Class(%T) [symbolic = %MakeSelf.type (constants.%MakeSelf.type)] // CHECK:STDOUT: %MakeSelf: @F.%MakeSelf.type (%MakeSelf.type) = struct_value () [symbolic = %MakeSelf (constants.%MakeSelf)] // CHECK:STDOUT: %MakeSelf.specific_fn.loc17_23.2: = specific_function %MakeSelf, @MakeSelf(%T) [symbolic = %MakeSelf.specific_fn.loc17_23.2 (constants.%MakeSelf.specific_fn)] @@ -149,22 +149,39 @@ class Class(T:! type) { // CHECK:STDOUT: // CHECK:STDOUT: fn() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %c.var: ref @F.%Class (%Class) = var c -// CHECK:STDOUT: %c: ref @F.%Class (%Class) = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: @F.%Class.loc17_19.2 (%Class) = binding_pattern c +// CHECK:STDOUT: %.loc17_5.1: @F.%Class.loc17_19.2 (%Class) = var_pattern %c.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %c.var: ref @F.%Class.loc17_19.2 (%Class) = var c // CHECK:STDOUT: %.loc17_23: @F.%MakeSelf.type (%MakeSelf.type) = specific_constant @Class.%MakeSelf.decl, @Class(constants.%T) [symbolic = %MakeSelf (constants.%MakeSelf)] // CHECK:STDOUT: %MakeSelf.ref: @F.%MakeSelf.type (%MakeSelf.type) = name_ref MakeSelf, %.loc17_23 [symbolic = %MakeSelf (constants.%MakeSelf)] // CHECK:STDOUT: %MakeSelf.specific_fn.loc17_23.1: = specific_function %MakeSelf.ref, @MakeSelf(constants.%T) [symbolic = %MakeSelf.specific_fn.loc17_23.2 (constants.%MakeSelf.specific_fn)] -// CHECK:STDOUT: %.loc17_9: ref @F.%Class (%Class) = splice_block %c.var {} -// CHECK:STDOUT: %MakeSelf.call: init @F.%Class (%Class) = call %MakeSelf.specific_fn.loc17_23.1() to %.loc17_9 +// CHECK:STDOUT: %.loc17_5.2: ref @F.%Class.loc17_19.2 (%Class) = splice_block %c.var {} +// CHECK:STDOUT: %MakeSelf.call: init @F.%Class.loc17_19.2 (%Class) = call %MakeSelf.specific_fn.loc17_23.1() to %.loc17_5.2 // CHECK:STDOUT: assign %c.var, %MakeSelf.call -// CHECK:STDOUT: %s.var: ref @F.%Class (%Class) = var s -// CHECK:STDOUT: %s: ref @F.%Class (%Class) = bind_name s, %s.var +// CHECK:STDOUT: %.loc17_19: type = splice_block %Class.loc17_19.1 [symbolic = %Class.loc17_19.2 (constants.%Class)] { +// CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.generic] +// CHECK:STDOUT: %T.ref: type = name_ref T, @Class.%T.loc11_13.1 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %Class.loc17_19.1: type = class_type @Class, @Class(constants.%T) [symbolic = %Class.loc17_19.2 (constants.%Class)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c: ref @F.%Class.loc17_19.2 (%Class) = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: @F.%Class.loc17_19.2 (%Class) = binding_pattern s +// CHECK:STDOUT: %.loc18_5.1: @F.%Class.loc17_19.2 (%Class) = var_pattern %s.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %s.var: ref @F.%Class.loc17_19.2 (%Class) = var s // CHECK:STDOUT: %.loc18_19: @F.%MakeClass.type (%MakeClass.type) = specific_constant @Class.%MakeClass.decl, @Class(constants.%T) [symbolic = %MakeClass (constants.%MakeClass)] // CHECK:STDOUT: %MakeClass.ref: @F.%MakeClass.type (%MakeClass.type) = name_ref MakeClass, %.loc18_19 [symbolic = %MakeClass (constants.%MakeClass)] // CHECK:STDOUT: %MakeClass.specific_fn.loc18_19.1: = specific_function %MakeClass.ref, @MakeClass(constants.%T) [symbolic = %MakeClass.specific_fn.loc18_19.2 (constants.%MakeClass.specific_fn)] -// CHECK:STDOUT: %.loc18_9: ref @F.%Class (%Class) = splice_block %s.var {} -// CHECK:STDOUT: %MakeClass.call: init @F.%Class (%Class) = call %MakeClass.specific_fn.loc18_19.1() to %.loc18_9 +// CHECK:STDOUT: %.loc18_5.2: ref @F.%Class.loc17_19.2 (%Class) = splice_block %s.var {} +// CHECK:STDOUT: %MakeClass.call: init @F.%Class.loc17_19.2 (%Class) = call %MakeClass.specific_fn.loc18_19.1() to %.loc18_5.2 // CHECK:STDOUT: assign %s.var, %MakeClass.call +// CHECK:STDOUT: %.loc18_12.1: type = splice_block %Self.ref [symbolic = %Class.loc17_19.2 (constants.%Class)] { +// CHECK:STDOUT: %.loc18_12.2: type = specific_constant constants.%Class, @Class(constants.%T) [symbolic = %Class.loc17_19.2 (constants.%Class)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc18_12.2 [symbolic = %Class.loc17_19.2 (constants.%Class)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: ref @F.%Class.loc17_19.2 (%Class) = bind_name s, %s.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/generic/stringify.carbon b/toolchain/check/testdata/class/generic/stringify.carbon index b07a7af503c8..af6be2f423ea 100644 --- a/toolchain/check/testdata/class/generic/stringify.carbon +++ b/toolchain/check/testdata/class/generic/stringify.carbon @@ -18,10 +18,10 @@ class EmptyParams() {} var v: NoParams; // CHECK:STDERR: fail_empty_params.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `NoParams` to `EmptyParams()` [ImplicitAsConversionFailure] // CHECK:STDERR: var w: EmptyParams() = v; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_empty_params.carbon:[[@LINE+4]]:1: note: type `NoParams` does not implement interface `Core.ImplicitAs(EmptyParams())` [MissingImplInMemberAccessNote] // CHECK:STDERR: var w: EmptyParams() = v; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var w: EmptyParams() = v; @@ -39,10 +39,10 @@ var v: Outer({}*); // TODO: It would be nice to include the `Outer({}*).` prefix in the name of `Inner`. // CHECK:STDERR: fail_nested.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `Outer({}*)` to `Inner({.a: i32}*)` [ImplicitAsConversionFailure] // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_nested.carbon:[[@LINE+4]]:1: note: type `Outer({}*)` does not implement interface `Core.ImplicitAs(Inner({.a: i32}*))` [MissingImplInMemberAccessNote] // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v; @@ -54,10 +54,10 @@ class C(N:! i32) {} // CHECK:STDERR: fail_int_value.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `()` to `C(123)` [ImplicitAsConversionFailure] // CHECK:STDERR: var v: C(123) = (); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: fail_int_value.carbon:[[@LINE+4]]:1: note: type `()` does not implement interface `Core.ImplicitAs(C(123))` [MissingImplInMemberAccessNote] // CHECK:STDERR: var v: C(123) = (); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: var v: C(123) = (); @@ -118,9 +118,22 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %NoParams.decl: type = class_decl @NoParams [template = constants.%NoParams] {} {} // CHECK:STDOUT: %EmptyParams.decl: %EmptyParams.type = class_decl @EmptyParams [template = constants.%EmptyParams.generic] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %NoParams = binding_pattern v +// CHECK:STDOUT: %.loc7: %NoParams = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %NoParams = var v +// CHECK:STDOUT: %NoParams.ref: type = name_ref NoParams, %NoParams.decl [template = constants.%NoParams] // CHECK:STDOUT: %v: ref %NoParams = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %EmptyParams = binding_pattern w +// CHECK:STDOUT: %.loc15_1: %EmptyParams = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %EmptyParams = var w +// CHECK:STDOUT: %.loc15_20: type = splice_block %EmptyParams [template = constants.%EmptyParams] { +// CHECK:STDOUT: %EmptyParams.ref: %EmptyParams.type = name_ref EmptyParams, %EmptyParams.decl [template = constants.%EmptyParams.generic] +// CHECK:STDOUT: %EmptyParams: type = class_type @EmptyParams [template = constants.%EmptyParams] +// CHECK:STDOUT: } // CHECK:STDOUT: %w: ref %EmptyParams = bind_name w, %w.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -190,9 +203,38 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc4_13.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_13.2 (constants.%T)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %Outer.614 = binding_pattern v +// CHECK:STDOUT: %.loc9_1: %Outer.614 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %Outer.614 = var v +// CHECK:STDOUT: %.loc9_17: type = splice_block %Outer.loc9 [template = constants.%Outer.614] { +// CHECK:STDOUT: %Outer.ref.loc9: %Outer.type = name_ref Outer, %Outer.decl [template = constants.%Outer.generic] +// CHECK:STDOUT: %.loc9_15: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_16: type = converted %.loc9_15, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %ptr.loc9: type = ptr_type %empty_struct_type [template = constants.%ptr.c28] +// CHECK:STDOUT: %Outer.loc9: type = class_type @Outer, @Outer(constants.%ptr.c28) [template = constants.%Outer.614] +// CHECK:STDOUT: } // CHECK:STDOUT: %v: ref %Outer.614 = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %Inner.277 = binding_pattern w +// CHECK:STDOUT: %.loc19_1: %Inner.277 = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %Inner.277 = var w +// CHECK:STDOUT: %.loc19_35: type = splice_block %Inner [template = constants.%Inner.277] { +// CHECK:STDOUT: %Outer.ref.loc19: %Outer.type = name_ref Outer, %Outer.decl [template = constants.%Outer.generic] +// CHECK:STDOUT: %.loc19_15: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc19_16: type = converted %.loc19_15, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %ptr.loc19_16: type = ptr_type %empty_struct_type [template = constants.%ptr.c28] +// CHECK:STDOUT: %Outer.loc19: type = class_type @Outer, @Outer(constants.%ptr.c28) [template = constants.%Outer.614] +// CHECK:STDOUT: %.loc19_18: %Inner.type.5d2 = specific_constant @Outer.%Inner.decl, @Outer(constants.%ptr.c28) [template = constants.%Inner.generic.8e6] +// CHECK:STDOUT: %Inner.ref: %Inner.type.5d2 = name_ref Inner, %.loc19_18 [template = constants.%Inner.generic.8e6] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a] +// CHECK:STDOUT: %ptr.loc19_34: type = ptr_type %struct_type.a [template = constants.%ptr.1bb] +// CHECK:STDOUT: %Inner: type = class_type @Inner, @Inner(constants.%ptr.c28, constants.%ptr.1bb) [template = constants.%Inner.277] +// CHECK:STDOUT: } // CHECK:STDOUT: %w: ref %Inner.277 = bind_name w, %w.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -277,6 +319,13 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %int_123.fff: Core.IntLiteral = int_value 123 [template] +// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_123.fff, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_123.f7f: %i32 = int_value 123 [template] // CHECK:STDOUT: %C.4c3: type = class_type @C, @C(%int_123.f7f) [template] // CHECK:STDOUT: } @@ -308,7 +357,22 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc4_9.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc4_9.2 (constants.%N.51e)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %C.4c3 = binding_pattern v +// CHECK:STDOUT: %.loc13_1: %C.4c3 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %C.4c3 = var v +// CHECK:STDOUT: %.loc13_13.1: type = splice_block %C [template = constants.%C.4c3] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %int_123: Core.IntLiteral = int_value 123 [template = constants.%int_123.fff] +// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_123, %impl.elem0 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_123) [template = constants.%int_123.f7f] +// CHECK:STDOUT: %.loc13_13.2: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_123.f7f] +// CHECK:STDOUT: %.loc13_13.3: %i32 = converted %int_123, %.loc13_13.2 [template = constants.%int_123.f7f] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%int_123.f7f) [template = constants.%C.4c3] +// CHECK:STDOUT: } // CHECK:STDOUT: %v: ref %C.4c3 = bind_name v, %v.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -327,7 +391,7 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_18: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc13_19: %C.4c3 = converted %.loc13_18, [template = ] +// CHECK:STDOUT: %.loc13_1: %C.4c3 = converted %.loc13_18, [template = ] // CHECK:STDOUT: assign file.%v.var, // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -359,11 +423,20 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: %E.generic: %E.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.ab5: = bound_method %int_1.5b8, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.70c: = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template] +// CHECK:STDOUT: %Convert.bound.ef9: = bound_method %int_2.ecc, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.787: = specific_function %Convert.bound.ef9, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template] +// CHECK:STDOUT: %D.val.413: %D = struct_value (%int_1.5d2, %int_2.ef8) [template] // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template] // CHECK:STDOUT: %Convert.bound.b30: = bound_method %int_3.1ba, %Convert.956 [template] @@ -401,13 +474,50 @@ var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D); // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D] // CHECK:STDOUT: %F.loc9_9.1: %D = bind_symbolic_name F, 0, %F.param [symbolic = %F.loc9_9.2 (constants.%F)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %g.patt: = binding_pattern g +// CHECK:STDOUT: %.loc25_1: = var_pattern %g.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %g.var: ref = var g -// CHECK:STDOUT: %g: ref = bind_name g, %g.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %E.ref: %E.type = name_ref E, %E.decl [template = constants.%E.generic] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc25_25.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) +// CHECK:STDOUT: %impl.elem0.loc25_25.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc25_25.1: = bound_method %int_1, %impl.elem0.loc25_25.1 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc25_25.1: = specific_function %Convert.bound.loc25_25.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc25_25.1: init %i32 = call %Convert.specific_fn.loc25_25.1(%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc25_25.2: init %i32 = converted %int_1, %int.convert_checked.loc25_25.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc25_25.3: ref %D = temporary_storage +// CHECK:STDOUT: %.loc25_25.4: ref %i32 = class_element_access %.loc25_25.3, element0 +// CHECK:STDOUT: %.loc25_25.5: init %i32 = initialize_from %.loc25_25.2 to %.loc25_25.4 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc25_25.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc25_25.2: = bound_method %int_2, %impl.elem0.loc25_25.2 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc25_25.2: = specific_function %Convert.bound.loc25_25.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc25_25.2: init %i32 = call %Convert.specific_fn.loc25_25.2(%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc25_25.6: init %i32 = converted %int_2, %int.convert_checked.loc25_25.2 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc25_25.7: ref %i32 = class_element_access %.loc25_25.3, element1 +// CHECK:STDOUT: %.loc25_25.8: init %i32 = initialize_from %.loc25_25.6 to %.loc25_25.7 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc25_25.9: init %D = class_init (%.loc25_25.5, %.loc25_25.8), %.loc25_25.3 [template = constants.%D.val.413] +// CHECK:STDOUT: %.loc25_25.10: ref %D = temporary %.loc25_25.3, %.loc25_25.9 +// CHECK:STDOUT: %.loc25_26.1: ref %D = converted %.loc25_25.1, %.loc25_25.10 +// CHECK:STDOUT: %.loc25_26.2: %D = bind_value %.loc25_26.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: %g: = bind_name g, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @D { -// CHECK:STDOUT: %.loc5: %D.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc6: %D.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc5_8: %D.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %D.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %D.elem = var +// CHECK:STDOUT: %.loc6_8: %D.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %D.elem = var_pattern %.loc6_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %D.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/generic_method.carbon b/toolchain/check/testdata/class/generic_method.carbon index 88dd751c7e2b..4eaec09bdc8d 100644 --- a/toolchain/check/testdata/class/generic_method.carbon +++ b/toolchain/check/testdata/class/generic_method.carbon @@ -86,7 +86,11 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: %complete_type.loc14_1.2: = complete_type_witness @Class.%struct_type.a (%struct_type.a) [symbolic = %complete_type.loc14_1.2 (constants.%complete_type)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc12: @Class.%Class.elem (%Class.elem) = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: @Class.%Class.elem (%Class.elem) = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: @Class.%Class.elem (%Class.elem) = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @Class.%Class.elem (%Class.elem) = var // CHECK:STDOUT: %F.decl: @Class.%F.type (%F.type) = fn_decl @F [symbolic = @Class.%F (constants.%F)] { // CHECK:STDOUT: %self.patt: %Class = binding_pattern self // CHECK:STDOUT: %self.param_patt: %Class = value_param_pattern %self.patt, runtime_param0 diff --git a/toolchain/check/testdata/class/import.carbon b/toolchain/check/testdata/class/import.carbon index 2db894519d34..52176790d86a 100644 --- a/toolchain/check/testdata/class/import.carbon +++ b/toolchain/check/testdata/class/import.carbon @@ -100,7 +100,11 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Field { -// CHECK:STDOUT: %.loc8: %Field.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc8_8: %Field.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc8_3: %Field.elem = var_pattern %.loc8_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Field.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type.1ec] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -230,14 +234,22 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %Empty = binding_pattern a +// CHECK:STDOUT: %.loc7_3.1: %Empty = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %Empty = var a -// CHECK:STDOUT: %a: ref %Empty = bind_name a, %a.var // CHECK:STDOUT: %.loc7_19.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_19.2: init %Empty = class_init (), %a.var [template = constants.%Empty.val] -// CHECK:STDOUT: %.loc7_20: init %Empty = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%Empty.val] -// CHECK:STDOUT: assign %a.var, %.loc7_20 +// CHECK:STDOUT: %.loc7_3.2: init %Empty = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%Empty.val] +// CHECK:STDOUT: assign %a.var, %.loc7_3.2 +// CHECK:STDOUT: %Empty.ref: type = name_ref Empty, imports.%import_ref.e6e [template = constants.%Empty] +// CHECK:STDOUT: %a: ref %Empty = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %Field = binding_pattern b +// CHECK:STDOUT: %.loc9_3.1: %Field = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %Field = var b -// CHECK:STDOUT: %b: ref %Field = bind_name b, %b.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc9_25.1: %struct_type.x.c96 = struct_literal (%int_1) // CHECK:STDOUT: %impl.elem0.loc9: %Convert.type.6da = impl_witness_access constants.%impl_witness.b97, element0 [template = constants.%Convert.16d] @@ -248,8 +260,10 @@ fn Run() { // CHECK:STDOUT: %.loc9_25.3: ref %i32 = class_element_access %b.var, element0 // CHECK:STDOUT: %.loc9_25.4: init %i32 = initialize_from %.loc9_25.2 to %.loc9_25.3 [template = constants.%int_1.47b] // CHECK:STDOUT: %.loc9_25.5: init %Field = class_init (%.loc9_25.4), %b.var [template = constants.%Field.val] -// CHECK:STDOUT: %.loc9_26: init %Field = converted %.loc9_25.1, %.loc9_25.5 [template = constants.%Field.val] -// CHECK:STDOUT: assign %b.var, %.loc9_26 +// CHECK:STDOUT: %.loc9_3.2: init %Field = converted %.loc9_25.1, %.loc9_25.5 [template = constants.%Field.val] +// CHECK:STDOUT: assign %b.var, %.loc9_3.2 +// CHECK:STDOUT: %Field.ref: type = name_ref Field, imports.%import_ref.53b [template = constants.%Field] +// CHECK:STDOUT: %b: ref %Field = bind_name b, %b.var // CHECK:STDOUT: %b.ref: ref %Field = name_ref b, %b // CHECK:STDOUT: %x.ref: %Field.elem = name_ref x, imports.%import_ref.4d2 [template = imports.%.d33] // CHECK:STDOUT: %.loc10_4: ref %i32 = class_element_access %b.ref, element0 @@ -260,12 +274,17 @@ fn Run() { // CHECK:STDOUT: %int.convert_checked.loc10: init %i32 = call %Convert.specific_fn.loc10(%int_2) [template = constants.%int_2.d0d] // CHECK:STDOUT: %.loc10_7: init %i32 = converted %int_2, %int.convert_checked.loc10 [template = constants.%int_2.d0d] // CHECK:STDOUT: assign %.loc10_4, %.loc10_7 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %ForwardDeclared.7b34f2.1 = binding_pattern c +// CHECK:STDOUT: %.loc12_3.1: %ForwardDeclared.7b34f2.1 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %ForwardDeclared.7b34f2.1 = var c -// CHECK:STDOUT: %c: ref %ForwardDeclared.7b34f2.1 = bind_name c, %c.var // CHECK:STDOUT: %.loc12_29.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc12_29.2: init %ForwardDeclared.7b34f2.1 = class_init (), %c.var [template = constants.%ForwardDeclared.val] -// CHECK:STDOUT: %.loc12_30: init %ForwardDeclared.7b34f2.1 = converted %.loc12_29.1, %.loc12_29.2 [template = constants.%ForwardDeclared.val] -// CHECK:STDOUT: assign %c.var, %.loc12_30 +// CHECK:STDOUT: %.loc12_3.2: init %ForwardDeclared.7b34f2.1 = converted %.loc12_29.1, %.loc12_29.2 [template = constants.%ForwardDeclared.val] +// CHECK:STDOUT: assign %c.var, %.loc12_3.2 +// CHECK:STDOUT: %ForwardDeclared.ref.loc12: type = name_ref ForwardDeclared, imports.%import_ref.046 [template = constants.%ForwardDeclared.7b34f2.1] +// CHECK:STDOUT: %c: ref %ForwardDeclared.7b34f2.1 = bind_name c, %c.var // CHECK:STDOUT: %c.ref.loc13: ref %ForwardDeclared.7b34f2.1 = name_ref c, %c // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.760 [template = constants.%F] // CHECK:STDOUT: %F.bound: = bound_method %c.ref.loc13, %F.ref @@ -276,17 +295,33 @@ fn Run() { // CHECK:STDOUT: %G.bound: = bound_method %c.ref.loc14, %G.ref // CHECK:STDOUT: %addr.loc14: %ptr.6cf = addr_of %c.ref.loc14 // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.bound(%addr.loc14) +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %ptr.6cf = binding_pattern d +// CHECK:STDOUT: %.loc16_3: %ptr.6cf = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %ptr.6cf = var d -// CHECK:STDOUT: %d: ref %ptr.6cf = bind_name d, %d.var // CHECK:STDOUT: %c.ref.loc16: ref %ForwardDeclared.7b34f2.1 = name_ref c, %c // CHECK:STDOUT: %addr.loc16: %ptr.6cf = addr_of %c.ref.loc16 // CHECK:STDOUT: assign %d.var, %addr.loc16 +// CHECK:STDOUT: %.loc16_25: type = splice_block %ptr.loc16 [template = constants.%ptr.6cf] { +// CHECK:STDOUT: %ForwardDeclared.ref.loc16: type = name_ref ForwardDeclared, imports.%import_ref.046 [template = constants.%ForwardDeclared.7b34f2.1] +// CHECK:STDOUT: %ptr.loc16: type = ptr_type %ForwardDeclared.7b34f2.1 [template = constants.%ptr.6cf] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d: ref %ptr.6cf = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %ptr.c62 = binding_pattern e +// CHECK:STDOUT: %.loc18_3: %ptr.c62 = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %ptr.c62 = var e +// CHECK:STDOUT: %.loc18_20: type = splice_block %ptr.loc18 [template = constants.%ptr.c62] { +// CHECK:STDOUT: %Incomplete.ref: type = name_ref Incomplete, imports.%import_ref.9b0 [template = constants.%Incomplete] +// CHECK:STDOUT: %ptr.loc18: type = ptr_type %Incomplete [template = constants.%ptr.c62] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %ptr.c62 = bind_name e, %e.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F[%self.param_patt: %ForwardDeclared.7b34f2.1]() [from "a.carbon"]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G[addr .inst1067: %ptr.6cf]() [from "a.carbon"]; +// CHECK:STDOUT: fn @G[addr .inst1076: %ptr.6cf]() [from "a.carbon"]; // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/import_base.carbon b/toolchain/check/testdata/class/import_base.carbon index 3ade23a2b42f..6d7eab576b3f 100644 --- a/toolchain/check/testdata/class/import_base.carbon +++ b/toolchain/check/testdata/class/import_base.carbon @@ -91,8 +91,16 @@ fn Run() { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [template = constants.%Base] // CHECK:STDOUT: %self: %Base = bind_name self, %self.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc8: %Base.elem = field_decl x, element0 [template] -// CHECK:STDOUT: %.loc9: %Base.elem = field_decl unused, element1 [template] +// CHECK:STDOUT: %.loc8_8: %Base.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc8_3: %Base.elem = var_pattern %.loc8_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc8: ref %Base.elem = var +// CHECK:STDOUT: %.loc9_13: %Base.elem = field_decl unused, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc9_3: %Base.elem = var_pattern %.loc9_13 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc9: ref %Base.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x.unused [template = constants.%complete_type.20c] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -183,8 +191,11 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %Child = binding_pattern a +// CHECK:STDOUT: %.loc7_3.1: %Child = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %Child = var a -// CHECK:STDOUT: %a: ref %Child = bind_name a, %a.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc7_47.1: %struct_type.x.unused.c45 = struct_literal (%int_0, %int_1) @@ -207,8 +218,10 @@ fn Run() { // CHECK:STDOUT: %.loc7_47.8: init %Base = class_init (%.loc7_47.4, %.loc7_47.7), %.loc7_48.2 [template = constants.%Base.val] // CHECK:STDOUT: %.loc7_48.3: init %Base = converted %.loc7_47.1, %.loc7_47.8 [template = constants.%Base.val] // CHECK:STDOUT: %.loc7_48.4: init %Child = class_init (%.loc7_48.3), %a.var [template = constants.%Child.val] -// CHECK:STDOUT: %.loc7_49: init %Child = converted %.loc7_48.1, %.loc7_48.4 [template = constants.%Child.val] -// CHECK:STDOUT: assign %a.var, %.loc7_49 +// CHECK:STDOUT: %.loc7_3.2: init %Child = converted %.loc7_48.1, %.loc7_48.4 [template = constants.%Child.val] +// CHECK:STDOUT: assign %a.var, %.loc7_3.2 +// CHECK:STDOUT: %Child.ref: type = name_ref Child, imports.%import_ref.794 [template = constants.%Child] +// CHECK:STDOUT: %a: ref %Child = bind_name a, %a.var // CHECK:STDOUT: %a.ref.loc8: ref %Child = name_ref a, %a // CHECK:STDOUT: %x.ref: %Base.elem = name_ref x, imports.%import_ref.e67 [template = imports.%.720] // CHECK:STDOUT: %.loc8_4.1: ref %Base = class_element_access %a.ref.loc8, element0 diff --git a/toolchain/check/testdata/class/import_indirect.carbon b/toolchain/check/testdata/class/import_indirect.carbon index e780886bb6fb..a9451ce6a177 100644 --- a/toolchain/check/testdata/class/import_indirect.carbon +++ b/toolchain/check/testdata/class/import_indirect.carbon @@ -158,11 +158,24 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %D: type = bind_alias D, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_val.patt: %C = binding_pattern b_val +// CHECK:STDOUT: %.loc8: %C = var_pattern %b_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_val.var: ref %C = var b_val +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %b_val: ref %C = bind_name b_val, %b_val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_ptr.patt: %ptr.019 = binding_pattern b_ptr +// CHECK:STDOUT: %.loc9_1: %ptr.019 = var_pattern %b_ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ptr.var: ref %ptr.019 = var b_ptr +// CHECK:STDOUT: %.loc9_13: type = splice_block %ptr [template = constants.%ptr.019] { +// CHECK:STDOUT: %D.ref: type = name_ref D, %D [template = constants.%C] +// CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ptr: ref %ptr.019 = bind_name b_ptr, %b_ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -174,8 +187,8 @@ var ptr: E* = &val; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_17.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc8_17.2: init %C = class_init (), file.%b_val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc8_18: init %C = converted %.loc8_17.1, %.loc8_17.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%b_val.var, %.loc8_18 +// CHECK:STDOUT: %.loc8_1: init %C = converted %.loc8_17.1, %.loc8_17.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%b_val.var, %.loc8_1 // CHECK:STDOUT: %b_val.ref: ref %C = name_ref b_val, file.%b_val // CHECK:STDOUT: %addr: %ptr.019 = addr_of %b_val.ref // CHECK:STDOUT: assign file.%b_ptr.var, %addr @@ -211,11 +224,24 @@ var ptr: E* = &val; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc6: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %E: type = bind_alias E, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_val.patt: %C = binding_pattern c_val +// CHECK:STDOUT: %.loc8: %C = var_pattern %c_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_val.var: ref %C = var c_val +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c_val: ref %C = bind_name c_val, %c_val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_ptr.patt: %ptr.019 = binding_pattern c_ptr +// CHECK:STDOUT: %.loc9_1: %ptr.019 = var_pattern %c_ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_ptr.var: ref %ptr.019 = var c_ptr +// CHECK:STDOUT: %.loc9_13: type = splice_block %ptr [template = constants.%ptr.019] { +// CHECK:STDOUT: %E.ref: type = name_ref E, %E [template = constants.%C] +// CHECK:STDOUT: %ptr: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } // CHECK:STDOUT: %c_ptr: ref %ptr.019 = bind_name c_ptr, %c_ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -227,8 +253,8 @@ var ptr: E* = &val; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_17.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc8_17.2: init %C = class_init (), file.%c_val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc8_18: init %C = converted %.loc8_17.1, %.loc8_17.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c_val.var, %.loc8_18 +// CHECK:STDOUT: %.loc8_1: init %C = converted %.loc8_17.1, %.loc8_17.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c_val.var, %.loc8_1 // CHECK:STDOUT: %c_val.ref: ref %C = name_ref c_val, file.%c_val // CHECK:STDOUT: %addr: %ptr.019 = addr_of %c_val.ref // CHECK:STDOUT: assign file.%c_ptr.var, %addr @@ -265,14 +291,27 @@ var ptr: E* = &val; // CHECK:STDOUT: .b_ptr = imports.%import_ref.ff5 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val -// CHECK:STDOUT: .ptr = %ptr +// CHECK:STDOUT: .ptr = %ptr.loc8_5 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %val.patt: %C = binding_pattern val +// CHECK:STDOUT: %.loc7: %C = var_pattern %val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %val.var: ref %C = var val +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ptr.patt: %ptr.019 = binding_pattern ptr +// CHECK:STDOUT: %.loc8_1: %ptr.019 = var_pattern %ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ptr.var: ref %ptr.019 = var ptr -// CHECK:STDOUT: %ptr: ref %ptr.019 = bind_name ptr, %ptr.var +// CHECK:STDOUT: %.loc8_11: type = splice_block %ptr.loc8_11 [template = constants.%ptr.019] { +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.ff6 [template = constants.%C] +// CHECK:STDOUT: %ptr.loc8_11: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ptr.loc8_5: ref %ptr.019 = bind_name ptr, %ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C [from "a.carbon"] { @@ -283,8 +322,8 @@ var ptr: E* = &val; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_15.2: init %C = class_init (), file.%val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_16: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%val.var, %.loc7_16 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%val.var, %.loc7_1 // CHECK:STDOUT: %val.ref: ref %C = name_ref val, file.%val // CHECK:STDOUT: %addr: %ptr.019 = addr_of %val.ref // CHECK:STDOUT: assign file.%ptr.var, %addr @@ -321,14 +360,27 @@ var ptr: E* = &val; // CHECK:STDOUT: .C = imports.%import_ref.3b0 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val -// CHECK:STDOUT: .ptr = %ptr +// CHECK:STDOUT: .ptr = %ptr.loc8_5 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %val.patt: %C = binding_pattern val +// CHECK:STDOUT: %.loc7: %C = var_pattern %val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %val.var: ref %C = var val +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ptr.patt: %ptr.019 = binding_pattern ptr +// CHECK:STDOUT: %.loc8_1: %ptr.019 = var_pattern %ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ptr.var: ref %ptr.019 = var ptr -// CHECK:STDOUT: %ptr: ref %ptr.019 = bind_name ptr, %ptr.var +// CHECK:STDOUT: %.loc8_11: type = splice_block %ptr.loc8_11 [template = constants.%ptr.019] { +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.ff6 [template = constants.%C] +// CHECK:STDOUT: %ptr.loc8_11: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ptr.loc8_5: ref %ptr.019 = bind_name ptr, %ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C [from "a.carbon"] { @@ -339,8 +391,8 @@ var ptr: E* = &val; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_15.2: init %C = class_init (), file.%val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_16: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%val.var, %.loc7_16 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%val.var, %.loc7_1 // CHECK:STDOUT: %val.ref: ref %C = name_ref val, file.%val // CHECK:STDOUT: %addr: %ptr.019 = addr_of %val.ref // CHECK:STDOUT: assign file.%ptr.var, %addr @@ -381,14 +433,27 @@ var ptr: E* = &val; // CHECK:STDOUT: .c_ptr = imports.%import_ref.be6 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val -// CHECK:STDOUT: .ptr = %ptr +// CHECK:STDOUT: .ptr = %ptr.loc8_5 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %val.patt: %C = binding_pattern val +// CHECK:STDOUT: %.loc7: %C = var_pattern %val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %val.var: ref %C = var val +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.ff6 [template = constants.%C] // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ptr.patt: %ptr.019 = binding_pattern ptr +// CHECK:STDOUT: %.loc8_1: %ptr.019 = var_pattern %ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ptr.var: ref %ptr.019 = var ptr -// CHECK:STDOUT: %ptr: ref %ptr.019 = bind_name ptr, %ptr.var +// CHECK:STDOUT: %.loc8_11: type = splice_block %ptr.loc8_11 [template = constants.%ptr.019] { +// CHECK:STDOUT: %E.ref: type = name_ref E, imports.%import_ref.2c9 [template = constants.%C] +// CHECK:STDOUT: %ptr.loc8_11: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ptr.loc8_5: ref %ptr.019 = bind_name ptr, %ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C [from "b.carbon"] { @@ -399,8 +464,8 @@ var ptr: E* = &val; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_15.2: init %C = class_init (), file.%val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_16: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%val.var, %.loc7_16 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%val.var, %.loc7_1 // CHECK:STDOUT: %val.ref: ref %C = name_ref val, file.%val // CHECK:STDOUT: %addr: %ptr.019 = addr_of %val.ref // CHECK:STDOUT: assign file.%ptr.var, %addr @@ -441,14 +506,27 @@ var ptr: E* = &val; // CHECK:STDOUT: .b_ptr = imports.%import_ref.ff5 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .val = %val -// CHECK:STDOUT: .ptr = %ptr +// CHECK:STDOUT: .ptr = %ptr.loc8_5 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %val.patt: %C = binding_pattern val +// CHECK:STDOUT: %.loc7: %C = var_pattern %val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %val.var: ref %C = var val +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.ff6 [template = constants.%C] // CHECK:STDOUT: %val: ref %C = bind_name val, %val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %ptr.patt: %ptr.019 = binding_pattern ptr +// CHECK:STDOUT: %.loc8_1: %ptr.019 = var_pattern %ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %ptr.var: ref %ptr.019 = var ptr -// CHECK:STDOUT: %ptr: ref %ptr.019 = bind_name ptr, %ptr.var +// CHECK:STDOUT: %.loc8_11: type = splice_block %ptr.loc8_11 [template = constants.%ptr.019] { +// CHECK:STDOUT: %E.ref: type = name_ref E, imports.%import_ref.2c9 [template = constants.%C] +// CHECK:STDOUT: %ptr.loc8_11: type = ptr_type %C [template = constants.%ptr.019] +// CHECK:STDOUT: } +// CHECK:STDOUT: %ptr.loc8_5: ref %ptr.019 = bind_name ptr, %ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C [from "b.carbon"] { @@ -459,8 +537,8 @@ var ptr: E* = &val; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_15.2: init %C = class_init (), file.%val.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_16: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%val.var, %.loc7_16 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%val.var, %.loc7_1 // CHECK:STDOUT: %val.ref: ref %C = name_ref val, file.%val // CHECK:STDOUT: %addr: %ptr.019 = addr_of %val.ref // CHECK:STDOUT: assign file.%ptr.var, %addr diff --git a/toolchain/check/testdata/class/import_member_cycle.carbon b/toolchain/check/testdata/class/import_member_cycle.carbon index 798d16428142..e0d98a90134e 100644 --- a/toolchain/check/testdata/class/import_member_cycle.carbon +++ b/toolchain/check/testdata/class/import_member_cycle.carbon @@ -53,7 +53,11 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Cycle { -// CHECK:STDOUT: %.loc5: %Cycle.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc5_8: %Cycle.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %Cycle.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Cycle.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -95,7 +99,15 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %ptr = binding_pattern a +// CHECK:STDOUT: %.loc7_3: %ptr = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %ptr = var a +// CHECK:STDOUT: %.loc7_15: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, imports.%import_ref.c07 [template = constants.%Cycle] +// CHECK:STDOUT: %ptr: type = ptr_type %Cycle [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %ptr = bind_name a, %a.var // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/import_struct_cyle.carbon b/toolchain/check/testdata/class/import_struct_cyle.carbon index 97653f57686b..69f78f0e2a4c 100644 --- a/toolchain/check/testdata/class/import_struct_cyle.carbon +++ b/toolchain/check/testdata/class/import_struct_cyle.carbon @@ -57,13 +57,26 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Cycle.decl.loc4: type = class_decl @Cycle [template = constants.%Cycle] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %struct_type.b = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %struct_type.b = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %struct_type.b = var a +// CHECK:STDOUT: %.loc6_19: type = splice_block %struct_type.b [template = constants.%struct_type.b] { +// CHECK:STDOUT: %Cycle.ref: type = name_ref Cycle, %Cycle.decl.loc4 [template = constants.%Cycle] +// CHECK:STDOUT: %ptr: type = ptr_type %Cycle [template = constants.%ptr] +// CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %ptr} [template = constants.%struct_type.b] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %struct_type.b = bind_name a, %a.var // CHECK:STDOUT: %Cycle.decl.loc8: type = class_decl @Cycle [template = constants.%Cycle] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Cycle { -// CHECK:STDOUT: %.loc10: %Cycle.elem = field_decl c, element0 [template] +// CHECK:STDOUT: %.loc10_8: %Cycle.elem = field_decl c, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: %Cycle.elem = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Cycle.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.c [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/inheritance_access.carbon b/toolchain/check/testdata/class/inheritance_access.carbon index c965aed3e90d..53eee50f2a87 100644 --- a/toolchain/check/testdata/class/inheritance_access.carbon +++ b/toolchain/check/testdata/class/inheritance_access.carbon @@ -266,8 +266,16 @@ class B { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Shape { -// CHECK:STDOUT: %.loc5: %Shape.elem = field_decl x, element0 [template] -// CHECK:STDOUT: %.loc6: %Shape.elem = field_decl y, element1 [template] +// CHECK:STDOUT: %.loc5_18: %Shape.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_13: %Shape.elem = var_pattern %.loc5_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %Shape.elem = var +// CHECK:STDOUT: %.loc6_18: %Shape.elem = field_decl y, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_13: %Shape.elem = var_pattern %.loc6_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %Shape.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x.y [template = constants.%complete_type.70a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -300,12 +308,12 @@ class B { // CHECK:STDOUT: fn @GetPosition[%self.param_patt: %Circle]() -> %return.param_patt: %tuple.type.d07 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref.loc13_13: %Circle = name_ref self, %self -// CHECK:STDOUT: %x.ref: %Shape.elem = name_ref x, @Shape.%.loc5 [template = @Shape.%.loc5] +// CHECK:STDOUT: %x.ref: %Shape.elem = name_ref x, @Shape.%.loc5_18 [template = @Shape.%.loc5_18] // CHECK:STDOUT: %.loc13_17.1: ref %Shape = class_element_access %self.ref.loc13_13, element0 // CHECK:STDOUT: %.loc13_17.2: ref %Shape = converted %self.ref.loc13_13, %.loc13_17.1 // CHECK:STDOUT: %.loc13_17.3: ref %i32 = class_element_access %.loc13_17.2, element0 // CHECK:STDOUT: %self.ref.loc13_21: %Circle = name_ref self, %self -// CHECK:STDOUT: %y.ref: %Shape.elem = name_ref y, @Shape.%.loc6 [template = @Shape.%.loc6] +// CHECK:STDOUT: %y.ref: %Shape.elem = name_ref y, @Shape.%.loc6_18 [template = @Shape.%.loc6_18] // CHECK:STDOUT: %.loc13_25.1: ref %Shape = class_element_access %self.ref.loc13_21, element0 // CHECK:STDOUT: %.loc13_25.2: ref %Shape = converted %self.ref.loc13_21, %.loc13_25.1 // CHECK:STDOUT: %.loc13_25.3: ref %i32 = class_element_access %.loc13_25.2, element1 @@ -476,14 +484,21 @@ class B { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %SOME_CONSTANT.patt: %i32 = binding_pattern SOME_CONSTANT +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc5_32: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_5, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_39.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_39.2: %i32 = converted %int_5, %.loc5_39.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %SOME_CONSTANT: %i32 = bind_name SOME_CONSTANT, %.loc5_39.2 +// CHECK:STDOUT: %.loc5_38.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc5_38.2: %i32 = converted %int_5, %.loc5_38.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %SOME_CONSTANT: %i32 = bind_name SOME_CONSTANT, %.loc5_38.2 // CHECK:STDOUT: %SomeProtectedFunction.decl: %SomeProtectedFunction.type = fn_decl @SomeProtectedFunction [template = constants.%SomeProtectedFunction] { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 @@ -588,7 +603,11 @@ class B { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Shape { -// CHECK:STDOUT: %.loc5: %Shape.elem = field_decl y, element0 [template] +// CHECK:STDOUT: %.loc5_16: %Shape.elem = field_decl y, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_11: %Shape.elem = var_pattern %.loc5_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Shape.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.y [template = constants.%complete_type.0f9] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -891,41 +910,66 @@ class B { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %SOME_PROTECTED_CONSTANT.patt: %i32 = binding_pattern SOME_PROTECTED_CONSTANT +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5.loc5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc5_42: type = splice_block %i32.loc5 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc5: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc5: = bound_method %int_5.loc5, %impl.elem0.loc5 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn.loc5: = specific_function %Convert.bound.loc5, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked.loc5: init %i32 = call %Convert.specific_fn.loc5(%int_5.loc5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_49.1: %i32 = value_of_initializer %int.convert_checked.loc5 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc5_49.2: %i32 = converted %int_5.loc5, %.loc5_49.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %SOME_PROTECTED_CONSTANT: %i32 = bind_name SOME_PROTECTED_CONSTANT, %.loc5_49.2 +// CHECK:STDOUT: %.loc5_48.1: %i32 = value_of_initializer %int.convert_checked.loc5 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc5_48.2: %i32 = converted %int_5.loc5, %.loc5_48.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %SOME_PROTECTED_CONSTANT: %i32 = bind_name SOME_PROTECTED_CONSTANT, %.loc5_48.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %SOME_PRIVATE_CONSTANT.patt: %i32 = binding_pattern SOME_PRIVATE_CONSTANT +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5.loc6: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc6_38: type = splice_block %i32.loc6 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc6: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc6: = bound_method %int_5.loc6, %impl.elem0.loc6 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn.loc6: = specific_function %Convert.bound.loc6, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked.loc6: init %i32 = call %Convert.specific_fn.loc6(%int_5.loc6) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc6_45.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc6_45.2: %i32 = converted %int_5.loc6, %.loc6_45.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %SOME_PRIVATE_CONSTANT: %i32 = bind_name SOME_PRIVATE_CONSTANT, %.loc6_45.2 +// CHECK:STDOUT: %.loc6_44.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc6_44.2: %i32 = converted %int_5.loc6, %.loc6_44.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %SOME_PRIVATE_CONSTANT: %i32 = bind_name SOME_PRIVATE_CONSTANT, %.loc6_44.2 // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Internal { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %INTERNAL_CONSTANT.patt: %i32 = binding_pattern INTERNAL_CONSTANT +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] +// CHECK:STDOUT: %.loc10_36: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_5, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc10_43.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc10_43.2: %i32 = converted %int_5, %.loc10_43.1 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %INTERNAL_CONSTANT: %i32 = bind_name INTERNAL_CONSTANT, %.loc10_43.2 +// CHECK:STDOUT: %.loc10_42.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc10_42.2: %i32 = converted %int_5, %.loc10_42.1 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %INTERNAL_CONSTANT: %i32 = bind_name INTERNAL_CONSTANT, %.loc10_42.2 // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type.357] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @B { -// CHECK:STDOUT: %.loc14: %B.elem = field_decl internal, element0 [template] +// CHECK:STDOUT: %.loc14_23: %B.elem = field_decl internal, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc14_11: %B.elem = var_pattern %.loc14_23 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem = var // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 @@ -965,7 +1009,7 @@ class B { // CHECK:STDOUT: fn @SomeFunc[%self.param_patt: %B]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %B = name_ref self, %self -// CHECK:STDOUT: %internal.ref: %B.elem = name_ref internal, @B.%.loc14 [template = @B.%.loc14] +// CHECK:STDOUT: %internal.ref: %B.elem = name_ref internal, @B.%.loc14_23 [template = @B.%.loc14_23] // CHECK:STDOUT: %.loc44_16.1: ref %Internal = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc44_16.2: %Internal = bind_value %.loc44_16.1 // CHECK:STDOUT: %INTERNAL_CONSTANT.ref: = name_ref INTERNAL_CONSTANT, [template = ] @@ -1009,7 +1053,11 @@ class B { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_16: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_11: %A.elem = var_pattern %.loc5_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type.1ec] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -1074,7 +1122,11 @@ class B { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @A { -// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_18: %A.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_13: %A.elem = var_pattern %.loc5_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type.1ec] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -1098,7 +1150,7 @@ class B { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %B = name_ref self, %self // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] -// CHECK:STDOUT: %x.ref: %A.elem = name_ref x, @A.%.loc5 [template = @A.%.loc5] +// CHECK:STDOUT: %x.ref: %A.elem = name_ref x, @A.%.loc5_18 [template = @A.%.loc5_18] // CHECK:STDOUT: %.loc12_9.1: ref %A = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc12_9.2: ref %A = converted %self.ref, %.loc12_9.1 // CHECK:STDOUT: %.loc12_9.3: ref %i32 = class_element_access %.loc12_9.2, element0 diff --git a/toolchain/check/testdata/class/init.carbon b/toolchain/check/testdata/class/init.carbon index 7fb831c4d7c9..e324a2da78c3 100644 --- a/toolchain/check/testdata/class/init.carbon +++ b/toolchain/check/testdata/class/init.carbon @@ -107,8 +107,16 @@ fn MakeReorder(n: i32, next: Class*) -> Class { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem.c91 = field_decl n, element0 [template] -// CHECK:STDOUT: %.loc13: %Class.elem.0c0 = field_decl next, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem.c91 = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem.c91 = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Class.elem.c91 = var +// CHECK:STDOUT: %.loc13_11: %Class.elem.0c0 = field_decl next, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Class.elem.0c0 = var_pattern %.loc13_11 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Class.elem.0c0 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n.next [template = constants.%complete_type.78f] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/init_as.carbon b/toolchain/check/testdata/class/init_as.carbon index 48f0785fa8ca..32aa269fd9d1 100644 --- a/toolchain/check/testdata/class/init_as.carbon +++ b/toolchain/check/testdata/class/init_as.carbon @@ -73,8 +73,16 @@ fn F() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class { -// CHECK:STDOUT: %.loc12: %Class.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %Class.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Class.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Class.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Class.elem = var +// CHECK:STDOUT: %.loc13_8: %Class.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Class.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -103,7 +111,7 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc17_26.9: init %Class = class_init (%.loc17_26.5, %.loc17_26.8), %.loc17_26.3 [template = constants.%Class.val] // CHECK:STDOUT: %.loc17_26.10: ref %Class = temporary %.loc17_26.3, %.loc17_26.9 // CHECK:STDOUT: %.loc17_28: ref %Class = converted %.loc17_26.1, %.loc17_26.10 -// CHECK:STDOUT: %a.ref: %Class.elem = name_ref a, @Class.%.loc12 [template = @Class.%.loc12] +// CHECK:STDOUT: %a.ref: %Class.elem = name_ref a, @Class.%.loc12_8 [template = @Class.%.loc12_8] // CHECK:STDOUT: %.loc17_37.1: ref %i32 = class_element_access %.loc17_28, element0 // CHECK:STDOUT: %.loc17_37.2: %i32 = bind_value %.loc17_37.1 // CHECK:STDOUT: return %.loc17_37.2 diff --git a/toolchain/check/testdata/class/init_nested.carbon b/toolchain/check/testdata/class/init_nested.carbon index a3bb5dca7c60..106751b65afd 100644 --- a/toolchain/check/testdata/class/init_nested.carbon +++ b/toolchain/check/testdata/class/init_nested.carbon @@ -81,15 +81,31 @@ fn MakeOuter() -> Outer { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Inner { -// CHECK:STDOUT: %.loc12: %Inner.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %Inner.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc12_8: %Inner.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Inner.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %Inner.elem = var +// CHECK:STDOUT: %.loc13_8: %Inner.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %Inner.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %Inner.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Outer { -// CHECK:STDOUT: %.loc19: %Outer.elem = field_decl c, element0 [template] -// CHECK:STDOUT: %.loc20: %Outer.elem = field_decl d, element1 [template] +// CHECK:STDOUT: %.loc19_8: %Outer.elem = field_decl c, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc19_3: %Outer.elem = var_pattern %.loc19_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc19: ref %Outer.elem = var +// CHECK:STDOUT: %.loc20_8: %Outer.elem = field_decl d, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc20_3: %Outer.elem = var_pattern %.loc20_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc20: ref %Outer.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.c.d.dce [template = constants.%complete_type.8b6] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/local.carbon b/toolchain/check/testdata/class/local.carbon index 5e9f50371578..9a7ad50f033f 100644 --- a/toolchain/check/testdata/class/local.carbon +++ b/toolchain/check/testdata/class/local.carbon @@ -88,11 +88,15 @@ class A { // CHECK:STDOUT: %return.patt: %B = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %B = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%B [template = constants.%B] +// CHECK:STDOUT: %Self.ref.loc14: type = name_ref Self, constants.%B [template = constants.%B] // CHECK:STDOUT: %return.param: ref %B = out_param runtime_param0 // CHECK:STDOUT: %return: ref %B = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc19: %B.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc19_12: %B.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc19_7: %B.elem = var_pattern %.loc19_12 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n.033 [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -105,7 +109,7 @@ class A { // CHECK:STDOUT: %.loc22_19.1: ref %B = temporary_storage // CHECK:STDOUT: %Make.call: init %B = call %Make.ref() to %.loc22_19.1 // CHECK:STDOUT: %.loc22_19.2: ref %B = temporary %.loc22_19.1, %Make.call -// CHECK:STDOUT: %n.ref: %B.elem = name_ref n, @B.%.loc19 [template = @B.%.loc19] +// CHECK:STDOUT: %n.ref: %B.elem = name_ref n, @B.%.loc19_12 [template = @B.%.loc19_12] // CHECK:STDOUT: %.loc22_20.1: ref %i32 = class_element_access %.loc22_19.2, element0 // CHECK:STDOUT: %.loc22_20.2: %i32 = bind_value %.loc22_20.1 // CHECK:STDOUT: return %.loc22_20.2 @@ -113,7 +117,10 @@ class A { // CHECK:STDOUT: // CHECK:STDOUT: fn @Make() -> %return.param_patt: %B { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %b: ref %B = bind_name b, %return +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %B = binding_pattern b +// CHECK:STDOUT: %.loc15_18.1: %B = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc15_39.1: %struct_type.n.44a = struct_literal (%int_1) // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -124,8 +131,10 @@ class A { // CHECK:STDOUT: %.loc15_39.3: ref %i32 = class_element_access %return, element0 // CHECK:STDOUT: %.loc15_39.4: init %i32 = initialize_from %.loc15_39.2 to %.loc15_39.3 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc15_39.5: init %B = class_init (%.loc15_39.4), %return [template = constants.%B.val] -// CHECK:STDOUT: %.loc15_40: init %B = converted %.loc15_39.1, %.loc15_39.5 [template = constants.%B.val] -// CHECK:STDOUT: assign %return, %.loc15_40 +// CHECK:STDOUT: %.loc15_18.2: init %B = converted %.loc15_39.1, %.loc15_39.5 [template = constants.%B.val] +// CHECK:STDOUT: assign %return, %.loc15_18.2 +// CHECK:STDOUT: %Self.ref.loc15: type = name_ref Self, constants.%B [template = constants.%B] +// CHECK:STDOUT: %b: ref %B = bind_name b, %return // CHECK:STDOUT: return %b to %return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/method.carbon b/toolchain/check/testdata/class/method.carbon index 814a2f1ba270..800af4b54050 100644 --- a/toolchain/check/testdata/class/method.carbon +++ b/toolchain/check/testdata/class/method.carbon @@ -284,7 +284,11 @@ fn CallGOnInitializingExpr() -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: %F.ref: %F.type = name_ref F, %F.decl [template = constants.%F] // CHECK:STDOUT: %A: %F.type = bind_alias A, %F.decl [template = constants.%F] -// CHECK:STDOUT: %.loc17: %Class.elem = field_decl k, element0 [template] +// CHECK:STDOUT: %.loc17_8: %Class.elem = field_decl k, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc17_3: %Class.elem = var_pattern %.loc17_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.k.0bf [template = constants.%complete_type.954] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -292,7 +296,7 @@ fn CallGOnInitializingExpr() -> i32 { // CHECK:STDOUT: fn @F[%self.param_patt: %Class]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Class = name_ref self, %self.loc20 -// CHECK:STDOUT: %k.ref: %Class.elem = name_ref k, @Class.%.loc17 [template = @Class.%.loc17] +// CHECK:STDOUT: %k.ref: %Class.elem = name_ref k, @Class.%.loc17_8 [template = @Class.%.loc17_8] // CHECK:STDOUT: %.loc21_14.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc21_14.2: %i32 = bind_value %.loc21_14.1 // CHECK:STDOUT: return %.loc21_14.2 @@ -349,7 +353,12 @@ fn CallGOnInitializingExpr() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @CallWithAddr() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %Class = binding_pattern c +// CHECK:STDOUT: %.loc39: %Class = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %Class = var c +// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %c: ref %Class = bind_name c, %c.var // CHECK:STDOUT: %c.ref: ref %Class = name_ref c, %c // CHECK:STDOUT: %G.ref: %G.type = name_ref G, @Class.%G.decl [template = constants.%G] diff --git a/toolchain/check/testdata/class/nested.carbon b/toolchain/check/testdata/class/nested.carbon index 6043437f9feb..0afcaa7d0afb 100644 --- a/toolchain/check/testdata/class/nested.carbon +++ b/toolchain/check/testdata/class/nested.carbon @@ -94,9 +94,9 @@ fn F(a: Outer*) { // CHECK:STDOUT: %a.param_patt: %ptr.5df = value_param_pattern %a.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %a.param: %ptr.5df = value_param runtime_param0 -// CHECK:STDOUT: %.loc41: type = splice_block %ptr [template = constants.%ptr.5df] { -// CHECK:STDOUT: %Outer.ref: type = name_ref Outer, file.%Outer.decl [template = constants.%Outer] -// CHECK:STDOUT: %ptr: type = ptr_type %Outer [template = constants.%ptr.5df] +// CHECK:STDOUT: %.loc41: type = splice_block %ptr.loc41 [template = constants.%ptr.5df] { +// CHECK:STDOUT: %Outer.ref.loc41: type = name_ref Outer, file.%Outer.decl [template = constants.%Outer] +// CHECK:STDOUT: %ptr.loc41: type = ptr_type %Outer [template = constants.%ptr.5df] // CHECK:STDOUT: } // CHECK:STDOUT: %a: %ptr.5df = bind_name a, %a.param // CHECK:STDOUT: } @@ -106,17 +106,41 @@ fn F(a: Outer*) { // CHECK:STDOUT: %F.decl: %F.type.288 = fn_decl @F.1 [template = constants.%F.bd8] {} {} // CHECK:STDOUT: %Inner.decl: type = class_decl @Inner [template = constants.%Inner] {} {} // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] {} {} -// CHECK:STDOUT: %.loc36: %Outer.elem.a16 = field_decl po, element0 [template] -// CHECK:STDOUT: %.loc37: %Outer.elem.a16 = field_decl qo, element1 [template] -// CHECK:STDOUT: %.loc38: %Outer.elem.fe9 = field_decl pi, element2 [template] +// CHECK:STDOUT: %.loc36_9: %Outer.elem.a16 = field_decl po, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc36_3: %Outer.elem.a16 = var_pattern %.loc36_9 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc36: ref %Outer.elem.a16 = var +// CHECK:STDOUT: %.loc37_9: %Outer.elem.a16 = field_decl qo, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc37_3: %Outer.elem.a16 = var_pattern %.loc37_9 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc37: ref %Outer.elem.a16 = var +// CHECK:STDOUT: %.loc38_9: %Outer.elem.fe9 = field_decl pi, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc38_3: %Outer.elem.fe9 = var_pattern %.loc38_9 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc38: ref %Outer.elem.fe9 = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.po.qo.pi [template = constants.%complete_type.e99] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Inner { -// CHECK:STDOUT: %.loc19: %Inner.elem.640 = field_decl pi, element0 [template] -// CHECK:STDOUT: %.loc20: %Inner.elem.c30 = field_decl po, element1 [template] -// CHECK:STDOUT: %.loc21: %Inner.elem.640 = field_decl qi, element2 [template] +// CHECK:STDOUT: %.loc19_11: %Inner.elem.640 = field_decl pi, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc19_5: %Inner.elem.640 = var_pattern %.loc19_11 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc19: ref %Inner.elem.640 = var +// CHECK:STDOUT: %.loc20_11: %Inner.elem.c30 = field_decl po, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc20_5: %Inner.elem.c30 = var_pattern %.loc20_11 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc20: ref %Inner.elem.c30 = var +// CHECK:STDOUT: %.loc21_11: %Inner.elem.640 = field_decl qi, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc21_5: %Inner.elem.640 = var_pattern %.loc21_11 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc21: ref %Inner.elem.640 = var // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {} // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.pi.po.qi [template = constants.%complete_type.7ae] // CHECK:STDOUT: complete_type_witness = %complete_type @@ -124,84 +148,124 @@ fn F(a: Outer*) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.1() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %o.patt: %Outer = binding_pattern o +// CHECK:STDOUT: %.loc14: %Outer = var_pattern %o.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %o.var: ref %Outer = var o +// CHECK:STDOUT: %Outer.ref: type = name_ref Outer, file.%Outer.decl [template = constants.%Outer] // CHECK:STDOUT: %o: ref %Outer = bind_name o, %o.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %Inner = binding_pattern i +// CHECK:STDOUT: %.loc15: %Inner = var_pattern %i.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %i.var: ref %Inner = var i +// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner] // CHECK:STDOUT: %i: ref %Inner = bind_name i, %i.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %o.patt: %Outer = binding_pattern o +// CHECK:STDOUT: %.loc25: %Outer = var_pattern %o.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %o.var: ref %Outer = var o +// CHECK:STDOUT: %Outer.ref: type = name_ref Outer, file.%Outer.decl [template = constants.%Outer] // CHECK:STDOUT: %o: ref %Outer = bind_name o, %o.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %Inner = binding_pattern i +// CHECK:STDOUT: %.loc26: %Inner = var_pattern %i.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %i.var: ref %Inner = var i +// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner] // CHECK:STDOUT: %i: ref %Inner = bind_name i, %i.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @H() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %o.patt: %Outer = binding_pattern o +// CHECK:STDOUT: %.loc32: %Outer = var_pattern %o.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %o.var: ref %Outer = var o +// CHECK:STDOUT: %Outer.ref: type = name_ref Outer, file.%Outer.decl [template = constants.%Outer] // CHECK:STDOUT: %o: ref %Outer = bind_name o, %o.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %Inner = binding_pattern i +// CHECK:STDOUT: %.loc33: %Inner = var_pattern %i.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %i.var: ref %Inner = var i +// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner] // CHECK:STDOUT: %i: ref %Inner = bind_name i, %i.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2(%a.param_patt: %ptr.5df) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %ptr.36a = binding_pattern b +// CHECK:STDOUT: } // CHECK:STDOUT: %a.ref.loc42: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc42_26: ref %Outer = deref %a.ref.loc42 -// CHECK:STDOUT: %pi.ref.loc42: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38 [template = @Outer.%.loc38] -// CHECK:STDOUT: %.loc42_29.1: ref %ptr.36a = class_element_access %.loc42_26, element2 -// CHECK:STDOUT: %.loc42_29.2: %ptr.36a = bind_value %.loc42_29.1 -// CHECK:STDOUT: %b: %ptr.36a = bind_name b, %.loc42_29.2 +// CHECK:STDOUT: %pi.ref.loc42: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38_9 [template = @Outer.%.loc38_9] +// CHECK:STDOUT: %.loc42_29: ref %ptr.36a = class_element_access %.loc42_26, element2 +// CHECK:STDOUT: %.loc42_21: type = splice_block %ptr.loc42 [template = constants.%ptr.36a] { +// CHECK:STDOUT: %Outer.ref.loc42: type = name_ref Outer, file.%Outer.decl [template = constants.%Outer] +// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner] +// CHECK:STDOUT: %ptr.loc42: type = ptr_type %Inner [template = constants.%ptr.36a] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %ptr.36a = bind_name b, %.loc42_29 // CHECK:STDOUT: %a.ref.loc44_3: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc44_4.1: ref %Outer = deref %a.ref.loc44_3 -// CHECK:STDOUT: %po.ref.loc44: %Outer.elem.a16 = name_ref po, @Outer.%.loc36 [template = @Outer.%.loc36] +// CHECK:STDOUT: %po.ref.loc44: %Outer.elem.a16 = name_ref po, @Outer.%.loc36_9 [template = @Outer.%.loc36_9] // CHECK:STDOUT: %.loc44_4.2: ref %ptr.5df = class_element_access %.loc44_4.1, element0 // CHECK:STDOUT: %a.ref.loc44_11: %ptr.5df = name_ref a, %a // CHECK:STDOUT: assign %.loc44_4.2, %a.ref.loc44_11 // CHECK:STDOUT: %a.ref.loc45_3: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc45_4.1: ref %Outer = deref %a.ref.loc45_3 -// CHECK:STDOUT: %qo.ref: %Outer.elem.a16 = name_ref qo, @Outer.%.loc37 [template = @Outer.%.loc37] +// CHECK:STDOUT: %qo.ref: %Outer.elem.a16 = name_ref qo, @Outer.%.loc37_9 [template = @Outer.%.loc37_9] // CHECK:STDOUT: %.loc45_4.2: ref %ptr.5df = class_element_access %.loc45_4.1, element1 // CHECK:STDOUT: %a.ref.loc45_11: %ptr.5df = name_ref a, %a // CHECK:STDOUT: assign %.loc45_4.2, %a.ref.loc45_11 // CHECK:STDOUT: %a.ref.loc46_3: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc46_4.1: ref %Outer = deref %a.ref.loc46_3 -// CHECK:STDOUT: %pi.ref.loc46_4: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38 [template = @Outer.%.loc38] +// CHECK:STDOUT: %pi.ref.loc46_4: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38_9 [template = @Outer.%.loc38_9] // CHECK:STDOUT: %.loc46_4.2: ref %ptr.36a = class_element_access %.loc46_4.1, element2 // CHECK:STDOUT: %a.ref.loc46_11: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc46_12.1: ref %Outer = deref %a.ref.loc46_11 -// CHECK:STDOUT: %pi.ref.loc46_12: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38 [template = @Outer.%.loc38] +// CHECK:STDOUT: %pi.ref.loc46_12: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38_9 [template = @Outer.%.loc38_9] // CHECK:STDOUT: %.loc46_12.2: ref %ptr.36a = class_element_access %.loc46_12.1, element2 // CHECK:STDOUT: %.loc46_12.3: %ptr.36a = bind_value %.loc46_12.2 // CHECK:STDOUT: assign %.loc46_4.2, %.loc46_12.3 -// CHECK:STDOUT: %b.ref.loc47: %ptr.36a = name_ref b, %b -// CHECK:STDOUT: %.loc47_4.1: ref %Inner = deref %b.ref.loc47 -// CHECK:STDOUT: %po.ref.loc47: %Inner.elem.c30 = name_ref po, @Inner.%.loc20 [template = @Inner.%.loc20] +// CHECK:STDOUT: %b.ref.loc47: ref %ptr.36a = name_ref b, %b +// CHECK:STDOUT: %.loc47_3: %ptr.36a = bind_value %b.ref.loc47 +// CHECK:STDOUT: %.loc47_4.1: ref %Inner = deref %.loc47_3 +// CHECK:STDOUT: %po.ref.loc47: %Inner.elem.c30 = name_ref po, @Inner.%.loc20_11 [template = @Inner.%.loc20_11] // CHECK:STDOUT: %.loc47_4.2: ref %ptr.5df = class_element_access %.loc47_4.1, element1 // CHECK:STDOUT: %a.ref.loc47: %ptr.5df = name_ref a, %a // CHECK:STDOUT: assign %.loc47_4.2, %a.ref.loc47 -// CHECK:STDOUT: %b.ref.loc48: %ptr.36a = name_ref b, %b -// CHECK:STDOUT: %.loc48_4.1: ref %Inner = deref %b.ref.loc48 -// CHECK:STDOUT: %pi.ref.loc48_4: %Inner.elem.640 = name_ref pi, @Inner.%.loc19 [template = @Inner.%.loc19] +// CHECK:STDOUT: %b.ref.loc48: ref %ptr.36a = name_ref b, %b +// CHECK:STDOUT: %.loc48_3: %ptr.36a = bind_value %b.ref.loc48 +// CHECK:STDOUT: %.loc48_4.1: ref %Inner = deref %.loc48_3 +// CHECK:STDOUT: %pi.ref.loc48_4: %Inner.elem.640 = name_ref pi, @Inner.%.loc19_11 [template = @Inner.%.loc19_11] // CHECK:STDOUT: %.loc48_4.2: ref %ptr.36a = class_element_access %.loc48_4.1, element0 // CHECK:STDOUT: %a.ref.loc48: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc48_12.1: ref %Outer = deref %a.ref.loc48 -// CHECK:STDOUT: %pi.ref.loc48_12: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38 [template = @Outer.%.loc38] +// CHECK:STDOUT: %pi.ref.loc48_12: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38_9 [template = @Outer.%.loc38_9] // CHECK:STDOUT: %.loc48_12.2: ref %ptr.36a = class_element_access %.loc48_12.1, element2 // CHECK:STDOUT: %.loc48_12.3: %ptr.36a = bind_value %.loc48_12.2 // CHECK:STDOUT: assign %.loc48_4.2, %.loc48_12.3 -// CHECK:STDOUT: %b.ref.loc49: %ptr.36a = name_ref b, %b -// CHECK:STDOUT: %.loc49_4.1: ref %Inner = deref %b.ref.loc49 -// CHECK:STDOUT: %qi.ref: %Inner.elem.640 = name_ref qi, @Inner.%.loc21 [template = @Inner.%.loc21] +// CHECK:STDOUT: %b.ref.loc49: ref %ptr.36a = name_ref b, %b +// CHECK:STDOUT: %.loc49_3: %ptr.36a = bind_value %b.ref.loc49 +// CHECK:STDOUT: %.loc49_4.1: ref %Inner = deref %.loc49_3 +// CHECK:STDOUT: %qi.ref: %Inner.elem.640 = name_ref qi, @Inner.%.loc21_11 [template = @Inner.%.loc21_11] // CHECK:STDOUT: %.loc49_4.2: ref %ptr.36a = class_element_access %.loc49_4.1, element2 // CHECK:STDOUT: %a.ref.loc49: %ptr.5df = name_ref a, %a // CHECK:STDOUT: %.loc49_12.1: ref %Outer = deref %a.ref.loc49 -// CHECK:STDOUT: %pi.ref.loc49: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38 [template = @Outer.%.loc38] +// CHECK:STDOUT: %pi.ref.loc49: %Outer.elem.fe9 = name_ref pi, @Outer.%.loc38_9 [template = @Outer.%.loc38_9] // CHECK:STDOUT: %.loc49_12.2: ref %ptr.36a = class_element_access %.loc49_12.1, element2 // CHECK:STDOUT: %.loc49_12.3: %ptr.36a = bind_value %.loc49_12.2 // CHECK:STDOUT: assign %.loc49_4.2, %.loc49_12.3 diff --git a/toolchain/check/testdata/class/nested_name.carbon b/toolchain/check/testdata/class/nested_name.carbon index f61049d955f4..8f4a28bcd6c0 100644 --- a/toolchain/check/testdata/class/nested_name.carbon +++ b/toolchain/check/testdata/class/nested_name.carbon @@ -91,7 +91,11 @@ fn G(o: Outer) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Inner { -// CHECK:STDOUT: %.loc13: %Inner.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc13_10: %Inner.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_5: %Inner.elem = var_pattern %.loc13_10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Inner.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -99,7 +103,7 @@ fn G(o: Outer) { // CHECK:STDOUT: fn @F(%oi.param_patt: %Inner) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %oi.ref: %Inner = name_ref oi, %oi -// CHECK:STDOUT: %n.ref: %Inner.elem = name_ref n, @Inner.%.loc13 [template = @Inner.%.loc13] +// CHECK:STDOUT: %n.ref: %Inner.elem = name_ref n, @Inner.%.loc13_10 [template = @Inner.%.loc13_10] // CHECK:STDOUT: %.loc18_12.1: ref %i32 = class_element_access %oi.ref, element0 // CHECK:STDOUT: %.loc18_12.2: %i32 = bind_value %.loc18_12.1 // CHECK:STDOUT: return %.loc18_12.2 @@ -107,7 +111,15 @@ fn G(o: Outer) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%o.param_patt: %Outer) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %Inner = binding_pattern i +// CHECK:STDOUT: %.loc22_3: %Inner = var_pattern %i.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %i.var: ref %Inner = var i +// CHECK:STDOUT: %.loc22_11: type = splice_block %Inner.ref [template = constants.%Inner] { +// CHECK:STDOUT: %o.ref: %Outer = name_ref o, %o +// CHECK:STDOUT: %Inner.ref: type = name_ref Inner, @Outer.%Inner.decl [template = constants.%Inner] +// CHECK:STDOUT: } // CHECK:STDOUT: %i: ref %Inner = bind_name i, %i.var // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/no_prelude/export_name.carbon b/toolchain/check/testdata/class/no_prelude/export_name.carbon index 9e1bcf276de3..24bf60d024c5 100644 --- a/toolchain/check/testdata/class/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/class/no_prelude/export_name.carbon @@ -103,7 +103,12 @@ var c: C = {}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -115,8 +120,8 @@ var c: C = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_14: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_14 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/no_prelude/generic_vs_params.carbon b/toolchain/check/testdata/class/no_prelude/generic_vs_params.carbon index 24a76bfdbc86..efc04c4c8c32 100644 --- a/toolchain/check/testdata/class/no_prelude/generic_vs_params.carbon +++ b/toolchain/check/testdata/class/no_prelude/generic_vs_params.carbon @@ -79,6 +79,7 @@ fn F(T:! type) { // CHECK:STDOUT: %NotGenericButParams.val: %NotGenericButParams = struct_value () [template] // CHECK:STDOUT: %GenericAndParams.2bb: type = class_type @GenericAndParams.1, @GenericAndParams.1(%X) [template] // CHECK:STDOUT: %GenericAndParams.val.0b2: %GenericAndParams.2bb = struct_value () [template] +// CHECK:STDOUT: %C.fac: type = class_type @C, @C(%X) [template] // CHECK:STDOUT: %GenericAndParams.type.c20: type = generic_class_type @GenericAndParams.2, @C(%X) [template] // CHECK:STDOUT: %GenericAndParams.generic.a55: %GenericAndParams.type.c20 = struct_value () [template] // CHECK:STDOUT: %GenericNoParams.val: %GenericNoParams.72f = struct_value () [template] @@ -116,15 +117,60 @@ fn F(T:! type) { // CHECK:STDOUT: %T.loc8_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_9.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %NotGenericNoParams = binding_pattern a +// CHECK:STDOUT: %.loc15: %NotGenericNoParams = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %NotGenericNoParams = var a +// CHECK:STDOUT: %NotGenericNoParams.ref: type = name_ref NotGenericNoParams, %NotGenericNoParams.decl [template = constants.%NotGenericNoParams] // CHECK:STDOUT: %a: ref %NotGenericNoParams = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %NotGenericButParams = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %NotGenericButParams = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %NotGenericButParams = var b +// CHECK:STDOUT: %.loc16_28: type = splice_block %NotGenericButParams [template = constants.%NotGenericButParams] { +// CHECK:STDOUT: %NotGenericButParams.ref: %NotGenericButParams.type = name_ref NotGenericButParams, %NotGenericButParams.decl [template = constants.%NotGenericButParams.generic] +// CHECK:STDOUT: %NotGenericButParams: type = class_type @NotGenericButParams [template = constants.%NotGenericButParams] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %NotGenericButParams = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %GenericAndParams.2bb = binding_pattern c +// CHECK:STDOUT: %.loc17_1: %GenericAndParams.2bb = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %GenericAndParams.2bb = var c +// CHECK:STDOUT: %.loc17_26: type = splice_block %GenericAndParams.loc17 [template = constants.%GenericAndParams.2bb] { +// CHECK:STDOUT: %GenericAndParams.ref.loc17: %GenericAndParams.type.c8d = name_ref GenericAndParams, %GenericAndParams.decl [template = constants.%GenericAndParams.generic.1e4] +// CHECK:STDOUT: %X.ref.loc17: type = name_ref X, %X.decl [template = constants.%X] +// CHECK:STDOUT: %GenericAndParams.loc17: type = class_type @GenericAndParams.1, @GenericAndParams.1(constants.%X) [template = constants.%GenericAndParams.2bb] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %GenericAndParams.2bb = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %GenericNoParams.72f = binding_pattern d +// CHECK:STDOUT: %.loc18_1: %GenericNoParams.72f = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %GenericNoParams.72f = var d +// CHECK:STDOUT: %.loc18_12: type = splice_block %GenericNoParams.ref [template = constants.%GenericNoParams.72f] { +// CHECK:STDOUT: %C.ref.loc18: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %X.ref.loc18: type = name_ref X, %X.decl [template = constants.%X] +// CHECK:STDOUT: %C.loc18: type = class_type @C, @C(constants.%X) [template = constants.%C.fac] +// CHECK:STDOUT: %GenericNoParams.ref: type = name_ref GenericNoParams, @C.%GenericNoParams.decl [template = constants.%GenericNoParams.72f] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %GenericNoParams.72f = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %GenericAndParams.91f = binding_pattern e +// CHECK:STDOUT: %.loc19_1: %GenericAndParams.91f = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %GenericAndParams.91f = var e +// CHECK:STDOUT: %.loc19_31: type = splice_block %GenericAndParams.loc19 [template = constants.%GenericAndParams.91f] { +// CHECK:STDOUT: %C.ref.loc19: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %X.ref.loc19_10: type = name_ref X, %X.decl [template = constants.%X] +// CHECK:STDOUT: %C.loc19: type = class_type @C, @C(constants.%X) [template = constants.%C.fac] +// CHECK:STDOUT: %.loc19_12: %GenericAndParams.type.c20 = specific_constant @C.%GenericAndParams.decl, @C(constants.%X) [template = constants.%GenericAndParams.generic.a55] +// CHECK:STDOUT: %GenericAndParams.ref.loc19: %GenericAndParams.type.c20 = name_ref GenericAndParams, %.loc19_12 [template = constants.%GenericAndParams.generic.a55] +// CHECK:STDOUT: %X.ref.loc19_30: type = name_ref X, %X.decl [template = constants.%X] +// CHECK:STDOUT: %GenericAndParams.loc19: type = class_type @GenericAndParams.2, @GenericAndParams.2(constants.%X, constants.%X) [template = constants.%GenericAndParams.91f] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %GenericAndParams.91f = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -202,24 +248,24 @@ fn F(T:! type) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc15_30.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc15_30.2: init %NotGenericNoParams = class_init (), file.%a.var [template = constants.%NotGenericNoParams.val] -// CHECK:STDOUT: %.loc15_31: init %NotGenericNoParams = converted %.loc15_30.1, %.loc15_30.2 [template = constants.%NotGenericNoParams.val] -// CHECK:STDOUT: assign file.%a.var, %.loc15_31 +// CHECK:STDOUT: %.loc15_1: init %NotGenericNoParams = converted %.loc15_30.1, %.loc15_30.2 [template = constants.%NotGenericNoParams.val] +// CHECK:STDOUT: assign file.%a.var, %.loc15_1 // CHECK:STDOUT: %.loc16_33.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc16_33.2: init %NotGenericButParams = class_init (), file.%b.var [template = constants.%NotGenericButParams.val] -// CHECK:STDOUT: %.loc16_34: init %NotGenericButParams = converted %.loc16_33.1, %.loc16_33.2 [template = constants.%NotGenericButParams.val] -// CHECK:STDOUT: assign file.%b.var, %.loc16_34 +// CHECK:STDOUT: %.loc16_1: init %NotGenericButParams = converted %.loc16_33.1, %.loc16_33.2 [template = constants.%NotGenericButParams.val] +// CHECK:STDOUT: assign file.%b.var, %.loc16_1 // CHECK:STDOUT: %.loc17_31.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc17_31.2: init %GenericAndParams.2bb = class_init (), file.%c.var [template = constants.%GenericAndParams.val.0b2] -// CHECK:STDOUT: %.loc17_32: init %GenericAndParams.2bb = converted %.loc17_31.1, %.loc17_31.2 [template = constants.%GenericAndParams.val.0b2] -// CHECK:STDOUT: assign file.%c.var, %.loc17_32 +// CHECK:STDOUT: %.loc17_1: init %GenericAndParams.2bb = converted %.loc17_31.1, %.loc17_31.2 [template = constants.%GenericAndParams.val.0b2] +// CHECK:STDOUT: assign file.%c.var, %.loc17_1 // CHECK:STDOUT: %.loc18_32.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc18_32.2: init %GenericNoParams.72f = class_init (), file.%d.var [template = constants.%GenericNoParams.val] -// CHECK:STDOUT: %.loc18_33: init %GenericNoParams.72f = converted %.loc18_32.1, %.loc18_32.2 [template = constants.%GenericNoParams.val] -// CHECK:STDOUT: assign file.%d.var, %.loc18_33 +// CHECK:STDOUT: %.loc18_1: init %GenericNoParams.72f = converted %.loc18_32.1, %.loc18_32.2 [template = constants.%GenericNoParams.val] +// CHECK:STDOUT: assign file.%d.var, %.loc18_1 // CHECK:STDOUT: %.loc19_36.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc19_36.2: init %GenericAndParams.91f = class_init (), file.%e.var [template = constants.%GenericAndParams.val.99b] -// CHECK:STDOUT: %.loc19_37: init %GenericAndParams.91f = converted %.loc19_36.1, %.loc19_36.2 [template = constants.%GenericAndParams.val.99b] -// CHECK:STDOUT: assign file.%e.var, %.loc19_37 +// CHECK:STDOUT: %.loc19_1: init %GenericAndParams.91f = converted %.loc19_36.1, %.loc19_36.2 [template = constants.%GenericAndParams.val.99b] +// CHECK:STDOUT: assign file.%e.var, %.loc19_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/no_prelude/import_access.carbon b/toolchain/check/testdata/class/no_prelude/import_access.carbon index d849f47119d0..490fc6fe46d1 100644 --- a/toolchain/check/testdata/class/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/class/no_prelude/import_access.carbon @@ -213,7 +213,12 @@ private class Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %Def = binding_pattern c +// CHECK:STDOUT: %.loc4: %Def = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %Def = var c +// CHECK:STDOUT: %Def.ref: type = name_ref Def, imports.%import_ref.c21 [template = constants.%Def] // CHECK:STDOUT: %c: ref %Def = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -225,8 +230,8 @@ private class Redecl {} // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc4_15.2: init %Def = class_init (), file.%c.var [template = constants.%Def.val] -// CHECK:STDOUT: %.loc4_16: init %Def = converted %.loc4_15.1, %.loc4_15.2 [template = constants.%Def.val] -// CHECK:STDOUT: assign file.%c.var, %.loc4_16 +// CHECK:STDOUT: %.loc4_1: init %Def = converted %.loc4_15.1, %.loc4_15.2 [template = constants.%Def.val] +// CHECK:STDOUT: assign file.%c.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -241,8 +246,13 @@ private class Redecl {} // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc10: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: %Def.ref: = name_ref Def, [template = ] +// CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -270,8 +280,16 @@ private class Redecl {} // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc10: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] +// CHECK:STDOUT: %Def.ref: = name_ref Def, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -302,7 +320,12 @@ private class Redecl {} // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %ForwardWithDef = binding_pattern c +// CHECK:STDOUT: %.loc4: %ForwardWithDef = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %ForwardWithDef = var c +// CHECK:STDOUT: %ForwardWithDef.ref: type = name_ref ForwardWithDef, imports.%import_ref.142 [template = constants.%ForwardWithDef] // CHECK:STDOUT: %c: ref %ForwardWithDef = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -314,8 +337,8 @@ private class Redecl {} // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_26.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc4_26.2: init %ForwardWithDef = class_init (), file.%c.var [template = constants.%ForwardWithDef.val] -// CHECK:STDOUT: %.loc4_27: init %ForwardWithDef = converted %.loc4_26.1, %.loc4_26.2 [template = constants.%ForwardWithDef.val] -// CHECK:STDOUT: assign file.%c.var, %.loc4_27 +// CHECK:STDOUT: %.loc4_1: init %ForwardWithDef = converted %.loc4_26.1, %.loc4_26.2 [template = constants.%ForwardWithDef.val] +// CHECK:STDOUT: assign file.%c.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -330,8 +353,13 @@ private class Redecl {} // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc10: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: %ForwardWithDef.ref: = name_ref ForwardWithDef, [template = ] +// CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -359,8 +387,16 @@ private class Redecl {} // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc10: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] +// CHECK:STDOUT: %ForwardWithDef.ref: = name_ref ForwardWithDef, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c: = bind_name c, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { diff --git a/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon b/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon index a31f55311cfd..321322a9e8de 100644 --- a/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon +++ b/toolchain/check/testdata/class/no_prelude/indirect_import_member.carbon @@ -250,7 +250,15 @@ var x: () = D.C.F(); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -292,7 +300,15 @@ var x: () = D.C.F(); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -334,7 +350,15 @@ var x: () = D.C.F(); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -379,7 +403,15 @@ var x: () = D.C.F(); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -429,7 +461,15 @@ var x: () = D.C.F(); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon b/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon index c2c12a0f9b05..f36708933da5 100644 --- a/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon +++ b/toolchain/check/testdata/class/no_prelude/syntactic_merge.carbon @@ -1067,7 +1067,11 @@ fn Base.F[addr self: Base*]() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc5: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc5_8: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %Base.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Base.elem = var // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %self.patt: %ptr.11f = binding_pattern self // CHECK:STDOUT: %self.param_patt: %ptr.11f = value_param_pattern %self.patt, runtime_param0 @@ -1090,7 +1094,7 @@ fn Base.F[addr self: Base*]() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %ptr.11f = name_ref self, %self // CHECK:STDOUT: %.loc18_4: ref %Base = deref %self.ref -// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc5 [template = @Base.%.loc5] +// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc5_8 [template = @Base.%.loc5_8] // CHECK:STDOUT: %.loc18_10: ref %empty_tuple.type = class_element_access %.loc18_4, element0 // CHECK:STDOUT: %.loc18_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc18_16.2: init %empty_tuple.type = tuple_init () to %.loc18_10 [template = constants.%empty_tuple] diff --git a/toolchain/check/testdata/class/raw_self.carbon b/toolchain/check/testdata/class/raw_self.carbon index 8fcb25fbfb13..f364c1e26857 100644 --- a/toolchain/check/testdata/class/raw_self.carbon +++ b/toolchain/check/testdata/class/raw_self.carbon @@ -150,7 +150,11 @@ fn Class.G[self: Self](r#self: i32) -> (i32, i32) { // CHECK:STDOUT: %return.param.loc13: ref %tuple.type.d07 = out_param runtime_param2 // CHECK:STDOUT: %return.loc13: ref %tuple.type.d07 = return_slot %return.param.loc13 // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc14: %Class.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc14_8: %Class.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc14_3: %Class.elem = var_pattern %.loc14_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -159,7 +163,7 @@ fn Class.G[self: Self](r#self: i32) -> (i32, i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref.loc18_5: %ptr.e71 = name_ref self, %self.loc17_17 // CHECK:STDOUT: %.loc18_4: ref %Class = deref %self.ref.loc18_5 -// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc14 [template = @Class.%.loc14] +// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc14_8 [template = @Class.%.loc14_8] // CHECK:STDOUT: %.loc18_10: ref %i32 = class_element_access %.loc18_4, element0 // CHECK:STDOUT: %self.ref.loc18_15: %i32 = name_ref r#self, %self.loc17_30 // CHECK:STDOUT: assign %.loc18_10, %self.ref.loc18_15 @@ -169,7 +173,7 @@ fn Class.G[self: Self](r#self: i32) -> (i32, i32) { // CHECK:STDOUT: fn @G[%self.param_patt.loc21_16: %Class](%self.param_patt.loc21_30: %i32) -> %return.param_patt: %tuple.type.d07 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref.loc22_11: %Class = name_ref self, %self.loc21_12 -// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc14 [template = @Class.%.loc14] +// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc14_8 [template = @Class.%.loc14_8] // CHECK:STDOUT: %.loc22_15.1: ref %i32 = class_element_access %self.ref.loc22_11, element0 // CHECK:STDOUT: %.loc22_15.2: %i32 = bind_value %.loc22_15.1 // CHECK:STDOUT: %self.ref.loc22_19: %i32 = name_ref r#self, %self.loc21_24 diff --git a/toolchain/check/testdata/class/raw_self_type.carbon b/toolchain/check/testdata/class/raw_self_type.carbon index d19b41eba3e0..e08f4202aa9f 100644 --- a/toolchain/check/testdata/class/raw_self_type.carbon +++ b/toolchain/check/testdata/class/raw_self_type.carbon @@ -101,13 +101,29 @@ fn MemberNamedSelf.F(x: Self, y: r#Self) {} // CHECK:STDOUT: // CHECK:STDOUT: fn @F.1() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %Self.patt: %ptr.e71 = binding_pattern r#Self +// CHECK:STDOUT: %.loc13_5: %ptr.e71 = var_pattern %Self.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %Self.var: ref %ptr.e71 = var r#Self +// CHECK:STDOUT: %.loc13_21: type = splice_block %ptr.loc13 [template = constants.%ptr.e71] { +// CHECK:STDOUT: %Self.ref.loc13: type = name_ref Self, constants.%Class [template = constants.%Class] +// CHECK:STDOUT: %ptr.loc13: type = ptr_type %Class [template = constants.%ptr.e71] +// CHECK:STDOUT: } // CHECK:STDOUT: %Self: ref %ptr.e71 = bind_name r#Self, %Self.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr.e71 = binding_pattern p +// CHECK:STDOUT: %.loc14_5: %ptr.e71 = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr.e71 = var p +// CHECK:STDOUT: %Self.ref.loc14_20: ref %ptr.e71 = name_ref r#Self, %Self +// CHECK:STDOUT: %.loc14_20: %ptr.e71 = bind_value %Self.ref.loc14_20 +// CHECK:STDOUT: assign %p.var, %.loc14_20 +// CHECK:STDOUT: %.loc14_16: type = splice_block %ptr.loc14 [template = constants.%ptr.e71] { +// CHECK:STDOUT: %Self.ref.loc14_12: type = name_ref Self, constants.%Class [template = constants.%Class] +// CHECK:STDOUT: %ptr.loc14: type = ptr_type %Class [template = constants.%ptr.e71] +// CHECK:STDOUT: } // CHECK:STDOUT: %p: ref %ptr.e71 = bind_name p, %p.var -// CHECK:STDOUT: %Self.ref: ref %ptr.e71 = name_ref r#Self, %Self -// CHECK:STDOUT: %.loc14: %ptr.e71 = bind_value %Self.ref -// CHECK:STDOUT: assign %p.var, %.loc14 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/reorder_qualified.carbon b/toolchain/check/testdata/class/reorder_qualified.carbon index cf57c60bfc61..ecd227923398 100644 --- a/toolchain/check/testdata/class/reorder_qualified.carbon +++ b/toolchain/check/testdata/class/reorder_qualified.carbon @@ -130,7 +130,11 @@ class A { // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {} // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %AF.decl: %AF.type = fn_decl @AF [template = constants.%AF] {} {} -// CHECK:STDOUT: %.loc46: %A.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc46_8: %A.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc46_3: %A.elem = var_pattern %.loc46_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %A.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.ba9 [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -138,7 +142,11 @@ class A { // CHECK:STDOUT: class @B { // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} // CHECK:STDOUT: %BF.decl: %BF.type = fn_decl @BF [template = constants.%BF] {} {} -// CHECK:STDOUT: %.loc16: %B.elem = field_decl b, element0 [template] +// CHECK:STDOUT: %.loc16_10: %B.elem = field_decl b, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc16_5: %B.elem = var_pattern %.loc16_10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.b.0a3 [template = constants.%complete_type.ba8] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -147,7 +155,11 @@ class A { // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {} // CHECK:STDOUT: %DF.decl: %DF.type = fn_decl @DF [template = constants.%DF] {} {} // CHECK:STDOUT: %CF.decl: %CF.type = fn_decl @CF [template = constants.%CF] {} {} -// CHECK:STDOUT: %.loc42: %C.elem = field_decl c, element0 [template] +// CHECK:STDOUT: %.loc42_10: %C.elem = field_decl c, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc42_5: %C.elem = var_pattern %.loc42_10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.c.b66 [template = constants.%complete_type.836] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -155,7 +167,11 @@ class A { // CHECK:STDOUT: class @D { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {} // CHECK:STDOUT: %DF.decl: %DF.type = fn_decl @DF [template = constants.%DF] {} {} -// CHECK:STDOUT: %.loc24: %D.elem = field_decl d, element0 [template] +// CHECK:STDOUT: %.loc24_12: %D.elem = field_decl d, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc24_7: %D.elem = var_pattern %.loc24_12 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %D.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.d.b7b [template = constants.%complete_type.860] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -166,8 +182,11 @@ class A { // CHECK:STDOUT: // CHECK:STDOUT: fn @DF() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: %.loc29_7.1: %A = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %A = var a -// CHECK:STDOUT: %a: ref %A = bind_name a, %a.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc29_25.1: %struct_type.a.a6c = struct_literal (%int_1) // CHECK:STDOUT: %impl.elem0.loc29: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -178,10 +197,15 @@ class A { // CHECK:STDOUT: %.loc29_25.3: ref %i32 = class_element_access %a.var, element0 // CHECK:STDOUT: %.loc29_25.4: init %i32 = initialize_from %.loc29_25.2 to %.loc29_25.3 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc29_25.5: init %A = class_init (%.loc29_25.4), %a.var [template = constants.%A.val] -// CHECK:STDOUT: %.loc29_26: init %A = converted %.loc29_25.1, %.loc29_25.5 [template = constants.%A.val] -// CHECK:STDOUT: assign %a.var, %.loc29_26 +// CHECK:STDOUT: %.loc29_7.2: init %A = converted %.loc29_25.1, %.loc29_25.5 [template = constants.%A.val] +// CHECK:STDOUT: assign %a.var, %.loc29_7.2 +// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A] +// CHECK:STDOUT: %a: ref %A = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %B = binding_pattern b +// CHECK:STDOUT: %.loc30_7.1: %B = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %B = var b -// CHECK:STDOUT: %b: ref %B = bind_name b, %b.var // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc30_25.1: %struct_type.b.a15 = struct_literal (%int_2) // CHECK:STDOUT: %impl.elem0.loc30: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -192,10 +216,15 @@ class A { // CHECK:STDOUT: %.loc30_25.3: ref %i32 = class_element_access %b.var, element0 // CHECK:STDOUT: %.loc30_25.4: init %i32 = initialize_from %.loc30_25.2 to %.loc30_25.3 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc30_25.5: init %B = class_init (%.loc30_25.4), %b.var [template = constants.%B.val] -// CHECK:STDOUT: %.loc30_26: init %B = converted %.loc30_25.1, %.loc30_25.5 [template = constants.%B.val] -// CHECK:STDOUT: assign %b.var, %.loc30_26 +// CHECK:STDOUT: %.loc30_7.2: init %B = converted %.loc30_25.1, %.loc30_25.5 [template = constants.%B.val] +// CHECK:STDOUT: assign %b.var, %.loc30_7.2 +// CHECK:STDOUT: %B.ref: type = name_ref B, @A.%B.decl [template = constants.%B] +// CHECK:STDOUT: %b: ref %B = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc31_7.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %.loc31_25.1: %struct_type.c.5b8 = struct_literal (%int_3) // CHECK:STDOUT: %impl.elem0.loc31: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -206,10 +235,15 @@ class A { // CHECK:STDOUT: %.loc31_25.3: ref %i32 = class_element_access %c.var, element0 // CHECK:STDOUT: %.loc31_25.4: init %i32 = initialize_from %.loc31_25.2 to %.loc31_25.3 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc31_25.5: init %C = class_init (%.loc31_25.4), %c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc31_26: init %C = converted %.loc31_25.1, %.loc31_25.5 [template = constants.%C.val] -// CHECK:STDOUT: assign %c.var, %.loc31_26 +// CHECK:STDOUT: %.loc31_7.2: init %C = converted %.loc31_25.1, %.loc31_25.5 [template = constants.%C.val] +// CHECK:STDOUT: assign %c.var, %.loc31_7.2 +// CHECK:STDOUT: %C.ref: type = name_ref C, @B.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %D = binding_pattern d +// CHECK:STDOUT: %.loc32_7.1: %D = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %D = var d -// CHECK:STDOUT: %d: ref %D = bind_name d, %d.var // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1] // CHECK:STDOUT: %.loc32_25.1: %struct_type.d.3ea = struct_literal (%int_4) // CHECK:STDOUT: %impl.elem0.loc32: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -220,8 +254,10 @@ class A { // CHECK:STDOUT: %.loc32_25.3: ref %i32 = class_element_access %d.var, element0 // CHECK:STDOUT: %.loc32_25.4: init %i32 = initialize_from %.loc32_25.2 to %.loc32_25.3 [template = constants.%int_4.940] // CHECK:STDOUT: %.loc32_25.5: init %D = class_init (%.loc32_25.4), %d.var [template = constants.%D.val] -// CHECK:STDOUT: %.loc32_26: init %D = converted %.loc32_25.1, %.loc32_25.5 [template = constants.%D.val] -// CHECK:STDOUT: assign %d.var, %.loc32_26 +// CHECK:STDOUT: %.loc32_7.2: init %D = converted %.loc32_25.1, %.loc32_25.5 [template = constants.%D.val] +// CHECK:STDOUT: assign %d.var, %.loc32_7.2 +// CHECK:STDOUT: %D.ref: type = name_ref D, @C.%D.decl [template = constants.%D] +// CHECK:STDOUT: %d: ref %D = bind_name d, %d.var // CHECK:STDOUT: %AF.ref: %AF.type = name_ref AF, @A.%AF.decl [template = constants.%AF] // CHECK:STDOUT: %AF.call: init %empty_tuple.type = call %AF.ref() // CHECK:STDOUT: %BF.ref: %BF.type = name_ref BF, @B.%BF.decl [template = constants.%BF] diff --git a/toolchain/check/testdata/class/scope.carbon b/toolchain/check/testdata/class/scope.carbon index 53a7b02f3f3f..ad83ee9d2965 100644 --- a/toolchain/check/testdata/class/scope.carbon +++ b/toolchain/check/testdata/class/scope.carbon @@ -145,17 +145,33 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc26_3: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a -// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %F.ref.loc26: %F.type.b25 = name_ref F, file.%F.decl [template = constants.%F.c41] // CHECK:STDOUT: %F.call.loc26: init %i32 = call %F.ref.loc26() // CHECK:STDOUT: assign %a.var, %F.call.loc26 +// CHECK:STDOUT: %.loc26_10: type = splice_block %i32.loc26 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc26: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc27_3: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b -// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %F.ref.loc27: %F.type.f1b = name_ref F, @Class.%F.decl [template = constants.%F.1f2] // CHECK:STDOUT: %F.call.loc27: init %i32 = call %F.ref.loc27() // CHECK:STDOUT: assign %b.var, %F.call.loc27 +// CHECK:STDOUT: %.loc27_10: type = splice_block %i32.loc27 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc27: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/self.carbon b/toolchain/check/testdata/class/self.carbon index 28514f6051a0..2ae6fef6942b 100644 --- a/toolchain/check/testdata/class/self.carbon +++ b/toolchain/check/testdata/class/self.carbon @@ -140,7 +140,11 @@ class Class { // CHECK:STDOUT: %return.param.loc6: ref %i32 = out_param runtime_param1 // CHECK:STDOUT: %return.loc6: ref %i32 = return_slot %return.param.loc6 // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc8: %Class.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc8_8: %Class.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc8_3: %Class.elem = var_pattern %.loc8_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -148,7 +152,7 @@ class Class { // CHECK:STDOUT: fn @F[%self.param_patt: %Class]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Class = name_ref self, %self.loc11 -// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc8 [template = @Class.%.loc8] +// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc8_8 [template = @Class.%.loc8_8] // CHECK:STDOUT: %.loc12_14.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc12_14.2: %i32 = bind_value %.loc12_14.1 // CHECK:STDOUT: return %.loc12_14.2 @@ -158,7 +162,7 @@ class Class { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %ptr.e71 = name_ref self, %self.loc15 // CHECK:STDOUT: %.loc16_11: ref %Class = deref %self.ref -// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc8 [template = @Class.%.loc8] +// CHECK:STDOUT: %n.ref: %Class.elem = name_ref n, @Class.%.loc8_8 [template = @Class.%.loc8_8] // CHECK:STDOUT: %.loc16_17.1: ref %i32 = class_element_access %.loc16_11, element0 // CHECK:STDOUT: %.loc16_17.2: %i32 = bind_value %.loc16_17.1 // CHECK:STDOUT: return %.loc16_17.2 diff --git a/toolchain/check/testdata/class/self_conversion.carbon b/toolchain/check/testdata/class/self_conversion.carbon index 522051942758..0c6e7f422824 100644 --- a/toolchain/check/testdata/class/self_conversion.carbon +++ b/toolchain/check/testdata/class/self_conversion.carbon @@ -129,7 +129,11 @@ fn Call(p: Derived*) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc12: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: %.loc12_8: %Base.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %Base.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Base.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a [template = constants.%complete_type.fd7] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -170,7 +174,7 @@ fn Call(p: Derived*) -> i32 { // CHECK:STDOUT: fn @SelfBase[%self.param_patt: %Base]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Base = name_ref self, %self.loc22 -// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc12 [template = @Base.%.loc12] +// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc12_8 [template = @Base.%.loc12_8] // CHECK:STDOUT: %.loc23_14.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc23_14.2: %i32 = bind_value %.loc23_14.1 // CHECK:STDOUT: return %.loc23_14.2 @@ -180,7 +184,7 @@ fn Call(p: Derived*) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %ptr.11f = name_ref self, %self.loc26 // CHECK:STDOUT: %.loc27_4: ref %Base = deref %self.ref -// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc12 [template = @Base.%.loc12] +// CHECK:STDOUT: %a.ref: %Base.elem = name_ref a, @Base.%.loc12_8 [template = @Base.%.loc12_8] // CHECK:STDOUT: %.loc27_10: ref %i32 = class_element_access %.loc27_4, element0 // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] diff --git a/toolchain/check/testdata/class/self_type.carbon b/toolchain/check/testdata/class/self_type.carbon index 2b65ff5a7d73..597bc0d1b922 100644 --- a/toolchain/check/testdata/class/self_type.carbon +++ b/toolchain/check/testdata/class/self_type.carbon @@ -88,11 +88,15 @@ fn Class.F[self: Self]() -> i32 { // CHECK:STDOUT: %return.patt: %Class = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %Class = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class] +// CHECK:STDOUT: %Self.ref.loc13: type = name_ref Self, constants.%Class [template = constants.%Class] // CHECK:STDOUT: %return.param: ref %Class = out_param runtime_param0 // CHECK:STDOUT: %return: ref %Class = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc18: %Class.elem = field_decl p, element0 [template] +// CHECK:STDOUT: %.loc18_8: %Class.elem = field_decl p, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc18_3: %Class.elem = var_pattern %.loc18_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Class.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.p [template = constants.%complete_type.56d] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -100,7 +104,7 @@ fn Class.F[self: Self]() -> i32 { // CHECK:STDOUT: fn @F[%self.param_patt: %Class]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %Class = name_ref self, %self.loc21 -// CHECK:STDOUT: %p.ref: %Class.elem = name_ref p, @Class.%.loc18 [template = @Class.%.loc18] +// CHECK:STDOUT: %p.ref: %Class.elem = name_ref p, @Class.%.loc18_8 [template = @Class.%.loc18_8] // CHECK:STDOUT: %.loc22_16.1: ref %ptr.e71 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc22_16.2: %ptr.e71 = bind_value %.loc22_16.1 // CHECK:STDOUT: %.loc22_11.1: ref %Class = deref %.loc22_16.2 @@ -115,6 +119,11 @@ fn Class.F[self: Self]() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Make() -> %return.param_patt: %Class { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %Class = binding_pattern s +// CHECK:STDOUT: %.loc14: %Class = var_pattern %s.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %Self.ref.loc14: type = name_ref Self, constants.%Class [template = constants.%Class] // CHECK:STDOUT: %s: ref %Class = bind_name s, %return // CHECK:STDOUT: %s.ref.loc15_5: ref %Class = name_ref s, %s // CHECK:STDOUT: %s.ref.loc15_16: ref %Class = name_ref s, %s diff --git a/toolchain/check/testdata/class/static_method.carbon b/toolchain/check/testdata/class/static_method.carbon index ebe2177655ff..0ee2aff8bd1e 100644 --- a/toolchain/check/testdata/class/static_method.carbon +++ b/toolchain/check/testdata/class/static_method.carbon @@ -78,7 +78,12 @@ fn Run() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %Class = binding_pattern c +// CHECK:STDOUT: %.loc16: %Class = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %Class = var c +// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] // CHECK:STDOUT: %c: ref %Class = bind_name c, %c.var // CHECK:STDOUT: %c.ref: ref %Class = name_ref c, %c // CHECK:STDOUT: %F.ref: %F.type = name_ref F, @Class.%F.decl [template = constants.%F] diff --git a/toolchain/check/testdata/class/todo_access_modifiers.carbon b/toolchain/check/testdata/class/todo_access_modifiers.carbon index 9382b092079a..a08f4442c3cc 100644 --- a/toolchain/check/testdata/class/todo_access_modifiers.carbon +++ b/toolchain/check/testdata/class/todo_access_modifiers.carbon @@ -54,8 +54,16 @@ class Access { // CHECK:STDOUT: class @Access { // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {} // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {} -// CHECK:STDOUT: %.loc17: %Access.elem = field_decl k, element0 [template] -// CHECK:STDOUT: %.loc19: %Access.elem = field_decl l, element1 [template] +// CHECK:STDOUT: %.loc17_16: %Access.elem = field_decl k, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc17_11: %Access.elem = var_pattern %.loc17_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc17: ref %Access.elem = var +// CHECK:STDOUT: %.loc19_18: %Access.elem = field_decl l, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc19_13: %Access.elem = var_pattern %.loc19_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc19: ref %Access.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.k.l [template = constants.%complete_type.48a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/virtual_modifiers.carbon b/toolchain/check/testdata/class/virtual_modifiers.carbon index 6974133c91ed..78a82416f8d1 100644 --- a/toolchain/check/testdata/class/virtual_modifiers.carbon +++ b/toolchain/check/testdata/class/virtual_modifiers.carbon @@ -360,6 +360,7 @@ class Derived { // CHECK:STDOUT: .Base = %import_ref.917 // CHECK:STDOUT: import Modifiers//default // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.917: type = import_ref Modifiers//default, Base, loaded [template = constants.%Base] // CHECK:STDOUT: %import_ref.05e: = import_ref Modifiers//default, loc6_1, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -380,15 +381,23 @@ class Derived { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %Base = binding_pattern v +// CHECK:STDOUT: %.loc7_3.1: %Base = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %Base = var v -// CHECK:STDOUT: %v: ref %Base = bind_name v, %v.var // CHECK:STDOUT: %.loc7_28.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_28.2: ref %ptr.454 = class_element_access %v.var, element0 // CHECK:STDOUT: %.loc7_28.3: ref %ptr.454 = vtable_ptr // CHECK:STDOUT: %.loc7_28.4: init %ptr.454 = initialize_from %.loc7_28.3 to %.loc7_28.2 // CHECK:STDOUT: %.loc7_28.5: init %Base = class_init (%.loc7_28.4), %v.var -// CHECK:STDOUT: %.loc7_29: init %Base = converted %.loc7_28.1, %.loc7_28.5 -// CHECK:STDOUT: assign %v.var, %.loc7_29 +// CHECK:STDOUT: %.loc7_3.2: init %Base = converted %.loc7_28.1, %.loc7_28.5 +// CHECK:STDOUT: assign %v.var, %.loc7_3.2 +// CHECK:STDOUT: %.loc7_19: type = splice_block %Base.ref [template = constants.%Base] { +// CHECK:STDOUT: %Modifiers.ref: = name_ref Modifiers, imports.%Modifiers [template = imports.%Modifiers] +// CHECK:STDOUT: %Base.ref: type = name_ref Base, imports.%import_ref.917 [template = constants.%Base] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %Base = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -619,8 +628,16 @@ class Derived { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Base { -// CHECK:STDOUT: %.loc5: %Base.elem = field_decl m1, element1 [template] -// CHECK:STDOUT: %.loc6: %Base.elem = field_decl m2, element2 [template] +// CHECK:STDOUT: %.loc5_9: %Base.elem = field_decl m1, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %Base.elem = var_pattern %.loc5_9 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc5: ref %Base.elem = var +// CHECK:STDOUT: %.loc6_9: %Base.elem = field_decl m2, element2 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_3: %Base.elem = var_pattern %.loc6_9 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc6: ref %Base.elem = var // CHECK:STDOUT: %F.decl: %F.type.7c6 = fn_decl @F.1 [template = constants.%F.d17] {} {} // CHECK:STDOUT: %.loc9: = vtable (%F.decl) [template = constants.%.5ee] // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.vptr.m1.m2 [template = constants.%complete_type.cf7] @@ -631,17 +648,28 @@ class Derived { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %i32 = binding_pattern i +// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %i.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %i.var: ref %i32 = var i -// CHECK:STDOUT: %i: ref %i32 = bind_name i, %i.var // CHECK:STDOUT: %int_3.loc12: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc12: = bound_method %int_3.loc12, %impl.elem0.loc12 [template = constants.%Convert.bound.b30] // CHECK:STDOUT: %Convert.specific_fn.loc12: = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_3.loc12) [template = constants.%int_3.822] -// CHECK:STDOUT: %.loc12: init %i32 = converted %int_3.loc12, %int.convert_checked.loc12 [template = constants.%int_3.822] -// CHECK:STDOUT: assign %i.var, %.loc12 +// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_3.loc12, %int.convert_checked.loc12 [template = constants.%int_3.822] +// CHECK:STDOUT: assign %i.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %i: ref %i32 = bind_name i, %i.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b1.patt: %Base = binding_pattern b1 +// CHECK:STDOUT: %.loc14_3.1: %Base = var_pattern %b1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b1.var: ref %Base = var b1 -// CHECK:STDOUT: %b1: ref %Base = bind_name b1, %b1.var // CHECK:STDOUT: %i.ref.loc14_25: ref %i32 = name_ref i, %i // CHECK:STDOUT: %i.ref.loc14_34: ref %i32 = name_ref i, %i // CHECK:STDOUT: %.loc14_35.1: %struct_type.m2.m1.68c = struct_literal (%i.ref.loc14_25, %i.ref.loc14_34) @@ -655,10 +683,15 @@ class Derived { // CHECK:STDOUT: %.loc14_35.7: ref %i32 = class_element_access %b1.var, element1 // CHECK:STDOUT: %.loc14_35.8: init %i32 = initialize_from %.loc14_25 to %.loc14_35.7 // CHECK:STDOUT: %.loc14_35.9: init %Base = class_init (%.loc14_35.4, %.loc14_35.6, %.loc14_35.8), %b1.var -// CHECK:STDOUT: %.loc14_36: init %Base = converted %.loc14_35.1, %.loc14_35.9 -// CHECK:STDOUT: assign %b1.var, %.loc14_36 +// CHECK:STDOUT: %.loc14_3.2: init %Base = converted %.loc14_35.1, %.loc14_35.9 +// CHECK:STDOUT: assign %b1.var, %.loc14_3.2 +// CHECK:STDOUT: %Base.ref.loc14: type = name_ref Base, file.%Base.decl [template = constants.%Base] +// CHECK:STDOUT: %b1: ref %Base = bind_name b1, %b1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b2.patt: %Base = binding_pattern b2 +// CHECK:STDOUT: %.loc15_3.1: %Base = var_pattern %b2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b2.var: ref %Base = var b2 -// CHECK:STDOUT: %b2: ref %Base = bind_name b2, %b2.var // CHECK:STDOUT: %int_3.loc15: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] // CHECK:STDOUT: %.loc15_35.1: %struct_type.m2.m1.5f2 = struct_literal (%int_3.loc15, %int_5) @@ -680,10 +713,12 @@ class Derived { // CHECK:STDOUT: %.loc15_35.9: ref %i32 = class_element_access %b2.var, element1 // CHECK:STDOUT: %.loc15_35.10: init %i32 = initialize_from %.loc15_35.8 to %.loc15_35.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc15_35.11: init %Base = class_init (%.loc15_35.4, %.loc15_35.7, %.loc15_35.10), %b2.var -// CHECK:STDOUT: %.loc15_36: init %Base = converted %.loc15_35.1, %.loc15_35.11 -// CHECK:STDOUT: assign %b2.var, %.loc15_36 +// CHECK:STDOUT: %.loc15_3.2: init %Base = converted %.loc15_35.1, %.loc15_35.11 +// CHECK:STDOUT: assign %b2.var, %.loc15_3.2 +// CHECK:STDOUT: %Base.ref.loc15: type = name_ref Base, file.%Base.decl [template = constants.%Base] +// CHECK:STDOUT: %b2: ref %Base = bind_name b2, %b2.var // CHECK:STDOUT: %b1.ref: ref %Base = name_ref b1, %b1 -// CHECK:STDOUT: %m2.ref: %Base.elem = name_ref m2, @Base.%.loc6 [template = @Base.%.loc6] +// CHECK:STDOUT: %m2.ref: %Base.elem = name_ref m2, @Base.%.loc6_9 [template = @Base.%.loc6_9] // CHECK:STDOUT: %.loc18_5: ref %i32 = class_element_access %b1.ref, element2 // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1] // CHECK:STDOUT: %impl.elem0.loc18: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] diff --git a/toolchain/check/testdata/const/import.carbon b/toolchain/check/testdata/const/import.carbon index 99ba80c04afe..8efe6b858ea3 100644 --- a/toolchain/check/testdata/const/import.carbon +++ b/toolchain/check/testdata/const/import.carbon @@ -63,9 +63,28 @@ var a_ptr: const i32* = a_ptr_ref; // CHECK:STDOUT: %return.param: ref %const = out_param runtime_param0 // CHECK:STDOUT: %return: ref %const = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: %const = binding_pattern a_ref +// CHECK:STDOUT: %.loc6_1: %const = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref %const = var a_ref +// CHECK:STDOUT: %.loc6_12: type = splice_block %const.loc6 [template = constants.%const] { +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %const.loc6: type = const_type %i32 [template = constants.%const] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref: ref %const = bind_name a_ref, %a_ref.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ptr_ref.patt: %ptr = binding_pattern a_ptr_ref +// CHECK:STDOUT: %.loc7_1: %ptr = var_pattern %a_ptr_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ptr_ref.var: ref %ptr = var a_ptr_ref +// CHECK:STDOUT: %.loc7_25: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %const.loc7: type = const_type %i32 [template = constants.%const] +// CHECK:STDOUT: %ptr: type = ptr_type %const [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ptr_ref: ref %ptr = bind_name a_ptr_ref, %a_ptr_ref.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -114,9 +133,29 @@ var a_ptr: const i32* = a_ptr_ref; // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %ptr = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %ptr = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %ptr = var a +// CHECK:STDOUT: %.loc6_17: type = splice_block %ptr.loc6 [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %const.loc6: type = const_type %i32 [template = constants.%const] +// CHECK:STDOUT: %ptr.loc6: type = ptr_type %const [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %ptr = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ptr.patt: %ptr = binding_pattern a_ptr +// CHECK:STDOUT: %.loc7_1: %ptr = var_pattern %a_ptr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ptr.var: ref %ptr = var a_ptr +// CHECK:STDOUT: %.loc7_21: type = splice_block %ptr.loc7 [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %const.loc7: type = const_type %i32 [template = constants.%const] +// CHECK:STDOUT: %ptr.loc7: type = ptr_type %const [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ptr: ref %ptr = bind_name a_ptr, %a_ptr.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/deduce/array.carbon b/toolchain/check/testdata/deduce/array.carbon index d81d8a42eba3..855ed159efb1 100644 --- a/toolchain/check/testdata/deduce/array.carbon +++ b/toolchain/check/testdata/deduce/array.carbon @@ -200,7 +200,7 @@ fn G() -> i32 { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C = return_slot %return.param // CHECK:STDOUT: } @@ -241,8 +241,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return.param_patt: %C { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a +// CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () @@ -260,8 +263,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc9_31: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc9_31 +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc9_3.2 +// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] { +// CHECK:STDOUT: %C.ref.loc9: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%C) [template = constants.%F.specific_fn] @@ -418,8 +427,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a +// CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () @@ -437,8 +449,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc9_31: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc9_31 +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc9_3.2 +// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] { +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%int_3.1ba) [template = constants.%F.specific_fn] @@ -569,8 +587,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a +// CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () @@ -588,8 +609,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc9_31: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc9_31 +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc9_3.2 +// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] { +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%C, constants.%int_3) [template = constants.%F.specific_fn] @@ -697,7 +724,7 @@ fn G() -> i32 { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C = return_slot %return.param // CHECK:STDOUT: } @@ -738,8 +765,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return.param_patt: %C { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a +// CHECK:STDOUT: %.loc10_3.1: %array_type.002 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %.loc10_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc10_25.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc10_29.1: %empty_struct_type = struct_literal () @@ -757,8 +787,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc10_29.2: init %C = class_init (), %.loc10_30.6 [template = constants.%C.val] // CHECK:STDOUT: %.loc10_30.7: init %C = converted %.loc10_29.1, %.loc10_29.2 [template = constants.%C.val] // CHECK:STDOUT: %.loc10_30.8: init %array_type.002 = array_init (%.loc10_30.3, %.loc10_30.5, %.loc10_30.7) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc10_31: init %array_type.002 = converted %.loc10_30.1, %.loc10_30.8 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc10_31 +// CHECK:STDOUT: %.loc10_3.2: init %array_type.002 = converted %.loc10_30.1, %.loc10_30.8 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc10_3.2 +// CHECK:STDOUT: %.loc10_15: type = splice_block %array_type [template = constants.%array_type.002] { +// CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%C) [template = constants.%F.specific_fn] @@ -924,8 +960,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.fe4 = binding_pattern a +// CHECK:STDOUT: %.loc11_3.1: %array_type.fe4 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.fe4 = var a -// CHECK:STDOUT: %a: ref %array_type.fe4 = bind_name a, %a.var // CHECK:STDOUT: %.loc11_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc11_25.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc11_29.1: %empty_struct_type = struct_literal () @@ -943,8 +982,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc11_29.2: init %D = class_init (), %.loc11_30.6 [template = constants.%D.val] // CHECK:STDOUT: %.loc11_30.7: init %D = converted %.loc11_29.1, %.loc11_29.2 [template = constants.%D.val] // CHECK:STDOUT: %.loc11_30.8: init %array_type.fe4 = array_init (%.loc11_30.3, %.loc11_30.5, %.loc11_30.7) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_31: init %array_type.fe4 = converted %.loc11_30.1, %.loc11_30.8 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc11_31 +// CHECK:STDOUT: %.loc11_3.2: init %array_type.fe4 = converted %.loc11_30.1, %.loc11_30.8 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc11_3.2 +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type.fe4] { +// CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %D [template = constants.%array_type.fe4] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type.fe4 = bind_name a, %a.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %a.ref: ref %array_type.fe4 = name_ref a, %a // CHECK:STDOUT: %F.specific_fn: = specific_function %F.ref, @F(constants.%int_3.1ba) [template = constants.%F.specific_fn] @@ -1092,8 +1137,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a +// CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type.002 = var a -// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal () @@ -1111,8 +1159,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val] // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc9_31: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc9_31 +// CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc9_3.2 +// CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] { +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/eval/aggregate.carbon b/toolchain/check/testdata/eval/aggregate.carbon index 6b014c93c6b0..54a16590b738 100644 --- a/toolchain/check/testdata/eval/aggregate.carbon +++ b/toolchain/check/testdata/eval/aggregate.carbon @@ -80,13 +80,58 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: .struct_access = %struct_access // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %tuple_copy.patt: %tuple.type.d07 = binding_pattern tuple_copy +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %tuple_copy.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %tuple_copy.var: ref %tuple.type.d07 = var tuple_copy +// CHECK:STDOUT: %.loc11_26.1: type = splice_block %.loc11_26.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_26.2: %tuple.type.24b = tuple_literal (%i32.loc11_18, %i32.loc11_23) +// CHECK:STDOUT: %.loc11_26.3: type = converted %.loc11_26.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %tuple_copy: ref %tuple.type.d07 = bind_name tuple_copy, %tuple_copy.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %struct_copy.patt: %struct_type.a.b.c = binding_pattern struct_copy +// CHECK:STDOUT: %.loc13_1: %struct_type.a.b.c = var_pattern %struct_copy.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %struct_copy.var: ref %struct_type.a.b.c = var struct_copy +// CHECK:STDOUT: %.loc13_44: type = splice_block %struct_type.a.b.c [template = constants.%struct_type.a.b.c] { +// CHECK:STDOUT: %int_32.loc13_23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc13_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc13_41: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13_41: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.c: type = struct_type {.a: %i32, .b: %i32, .c: %i32} [template = constants.%struct_type.a.b.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %struct_copy: ref %struct_type.a.b.c = bind_name struct_copy, %struct_copy.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %tuple_index.patt: %array_type = binding_pattern tuple_index +// CHECK:STDOUT: %.loc15_1: %array_type = var_pattern %tuple_index.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %tuple_index.var: ref %array_type = var tuple_index +// CHECK:STDOUT: %.loc15_25: type = splice_block %array_type.loc15 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type.loc15: type = array_type %int_1.loc15, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %tuple_index: ref %array_type = bind_name tuple_index, %tuple_index.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %struct_access.patt: %array_type = binding_pattern struct_access +// CHECK:STDOUT: %.loc17_1: %array_type = var_pattern %struct_access.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %struct_access.var: ref %array_type = var struct_access +// CHECK:STDOUT: %.loc17_27: type = splice_block %array_type.loc17 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type.loc17: type = array_type %int_1.loc17, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %struct_access: ref %array_type = bind_name struct_access, %struct_access.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -122,8 +167,8 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %tuple.elem1.loc11_37.2: ref %i32 = tuple_access file.%tuple_copy.var, element1 // CHECK:STDOUT: %.loc11_37.3: init %i32 = initialize_from %tuple.elem1.loc11_37.1 to %tuple.elem1.loc11_37.2 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc11_37.4: init %tuple.type.d07 = tuple_init (%.loc11_37.2, %.loc11_37.3) to file.%tuple_copy.var [template = constants.%tuple.21c] -// CHECK:STDOUT: %.loc11_50: init %tuple.type.d07 = converted %.loc11_37.1, %.loc11_37.4 [template = constants.%tuple.21c] -// CHECK:STDOUT: assign file.%tuple_copy.var, %.loc11_50 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_37.1, %.loc11_37.4 [template = constants.%tuple.21c] +// CHECK:STDOUT: assign file.%tuple_copy.var, %.loc11_1 // CHECK:STDOUT: %int_3.loc13: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %int_2.loc13: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] @@ -165,8 +210,8 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %.loc13_73.9: ref %i32 = struct_access file.%struct_copy.var, element2 // CHECK:STDOUT: %.loc13_73.10: init %i32 = initialize_from %.loc13_73.8 to %.loc13_73.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc13_73.11: init %struct_type.a.b.c = struct_init (%.loc13_73.4, %.loc13_73.7, %.loc13_73.10) to file.%struct_copy.var [template = constants.%struct.cff] -// CHECK:STDOUT: %.loc13_103: init %struct_type.a.b.c = converted %.loc13_73.1, %.loc13_73.11 [template = constants.%struct.cff] -// CHECK:STDOUT: assign file.%struct_copy.var, %.loc13_103 +// CHECK:STDOUT: %.loc13_1: init %struct_type.a.b.c = converted %.loc13_73.1, %.loc13_73.11 [template = constants.%struct.cff] +// CHECK:STDOUT: assign file.%struct_copy.var, %.loc13_1 // CHECK:STDOUT: %int_0.loc15_30: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %.loc15_32.1: %tuple.type.985 = tuple_literal (%int_0.loc15_30) // CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] @@ -186,11 +231,11 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %Convert.specific_fn.loc15: = specific_function %Convert.bound.loc15, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %Convert.specific_fn.loc15(%int_0.loc15_30) [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc15_32.2: init %i32 = converted %int_0.loc15_30, %int.convert_checked.loc15 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc15_5: ref %array_type = splice_block file.%tuple_index.var {} +// CHECK:STDOUT: %.loc15_1: ref %array_type = splice_block file.%tuple_index.var {} // CHECK:STDOUT: %int_0.loc15_32: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc15_32.3: ref %i32 = array_index %.loc15_5, %int_0.loc15_32 +// CHECK:STDOUT: %.loc15_32.3: ref %i32 = array_index %.loc15_1, %int_0.loc15_32 // CHECK:STDOUT: %.loc15_32.4: init %i32 = initialize_from %.loc15_32.2 to %.loc15_32.3 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc15_32.5: init %array_type = array_init (%.loc15_32.4) to %.loc15_5 [template = constants.%array] +// CHECK:STDOUT: %.loc15_32.5: init %array_type = array_init (%.loc15_32.4) to %.loc15_1 [template = constants.%array] // CHECK:STDOUT: %.loc15_34: init %array_type = converted %.loc15_32.1, %.loc15_32.5 [template = constants.%array] // CHECK:STDOUT: assign file.%tuple_index.var, %.loc15_34 // CHECK:STDOUT: %int_0.loc17_32: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] @@ -209,11 +254,11 @@ var struct_access: [i32; 1] = (0,) as [i32; {.a = 3, .b = 1}.b]; // CHECK:STDOUT: %Convert.specific_fn.loc17: = specific_function %Convert.bound.loc17, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %Convert.specific_fn.loc17(%int_0.loc17_32) [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc17_34.2: init %i32 = converted %int_0.loc17_32, %int.convert_checked.loc17 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc17_5: ref %array_type = splice_block file.%struct_access.var {} +// CHECK:STDOUT: %.loc17_1: ref %array_type = splice_block file.%struct_access.var {} // CHECK:STDOUT: %int_0.loc17_34: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] -// CHECK:STDOUT: %.loc17_34.3: ref %i32 = array_index %.loc17_5, %int_0.loc17_34 +// CHECK:STDOUT: %.loc17_34.3: ref %i32 = array_index %.loc17_1, %int_0.loc17_34 // CHECK:STDOUT: %.loc17_34.4: init %i32 = initialize_from %.loc17_34.2 to %.loc17_34.3 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc17_34.5: init %array_type = array_init (%.loc17_34.4) to %.loc17_5 [template = constants.%array] +// CHECK:STDOUT: %.loc17_34.5: init %array_type = array_init (%.loc17_34.4) to %.loc17_1 [template = constants.%array] // CHECK:STDOUT: %.loc17_36: init %array_type = converted %.loc17_34.1, %.loc17_34.5 [template = constants.%array] // CHECK:STDOUT: assign file.%struct_access.var, %.loc17_36 // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/eval/fail_aggregate.carbon b/toolchain/check/testdata/eval/fail_aggregate.carbon index 00b0158ac442..7fcec6d4d40f 100644 --- a/toolchain/check/testdata/eval/fail_aggregate.carbon +++ b/toolchain/check/testdata/eval/fail_aggregate.carbon @@ -70,7 +70,17 @@ var array_index: [i32; 1] = (0,) as [i32; ((5, 7, 1, 9) as [i32; 4])[2]]; // CHECK:STDOUT: .array_index = %array_index // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %array_index.patt: %array_type.0cb = binding_pattern array_index +// CHECK:STDOUT: %.loc17_1: %array_type.0cb = var_pattern %array_index.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %array_index.var: ref %array_type.0cb = var array_index +// CHECK:STDOUT: %.loc17_25: type = splice_block %array_type [template = constants.%array_type.0cb] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type.0cb] +// CHECK:STDOUT: } // CHECK:STDOUT: %array_index: ref %array_type.0cb = bind_name array_index, %array_index.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/symbolic.carbon b/toolchain/check/testdata/eval/symbolic.carbon index 970fadd7f2f5..567272315c7d 100644 --- a/toolchain/check/testdata/eval/symbolic.carbon +++ b/toolchain/check/testdata/eval/symbolic.carbon @@ -28,6 +28,7 @@ fn G(N:! i32) { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %ptr.79f: type = ptr_type %T [symbolic] // CHECK:STDOUT: %const: type = const_type %T [symbolic] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.4f2: type = tuple_type (%ptr.79f, %const) [symbolic] // CHECK:STDOUT: %require_complete.155: = require_complete_type %tuple.type.4f2 [symbolic] // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %T} [symbolic] @@ -41,6 +42,8 @@ fn G(N:! i32) { // CHECK:STDOUT: %N.patt.8e2: %i32 = symbolic_binding_pattern N, 0 [symbolic] // CHECK:STDOUT: %G.type: type = fn_type @G [template] // CHECK:STDOUT: %G: %G.type = struct_value () [template] +// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template] +// CHECK:STDOUT: %impl_witness.023: = impl_witness (imports.%import_ref.85c), @impl.2(%int_32) [template] // CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.2(%int_32) [template] // CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template] // CHECK:STDOUT: %Convert.bound: = bound_method %N.51e, %Convert.960 [symbolic] @@ -78,9 +81,9 @@ fn G(N:! i32) { // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc18_6.1, runtime_param [symbolic = %N.patt.loc18_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: } { // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param -// CHECK:STDOUT: %.loc18: type = splice_block %i32 [template = constants.%i32] { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18: type = splice_block %i32.loc18 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %N.loc18_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc18_6.2 (constants.%N.51e)] // CHECK:STDOUT: } @@ -91,23 +94,52 @@ fn G(N:! i32) { // CHECK:STDOUT: %T.patt.loc12_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %ptr: type = ptr_type @F.%T.loc12_6.2 (%T) [symbolic = %ptr (constants.%ptr.79f)] -// CHECK:STDOUT: %const: type = const_type @F.%T.loc12_6.2 (%T) [symbolic = %const (constants.%const)] -// CHECK:STDOUT: %tuple.type: type = tuple_type (@F.%ptr (%ptr.79f), @F.%const (%const)) [symbolic = %tuple.type (constants.%tuple.type.4f2)] +// CHECK:STDOUT: %ptr.loc13_12.2: type = ptr_type @F.%T.loc12_6.2 (%T) [symbolic = %ptr.loc13_12.2 (constants.%ptr.79f)] +// CHECK:STDOUT: %const.loc13_15.2: type = const_type @F.%T.loc12_6.2 (%T) [symbolic = %const.loc13_15.2 (constants.%const)] +// CHECK:STDOUT: %tuple.type: type = tuple_type (@F.%ptr.loc13_12.2 (%ptr.79f), @F.%const.loc13_15.2 (%const)) [symbolic = %tuple.type (constants.%tuple.type.4f2)] // CHECK:STDOUT: %require_complete.loc13: = require_complete_type @F.%tuple.type (%tuple.type.4f2) [symbolic = %require_complete.loc13 (constants.%require_complete.155)] -// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: @F.%T.loc12_6.2 (%T)} [symbolic = %struct_type.a (constants.%struct_type.a)] -// CHECK:STDOUT: %require_complete.loc14: = require_complete_type @F.%struct_type.a (%struct_type.a) [symbolic = %require_complete.loc14 (constants.%require_complete.28a)] -// CHECK:STDOUT: %array_type: type = array_type constants.%int_5, @F.%T.loc12_6.2 (%T) [symbolic = %array_type (constants.%array_type.ec2)] -// CHECK:STDOUT: %require_complete.loc15: = require_complete_type @F.%array_type (%array_type.ec2) [symbolic = %require_complete.loc15 (constants.%require_complete.fe1)] +// CHECK:STDOUT: %struct_type.a.loc14_16.2: type = struct_type {.a: @F.%T.loc12_6.2 (%T)} [symbolic = %struct_type.a.loc14_16.2 (constants.%struct_type.a)] +// CHECK:STDOUT: %require_complete.loc14: = require_complete_type @F.%struct_type.a.loc14_16.2 (%struct_type.a) [symbolic = %require_complete.loc14 (constants.%require_complete.28a)] +// CHECK:STDOUT: %array_type.loc15_15.2: type = array_type constants.%int_5, @F.%T.loc12_6.2 (%T) [symbolic = %array_type.loc15_15.2 (constants.%array_type.ec2)] +// CHECK:STDOUT: %require_complete.loc15: = require_complete_type @F.%array_type.loc15_15.2 (%array_type.ec2) [symbolic = %require_complete.loc15 (constants.%require_complete.fe1)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %u.patt: @F.%tuple.type (%tuple.type.4f2) = binding_pattern u +// CHECK:STDOUT: %.loc13_3: @F.%tuple.type (%tuple.type.4f2) = var_pattern %u.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %u.var: ref @F.%tuple.type (%tuple.type.4f2) = var u +// CHECK:STDOUT: %.loc13_22.1: type = splice_block %.loc13_22.3 [symbolic = %tuple.type (constants.%tuple.type.4f2)] { +// CHECK:STDOUT: %T.ref.loc13_11: type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %ptr.loc13_12.1: type = ptr_type %T [symbolic = %ptr.loc13_12.2 (constants.%ptr.79f)] +// CHECK:STDOUT: %T.ref.loc13_21: type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %const.loc13_15.1: type = const_type %T [symbolic = %const.loc13_15.2 (constants.%const)] +// CHECK:STDOUT: %.loc13_22.2: %tuple.type.24b = tuple_literal (%ptr.loc13_12.1, %const.loc13_15.1) +// CHECK:STDOUT: %.loc13_22.3: type = converted %.loc13_22.2, constants.%tuple.type.4f2 [symbolic = %tuple.type (constants.%tuple.type.4f2)] +// CHECK:STDOUT: } // CHECK:STDOUT: %u: ref @F.%tuple.type (%tuple.type.4f2) = bind_name u, %u.var -// CHECK:STDOUT: %v.var: ref @F.%struct_type.a (%struct_type.a) = var v -// CHECK:STDOUT: %v: ref @F.%struct_type.a (%struct_type.a) = bind_name v, %v.var -// CHECK:STDOUT: %w.var: ref @F.%array_type (%array_type.ec2) = var w -// CHECK:STDOUT: %w: ref @F.%array_type (%array_type.ec2) = bind_name w, %w.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: @F.%struct_type.a.loc14_16.2 (%struct_type.a) = binding_pattern v +// CHECK:STDOUT: %.loc14_3: @F.%struct_type.a.loc14_16.2 (%struct_type.a) = var_pattern %v.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %v.var: ref @F.%struct_type.a.loc14_16.2 (%struct_type.a) = var v +// CHECK:STDOUT: %.loc14_16: type = splice_block %struct_type.a.loc14_16.1 [symbolic = %struct_type.a.loc14_16.2 (constants.%struct_type.a)] { +// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %struct_type.a.loc14_16.1: type = struct_type {.a: %T} [symbolic = %struct_type.a.loc14_16.2 (constants.%struct_type.a)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref @F.%struct_type.a.loc14_16.2 (%struct_type.a) = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: @F.%array_type.loc15_15.2 (%array_type.ec2) = binding_pattern w +// CHECK:STDOUT: %.loc15_3: @F.%array_type.loc15_15.2 (%array_type.ec2) = var_pattern %w.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %w.var: ref @F.%array_type.loc15_15.2 (%array_type.ec2) = var w +// CHECK:STDOUT: %.loc15_15: type = splice_block %array_type.loc15_15.1 [symbolic = %array_type.loc15_15.2 (constants.%array_type.ec2)] { +// CHECK:STDOUT: %T.ref.loc15: type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5] +// CHECK:STDOUT: %array_type.loc15_15.1: type = array_type %int_5, %T [symbolic = %array_type.loc15_15.2 (constants.%array_type.ec2)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: ref @F.%array_type.loc15_15.2 (%array_type.ec2) = bind_name w, %w.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -117,16 +149,32 @@ fn G(N:! i32) { // CHECK:STDOUT: %N.patt.loc18_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc18_6.2 (constants.%N.patt.8e2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Convert.bound: = bound_method %N.loc18_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)] -// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)] -// CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.loc18_6.2) [symbolic = %int.convert_checked (constants.%int.convert_checked)] -// CHECK:STDOUT: %array_type: type = array_type %int.convert_checked, %i32 [symbolic = %array_type (constants.%array_type.b04)] -// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type (%array_type.b04) [symbolic = %require_complete (constants.%require_complete.9dc)] +// CHECK:STDOUT: %Convert.bound.loc19_16.2: = bound_method %N.loc18_6.2, constants.%Convert.960 [symbolic = %Convert.bound.loc19_16.2 (constants.%Convert.bound)] +// CHECK:STDOUT: %Convert.specific_fn.loc19_16.2: = specific_function %Convert.bound.loc19_16.2, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc19_16.2 (constants.%Convert.specific_fn)] +// CHECK:STDOUT: %int.convert_checked.loc19_16.2: init Core.IntLiteral = call %Convert.specific_fn.loc19_16.2(%N.loc18_6.2) [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc19_17.2: type = array_type %int.convert_checked.loc19_16.2, %i32 [symbolic = %array_type.loc19_17.2 (constants.%array_type.b04)] +// CHECK:STDOUT: %require_complete: = require_complete_type @G.%array_type.loc19_17.2 (%array_type.b04) [symbolic = %require_complete (constants.%require_complete.9dc)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%N.param_patt: %i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %k.var: ref @G.%array_type (%array_type.b04) = var k -// CHECK:STDOUT: %k: ref @G.%array_type (%array_type.b04) = bind_name k, %k.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %k.patt: @G.%array_type.loc19_17.2 (%array_type.b04) = binding_pattern k +// CHECK:STDOUT: %.loc19_3: @G.%array_type.loc19_17.2 (%array_type.b04) = var_pattern %k.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %k.var: ref @G.%array_type.loc19_17.2 (%array_type.b04) = var k +// CHECK:STDOUT: %.loc19_17: type = splice_block %array_type.loc19_17.1 [symbolic = %array_type.loc19_17.2 (constants.%array_type.b04)] { +// CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc18_6.1 [symbolic = %N.loc18_6.2 (constants.%N.51e)] +// CHECK:STDOUT: %impl.elem0: %Convert.type.71e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960] +// CHECK:STDOUT: %Convert.bound.loc19_16.1: = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound.loc19_16.2 (constants.%Convert.bound)] +// CHECK:STDOUT: %Convert.specific_fn.loc19_16.1: = specific_function %Convert.bound.loc19_16.1, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn.loc19_16.2 (constants.%Convert.specific_fn)] +// CHECK:STDOUT: %int.convert_checked.loc19_16.1: init Core.IntLiteral = call %Convert.specific_fn.loc19_16.1(%N.ref) [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc19_16.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc19_16.1 [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %.loc19_16.2: Core.IntLiteral = converted %N.ref, %.loc19_16.1 [symbolic = %int.convert_checked.loc19_16.2 (constants.%int.convert_checked)] +// CHECK:STDOUT: %array_type.loc19_17.1: type = array_type %.loc19_16.2, %i32 [symbolic = %array_type.loc19_17.2 (constants.%array_type.b04)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %k: ref @G.%array_type.loc19_17.2 (%array_type.b04) = bind_name k, %k.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon b/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon index 87f994454cd1..5da411bf3f30 100644 --- a/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon +++ b/toolchain/check/testdata/expr_category/in_place_tuple_init.carbon @@ -93,12 +93,24 @@ fn H() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return.param_patt: %tuple.type.d07 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %tuple.type.d07 = binding_pattern v +// CHECK:STDOUT: %.loc14_3.1: %tuple.type.d07 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %tuple.type.d07 = var v -// CHECK:STDOUT: %v: ref %tuple.type.d07 = bind_name v, %v.var // CHECK:STDOUT: %F.ref.loc14: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %.loc14: ref %tuple.type.d07 = splice_block %v.var {} -// CHECK:STDOUT: %F.call.loc14: init %tuple.type.d07 = call %F.ref.loc14() to %.loc14 +// CHECK:STDOUT: %.loc14_3.2: ref %tuple.type.d07 = splice_block %v.var {} +// CHECK:STDOUT: %F.call.loc14: init %tuple.type.d07 = call %F.ref.loc14() to %.loc14_3.2 // CHECK:STDOUT: assign %v.var, %F.call.loc14 +// CHECK:STDOUT: %.loc14_19.1: type = splice_block %.loc14_19.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc14_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_19.2: %tuple.type.24b = tuple_literal (%i32.loc14_11, %i32.loc14_16) +// CHECK:STDOUT: %.loc14_19.3: type = converted %.loc14_19.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %tuple.type.d07 = bind_name v, %v.var // CHECK:STDOUT: %v.ref: ref %tuple.type.d07 = name_ref v, %v // CHECK:STDOUT: %F.ref.loc15: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %.loc15: ref %tuple.type.d07 = splice_block %v.ref {} diff --git a/toolchain/check/testdata/function/builtin/call.carbon b/toolchain/check/testdata/function/builtin/call.carbon index b47a826cecdd..565479ebd0ef 100644 --- a/toolchain/check/testdata/function/builtin/call.carbon +++ b/toolchain/check/testdata/function/builtin/call.carbon @@ -23,6 +23,25 @@ fn RuntimeCall(a: i32, b: i32) -> i32 { // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %Add.type.b1f: type = fn_type @Add.1 [template] // CHECK:STDOUT: %Add: %Add.type.b1f = struct_value () [template] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template] +// CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.ab5: = bound_method %int_1.5b8, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.70c: = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template] +// CHECK:STDOUT: %Convert.bound.ef9: = bound_method %int_2.ecc, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.787: = specific_function %Convert.bound.ef9, @Convert.2(%int_32) [template] +// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template] +// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template] +// CHECK:STDOUT: %impl_witness.023: = impl_witness (imports.%import_ref.85c), @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.2d6: = bound_method %int_3.822, %Convert.960 [template] +// CHECK:STDOUT: %Convert.specific_fn.377: = specific_function %Convert.bound.2d6, @Convert.3(%int_32) [template] // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [template] // CHECK:STDOUT: %RuntimeCall.type: type = fn_type @RuntimeCall [template] @@ -71,7 +90,40 @@ fn RuntimeCall(a: i32, b: i32) -> i32 { // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %arr.patt: %array_type = binding_pattern arr +// CHECK:STDOUT: %.loc13_1: %array_type = var_pattern %arr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr +// CHECK:STDOUT: %.loc13_25: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %Add.ref: %Add.type.b1f = name_ref Add, %Add.decl [template = constants.%Add] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %impl.elem0.loc13_20: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc13_20: = bound_method %int_1, %impl.elem0.loc13_20 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc13_20: = specific_function %Convert.bound.loc13_20, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc13_20: init %i32 = call %Convert.specific_fn.loc13_20(%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_20.1: %i32 = value_of_initializer %int.convert_checked.loc13_20 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc13_20.2: %i32 = converted %int_1, %.loc13_20.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc13_23: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc13_23: = bound_method %int_2, %impl.elem0.loc13_23 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc13_23: = specific_function %Convert.bound.loc13_23, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc13_23: init %i32 = call %Convert.specific_fn.loc13_23(%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_23.1: %i32 = value_of_initializer %int.convert_checked.loc13_23 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc13_23.2: %i32 = converted %int_2, %.loc13_23.1 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc13_20.2, %.loc13_23.2) [template = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc13_24: %Convert.type.71e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960] +// CHECK:STDOUT: %Convert.bound.loc13_24: = bound_method %int.sadd, %impl.elem0.loc13_24 [template = constants.%Convert.bound.2d6] +// CHECK:STDOUT: %Convert.specific_fn.loc13_24: = specific_function %Convert.bound.loc13_24, @Convert.3(constants.%int_32) [template = constants.%Convert.specific_fn.377] +// CHECK:STDOUT: %.loc13_24.1: %i32 = value_of_initializer %int.sadd [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc13_24.2: %i32 = converted %int.sadd, %.loc13_24.1 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc13_24: init Core.IntLiteral = call %Convert.specific_fn.loc13_24(%.loc13_24.2) [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc13_24.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc13_24 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc13_24.4: Core.IntLiteral = converted %int.sadd, %.loc13_24.3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc13_24.4, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [template = constants.%RuntimeCall] { // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a diff --git a/toolchain/check/testdata/function/builtin/method.carbon b/toolchain/check/testdata/function/builtin/method.carbon index dcb2597397a1..63cc79195990 100644 --- a/toolchain/check/testdata/function/builtin/method.carbon +++ b/toolchain/check/testdata/function/builtin/method.carbon @@ -34,6 +34,30 @@ var arr: [i32; (1 as i32).(I.F)(2)]; // CHECK:STDOUT: %F.type.066: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.9ec: %F.type.066 = struct_value () [template] // CHECK:STDOUT: %I.facet: %I.type = facet_value %i32, %impl_witness.da7 [template] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %Convert.type.99b: type = fn_type @Convert.1, @As(%i32) [template] +// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.2, @ImplicitAs(Core.IntLiteral) [template] +// CHECK:STDOUT: %impl_witness.882: = impl_witness (imports.%import_ref.78a), @impl.4(%int_32) [template] +// CHECK:STDOUT: %Convert.type.4fd: type = fn_type @Convert.5, @impl.4(%int_32) [template] +// CHECK:STDOUT: %Convert.197: %Convert.type.4fd = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.c1b: = bound_method %int_1.5b8, %Convert.197 [template] +// CHECK:STDOUT: %Convert.specific_fn.f9a: = specific_function %Convert.bound.c1b, @Convert.5(%int_32) [template] +// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template] +// CHECK:STDOUT: %F.bound: = bound_method %int_1.5d2, %F.9ec [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.2, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.3, @impl.2(%int_32) [template] +// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.ef9: = bound_method %int_2.ecc, %Convert.956 [template] +// CHECK:STDOUT: %Convert.specific_fn.787: = specific_function %Convert.bound.ef9, @Convert.3(%int_32) [template] +// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template] +// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template] +// CHECK:STDOUT: %impl_witness.023: = impl_witness (imports.%import_ref.85c), @impl.3(%int_32) [template] +// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.4, @impl.3(%int_32) [template] +// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.2d6: = bound_method %int_3.822, %Convert.960 [template] +// CHECK:STDOUT: %Convert.specific_fn.377: = specific_function %Convert.bound.2d6, @Convert.4(%int_32) [template] // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [template] // CHECK:STDOUT: } @@ -62,7 +86,45 @@ var arr: [i32; (1 as i32).(I.F)(2)]; // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness (@impl.1.%F.decl) [template = constants.%impl_witness.da7] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %arr.patt: %array_type = binding_pattern arr +// CHECK:STDOUT: %.loc19_1: %array_type = var_pattern %arr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr +// CHECK:STDOUT: %.loc19_35: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc19_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_32.loc19_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %impl.elem0.loc19_19: %Convert.type.99b = impl_witness_access constants.%impl_witness.882, element0 [template = constants.%Convert.197] +// CHECK:STDOUT: %Convert.bound.loc19_19: = bound_method %int_1, %impl.elem0.loc19_19 [template = constants.%Convert.bound.c1b] +// CHECK:STDOUT: %Convert.specific_fn.loc19_19: = specific_function %Convert.bound.loc19_19, @Convert.5(constants.%int_32) [template = constants.%Convert.specific_fn.f9a] +// CHECK:STDOUT: %int.convert_checked.loc19_19: init %i32 = call %Convert.specific_fn.loc19_19(%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc19_19.1: %i32 = value_of_initializer %int.convert_checked.loc19_19 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc19_19.2: %i32 = converted %int_1, %.loc19_19.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [template = constants.%I.type] +// CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, @I.%assoc0 [template = constants.%assoc0.fa7] +// CHECK:STDOUT: %impl.elem0.loc19_26: %F.type.cf0 = impl_witness_access constants.%impl_witness.da7, element0 [template = constants.%F.9ec] +// CHECK:STDOUT: %F.bound: = bound_method %.loc19_19.2, %impl.elem0.loc19_26 [template = constants.%F.bound] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %impl.elem0.loc19_33: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc19_33: = bound_method %int_2, %impl.elem0.loc19_33 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc19_33: = specific_function %Convert.bound.loc19_33, @Convert.3(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc19_33: init %i32 = call %Convert.specific_fn.loc19_33(%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc19_33.1: %i32 = value_of_initializer %int.convert_checked.loc19_33 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc19_33.2: %i32 = converted %int_2, %.loc19_33.1 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %int.sadd: init %i32 = call %F.bound(%.loc19_19.2, %.loc19_33.2) [template = constants.%int_3.822] +// CHECK:STDOUT: %impl.elem0.loc19_34: %Convert.type.71e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960] +// CHECK:STDOUT: %Convert.bound.loc19_34: = bound_method %int.sadd, %impl.elem0.loc19_34 [template = constants.%Convert.bound.2d6] +// CHECK:STDOUT: %Convert.specific_fn.loc19_34: = specific_function %Convert.bound.loc19_34, @Convert.4(constants.%int_32) [template = constants.%Convert.specific_fn.377] +// CHECK:STDOUT: %.loc19_34.1: %i32 = value_of_initializer %int.sadd [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc19_34.2: %i32 = converted %int.sadd, %.loc19_34.1 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc19_34: init Core.IntLiteral = call %Convert.specific_fn.loc19_34(%.loc19_34.2) [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc19_34.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc19_34 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc19_34.4: Core.IntLiteral = converted %int.sadd, %.loc19_34.3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc19_34.4, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/no_prelude/adapted_type.carbon b/toolchain/check/testdata/function/builtin/no_prelude/adapted_type.carbon index 0dbc955f4d2d..86ea8873b6f7 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/adapted_type.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/adapted_type.carbon @@ -131,7 +131,12 @@ fn Int(N: MyIntLiteral) -> type = "int.make_type_signed"; // CHECK:STDOUT: %return.param: ref %MyInt32 = out_param runtime_param2 // CHECK:STDOUT: %return: ref %MyInt32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %MyInt32 = binding_pattern v +// CHECK:STDOUT: %.loc22: %MyInt32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %MyInt32 = var v +// CHECK:STDOUT: %MyInt32.ref: type = name_ref MyInt32, %MyInt32.decl [template = constants.%MyInt32] // CHECK:STDOUT: %v: ref %MyInt32 = bind_name v, %v.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon index 166409ef09ca..333100932e26 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon @@ -612,7 +612,11 @@ var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: %impl_witness.d9b: = impl_witness (imports.%import_ref.73a) [template] // CHECK:STDOUT: %Convert.type.953: type = fn_type @Convert.3 [template] // CHECK:STDOUT: %Convert.5bc: %Convert.type.953 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.b34: = bound_method %int_1.5b8, %Convert.5bc [template] +// CHECK:STDOUT: %int_1.f38: %i32.builtin = int_value 1 [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %Convert.bound.324: = bound_method %int_2.ecc, %Convert.5bc [template] +// CHECK:STDOUT: %int_2.5a1: %i32.builtin = int_value 2 [template] // CHECK:STDOUT: %Op.type.545: type = fn_type @Op.1 [template] // CHECK:STDOUT: %Self.as_type.da9: type = facet_access_type %Self.a99 [symbolic] // CHECK:STDOUT: %Op.assoc_type: type = assoc_entity_type %Add.type, %Op.type.545 [template] @@ -620,9 +624,13 @@ var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: %impl_witness.bd0: = impl_witness (imports.%import_ref.db4) [template] // CHECK:STDOUT: %Op.type.240: type = fn_type @Op.2 [template] // CHECK:STDOUT: %Op.0e2: %Op.type.240 = struct_value () [template] +// CHECK:STDOUT: %Op.bound.393: = bound_method %int_1.f38, %Op.0e2 [template] // CHECK:STDOUT: %int_3.a0f: %i32.builtin = int_value 3 [template] // CHECK:STDOUT: %assoc0.5048c6.2: %Convert.assoc_type.c0e = assoc_entity element0, imports.%import_ref.207961.4 [symbolic] // CHECK:STDOUT: %impl_witness.8f3: = impl_witness (imports.%import_ref.4f9) [template] +// CHECK:STDOUT: %Convert.type.0e4: type = fn_type @Convert.4 [template] +// CHECK:STDOUT: %Convert.b32: %Convert.type.0e4 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.65a: = bound_method %int_3.a0f, %Convert.b32 [template] // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32.builtin [template] // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template] @@ -680,7 +688,48 @@ var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %arr.patt: %array_type = binding_pattern arr +// CHECK:STDOUT: %.loc4_1: %array_type = var_pattern %arr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr +// CHECK:STDOUT: %.loc4_39: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc4_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_11: init type = call constants.%Int(%int_32.loc4_11) [template = constants.%i32.builtin] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_32.loc4_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_22: init type = call constants.%Int(%int_32.loc4_22) [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_22.1: type = value_of_initializer %int.make_type_signed.loc4_22 [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_22.2: type = converted %int.make_type_signed.loc4_22, %.loc4_22.1 [template = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_19: %Convert.type.378 = impl_witness_access constants.%impl_witness.d9b, element0 [template = constants.%Convert.5bc] +// CHECK:STDOUT: %Convert.bound.loc4_19: = bound_method %int_1, %impl.elem0.loc4_19 [template = constants.%Convert.bound.b34] +// CHECK:STDOUT: %int.convert_checked.loc4_19: init %i32.builtin = call %Convert.bound.loc4_19(%int_1) [template = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_19.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_19 [template = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_19.2: %i32.builtin = converted %int_1, %.loc4_19.1 [template = constants.%int_1.f38] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %int_32.loc4_35: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed.loc4_35: init type = call constants.%Int(%int_32.loc4_35) [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_35.1: type = value_of_initializer %int.make_type_signed.loc4_35 [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_35.2: type = converted %int.make_type_signed.loc4_35, %.loc4_35.1 [template = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_32: %Convert.type.378 = impl_witness_access constants.%impl_witness.d9b, element0 [template = constants.%Convert.5bc] +// CHECK:STDOUT: %Convert.bound.loc4_32: = bound_method %int_2, %impl.elem0.loc4_32 [template = constants.%Convert.bound.324] +// CHECK:STDOUT: %int.convert_checked.loc4_32: init %i32.builtin = call %Convert.bound.loc4_32(%int_2) [template = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_32.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_32 [template = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_32.2: %i32.builtin = converted %int_2, %.loc4_32.1 [template = constants.%int_2.5a1] +// CHECK:STDOUT: %impl.elem0.loc4_27.1: %Op.type.545 = impl_witness_access constants.%impl_witness.bd0, element0 [template = constants.%Op.0e2] +// CHECK:STDOUT: %Op.bound: = bound_method %.loc4_19.2, %impl.elem0.loc4_27.1 [template = constants.%Op.bound.393] +// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %Op.bound(%.loc4_19.2, %.loc4_32.2) [template = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_signed.loc4_11 [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_signed.loc4_11, %.loc4_11.1 [template = constants.%i32.builtin] +// CHECK:STDOUT: %impl.elem0.loc4_27.2: %Convert.type.71e = impl_witness_access constants.%impl_witness.8f3, element0 [template = constants.%Convert.b32] +// CHECK:STDOUT: %Convert.bound.loc4_27: = bound_method %int.sadd, %impl.elem0.loc4_27.2 [template = constants.%Convert.bound.65a] +// CHECK:STDOUT: %.loc4_27.1: %i32.builtin = value_of_initializer %int.sadd [template = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_27.2: %i32.builtin = converted %int.sadd, %.loc4_27.1 [template = constants.%int_3.a0f] +// CHECK:STDOUT: %int.convert_checked.loc4_27: init Core.IntLiteral = call %Convert.bound.loc4_27(%.loc4_27.2) [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_27.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_27 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_27.4: Core.IntLiteral = converted %int.sadd, %.loc4_27.3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc4_27.4, %i32.builtin [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -832,8 +881,8 @@ var arr: [i32; (1 as i32) + (2 as i32)] = (3, 4, (3 as i32) + (4 as i32)); // CHECK:STDOUT: %.loc4_73.8: ref %i32.builtin = array_index file.%arr.var, %int_2 // CHECK:STDOUT: %.loc4_73.9: init %i32.builtin = initialize_from %int.sadd to %.loc4_73.8 [template = constants.%int_7] // CHECK:STDOUT: %.loc4_73.10: init %array_type = array_init (%.loc4_73.4, %.loc4_73.7, %.loc4_73.9) to file.%arr.var [template = constants.%array] -// CHECK:STDOUT: %.loc4_74: init %array_type = converted %.loc4_73.1, %.loc4_73.10 [template = constants.%array] -// CHECK:STDOUT: assign file.%arr.var, %.loc4_74 +// CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_73.1, %.loc4_73.10 [template = constants.%array] +// CHECK:STDOUT: assign file.%arr.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/builtin/no_prelude/import.carbon b/toolchain/check/testdata/function/builtin/no_prelude/import.carbon index b36b49d76e2f..d57e905fbee5 100644 --- a/toolchain/check/testdata/function/builtin/no_prelude/import.carbon +++ b/toolchain/check/testdata/function/builtin/no_prelude/import.carbon @@ -165,7 +165,13 @@ var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %Int.type: type = fn_type @Int [template] +// CHECK:STDOUT: %Int: %Int.type = struct_value () [template] // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template] +// CHECK:STDOUT: %AsIntLiteral.type: type = fn_type @AsIntLiteral [template] +// CHECK:STDOUT: %AsIntLiteral: %AsIntLiteral.type = struct_value () [template] +// CHECK:STDOUT: %TestAdd.type: type = fn_type @TestAdd [template] +// CHECK:STDOUT: %TestAdd: %TestAdd.type = struct_value () [template] // CHECK:STDOUT: %AsI32.type: type = fn_type @AsI32 [template] // CHECK:STDOUT: %AsI32: %AsI32.type = struct_value () [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] @@ -188,6 +194,8 @@ var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = // CHECK:STDOUT: .AsI32 = %import_ref.614 // CHECK:STDOUT: import Core//core // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.d91: %AsIntLiteral.type = import_ref Core//core, AsIntLiteral, loaded [template = constants.%AsIntLiteral] +// CHECK:STDOUT: %import_ref.a93: %TestAdd.type = import_ref Core//core, TestAdd, loaded [template = constants.%TestAdd] // CHECK:STDOUT: %import_ref.614: %AsI32.type = import_ref Core//core, AsI32, loaded [template = constants.%AsI32] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -197,7 +205,40 @@ var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = // CHECK:STDOUT: .arr = %arr // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %arr.patt: %array_type = binding_pattern arr +// CHECK:STDOUT: %.loc4_1: %array_type = var_pattern %arr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %arr.var: ref %array_type = var arr +// CHECK:STDOUT: %.loc4_77: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32.builtin] +// CHECK:STDOUT: %Core.ref.loc4_16: = name_ref Core, imports.%Core [template = imports.%Core] +// CHECK:STDOUT: %AsIntLiteral.ref: %AsIntLiteral.type = name_ref AsIntLiteral, imports.%import_ref.d91 [template = constants.%AsIntLiteral] +// CHECK:STDOUT: %Core.ref.loc4_34: = name_ref Core, imports.%Core [template = imports.%Core] +// CHECK:STDOUT: %TestAdd.ref: %TestAdd.type = name_ref TestAdd, imports.%import_ref.a93 [template = constants.%TestAdd] +// CHECK:STDOUT: %Core.ref.loc4_47: = name_ref Core, imports.%Core [template = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_51: %AsI32.type = name_ref AsI32, imports.%import_ref.614 [template = constants.%AsI32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int.convert_checked.loc4_59: init %i32.builtin = call %AsI32.ref.loc4_51(%int_1) [template = constants.%int_1.f38] +// CHECK:STDOUT: %Core.ref.loc4_62: = name_ref Core, imports.%Core [template = imports.%Core] +// CHECK:STDOUT: %AsI32.ref.loc4_66: %AsI32.type = name_ref AsI32, imports.%import_ref.614 [template = constants.%AsI32] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %int.convert_checked.loc4_74: init %i32.builtin = call %AsI32.ref.loc4_66(%int_2) [template = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_59.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_59 [template = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_59.2: %i32.builtin = converted %int.convert_checked.loc4_59, %.loc4_59.1 [template = constants.%int_1.f38] +// CHECK:STDOUT: %.loc4_74.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_74 [template = constants.%int_2.5a1] +// CHECK:STDOUT: %.loc4_74.2: %i32.builtin = converted %int.convert_checked.loc4_74, %.loc4_74.1 [template = constants.%int_2.5a1] +// CHECK:STDOUT: %int.sadd: init %i32.builtin = call %TestAdd.ref(%.loc4_59.2, %.loc4_74.2) [template = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_75.1: %i32.builtin = value_of_initializer %int.sadd [template = constants.%int_3.a0f] +// CHECK:STDOUT: %.loc4_75.2: %i32.builtin = converted %int.sadd, %.loc4_75.1 [template = constants.%int_3.a0f] +// CHECK:STDOUT: %int.convert_checked.loc4_76: init Core.IntLiteral = call %AsIntLiteral.ref(%.loc4_75.2) [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_signed, %.loc4_11.1 [template = constants.%i32.builtin] +// CHECK:STDOUT: %.loc4_76.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_76 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc4_76.2: Core.IntLiteral = converted %int.convert_checked.loc4_76, %.loc4_76.1 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type: type = array_type %.loc4_76.2, %i32.builtin [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -234,8 +275,8 @@ var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = // CHECK:STDOUT: %.loc4_125.6: ref %i32.builtin = array_index file.%arr.var, %int_2.loc4_125 // CHECK:STDOUT: %.loc4_125.7: init %i32.builtin = initialize_from %int.convert_checked.loc4_124 to %.loc4_125.6 [template = constants.%int_3.a0f] // CHECK:STDOUT: %.loc4_125.8: init %array_type = array_init (%.loc4_125.3, %.loc4_125.5, %.loc4_125.7) to file.%arr.var [template = constants.%array] -// CHECK:STDOUT: %.loc4_126: init %array_type = converted %.loc4_125.1, %.loc4_125.8 [template = constants.%array] -// CHECK:STDOUT: assign file.%arr.var, %.loc4_126 +// CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_125.1, %.loc4_125.8 [template = constants.%array] +// CHECK:STDOUT: assign file.%arr.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/fail_not_callable.carbon b/toolchain/check/testdata/function/call/fail_not_callable.carbon index 48cf89e29cca..4c1970207ab3 100644 --- a/toolchain/check/testdata/function/call/fail_not_callable.carbon +++ b/toolchain/check/testdata/function/call/fail_not_callable.carbon @@ -45,10 +45,18 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %i32 = var x -// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var // CHECK:STDOUT: %str: String = string_literal "hello" [template = constants.%str] // CHECK:STDOUT: assign %x.var, +// CHECK:STDOUT: %.loc16_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon index cafdeefba49d..84106fe378d0 100644 --- a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon @@ -13,10 +13,10 @@ fn Foo() -> f64 { return 1.0; } fn Run() { // CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `f64` to `i32` [ImplicitAsConversionFailure] // CHECK:STDERR: var x: i32 = Foo(); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~ // CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+4]]:3: note: type `f64` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote] // CHECK:STDERR: var x: i32 = Foo(); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~~ // CHECK:STDERR: var x: i32 = Foo(); } @@ -75,12 +75,20 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: %.loc21_3.1: %i32 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %i32 = var x -// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo] // CHECK:STDOUT: %Foo.call: init f64 = call %Foo.ref() -// CHECK:STDOUT: %.loc21: %i32 = converted %Foo.call, [template = ] +// CHECK:STDOUT: %.loc21_3.2: %i32 = converted %Foo.call, [template = ] // CHECK:STDOUT: assign %x.var, +// CHECK:STDOUT: %.loc21_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/i32.carbon b/toolchain/check/testdata/function/call/i32.carbon index defaa37ae408..3cafd03a105a 100644 --- a/toolchain/check/testdata/function/call/i32.carbon +++ b/toolchain/check/testdata/function/call/i32.carbon @@ -79,8 +79,11 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b -// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: %Echo.ref: %Echo.type = name_ref Echo, file.%Echo.decl [template = constants.%Echo] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -91,6 +94,11 @@ fn Main() { // CHECK:STDOUT: %.loc16_21.2: %i32 = converted %int_1, %.loc16_21.1 [template = constants.%int_1.5d2] // CHECK:STDOUT: %Echo.call: init %i32 = call %Echo.ref(%.loc16_21.2) // CHECK:STDOUT: assign %b.var, %Echo.call +// CHECK:STDOUT: %.loc16_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/more_param_ir.carbon b/toolchain/check/testdata/function/call/more_param_ir.carbon index 086989209f7c..ef4900561f76 100644 --- a/toolchain/check/testdata/function/call/more_param_ir.carbon +++ b/toolchain/check/testdata/function/call/more_param_ir.carbon @@ -26,6 +26,7 @@ fn Main() { // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template] // CHECK:STDOUT: %Main.type: type = fn_type @Main [template] // CHECK:STDOUT: %Main: %Main.type = struct_value () [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template] @@ -89,8 +90,11 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.a1c = binding_pattern x +// CHECK:STDOUT: %.loc14_3.1: %tuple.type.a1c = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.a1c = var x -// CHECK:STDOUT: %x: ref %tuple.type.a1c = bind_name x, %x.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc14_22.1: %tuple.type.985 = tuple_literal (%int_1) // CHECK:STDOUT: %impl.elem0.loc14: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -99,8 +103,15 @@ fn Main() { // CHECK:STDOUT: %int.convert_checked.loc14: init %i32 = call %Convert.specific_fn.loc14(%int_1) [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc14_22.2: init %i32 = converted %int_1, %int.convert_checked.loc14 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc14_22.3: init %tuple.type.a1c = tuple_init (%.loc14_22.2) to %x.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc14_23: init %tuple.type.a1c = converted %.loc14_22.1, %.loc14_22.3 [template = constants.%tuple] -// CHECK:STDOUT: assign %x.var, %.loc14_23 +// CHECK:STDOUT: %.loc14_3.2: init %tuple.type.a1c = converted %.loc14_22.1, %.loc14_22.3 [template = constants.%tuple] +// CHECK:STDOUT: assign %x.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_15.1: type = splice_block %.loc14_15.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_15.2: %tuple.type.85c = tuple_literal (%i32) +// CHECK:STDOUT: %.loc14_15.3: type = converted %.loc14_15.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %tuple.type.a1c = bind_name x, %x.var // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo] // CHECK:STDOUT: %x.ref: ref %tuple.type.a1c = name_ref x, %x // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] diff --git a/toolchain/check/testdata/function/call/no_prelude/alias.carbon b/toolchain/check/testdata/function/call/no_prelude/alias.carbon index 6e61c2bbf26c..7d5b945e178a 100644 --- a/toolchain/check/testdata/function/call/no_prelude/alias.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/alias.carbon @@ -57,11 +57,19 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc16_3: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b -// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: %B.ref: %A.type = name_ref B, file.%B [template = constants.%A] // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %B.ref() // CHECK:STDOUT: assign %b.var, %A.call +// CHECK:STDOUT: %.loc16_11.1: type = splice_block %.loc16_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc16_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_11.3: type = converted %.loc16_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon b/toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon index d101f7d91efb..cf3082f68f21 100644 --- a/toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon +++ b/toolchain/check/testdata/function/call/no_prelude/return_implicit.carbon @@ -41,11 +41,19 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc15_3: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b -// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: %MakeImplicitEmptyTuple.ref: %MakeImplicitEmptyTuple.type = name_ref MakeImplicitEmptyTuple, file.%MakeImplicitEmptyTuple.decl [template = constants.%MakeImplicitEmptyTuple] // CHECK:STDOUT: %MakeImplicitEmptyTuple.call: init %empty_tuple.type = call %MakeImplicitEmptyTuple.ref() // CHECK:STDOUT: assign %b.var, %MakeImplicitEmptyTuple.call +// CHECK:STDOUT: %.loc15_11.1: type = splice_block %.loc15_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc15_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_11.3: type = converted %.loc15_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/import.carbon b/toolchain/check/testdata/function/declaration/import.carbon index b8c2357d126a..00762ba3a5be 100644 --- a/toolchain/check/testdata/function/declaration/import.carbon +++ b/toolchain/check/testdata/function/declaration/import.carbon @@ -506,15 +506,56 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc7_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc7_8: type = splice_block %i32.loc7 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c +// CHECK:STDOUT: %.loc8_1: %struct_type.c = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var c +// CHECK:STDOUT: %.loc8_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] { +// CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc9_1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d +// CHECK:STDOUT: %.loc9_9.1: type = splice_block %.loc9_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc9_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_9.3: type = converted %.loc9_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -656,15 +697,56 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {} // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc52_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc52_9.1: type = splice_block %.loc52_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc52_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc52_9.3: type = converted %.loc52_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc53_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc53_8: type = splice_block %i32.loc53 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc53: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c +// CHECK:STDOUT: %.loc54_1: %struct_type.c = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var c +// CHECK:STDOUT: %.loc54_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] { +// CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc54: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc55_1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d +// CHECK:STDOUT: %.loc55_9.1: type = splice_block %.loc55_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc55_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc55_9.3: type = converted %.loc55_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc56_1: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc56_9.1: type = splice_block %.loc56_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc56_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc56_9.3: type = converted %.loc56_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -806,15 +888,56 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {} // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc12_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc12_9.1: type = splice_block %.loc12_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_9.3: type = converted %.loc12_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc13_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc13_8: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c +// CHECK:STDOUT: %.loc14_1: %struct_type.c = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var c +// CHECK:STDOUT: %.loc14_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] { +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc15_1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d +// CHECK:STDOUT: %.loc15_9.1: type = splice_block %.loc15_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc15_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_9.3: type = converted %.loc15_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc16_1: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc16_9.1: type = splice_block %.loc16_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc16_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_9.3: type = converted %.loc16_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -930,15 +1053,56 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc52_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc52_9.1: type = splice_block %.loc52_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc52_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc52_9.3: type = converted %.loc52_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc53_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc53_8: type = splice_block %i32.loc53 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc53: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c +// CHECK:STDOUT: %.loc54_1: %struct_type.c = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var c +// CHECK:STDOUT: %.loc54_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] { +// CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc54: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc55_1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d +// CHECK:STDOUT: %.loc55_9.1: type = splice_block %.loc55_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc55_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc55_9.3: type = converted %.loc55_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc56_1: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc56_9.1: type = splice_block %.loc56_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc56_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc56_9.3: type = converted %.loc56_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1054,15 +1218,56 @@ import library "extern_api"; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc52_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc52_9.1: type = splice_block %.loc52_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc52_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc52_9.3: type = converted %.loc52_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc53_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc53_8: type = splice_block %i32.loc53 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc53: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c +// CHECK:STDOUT: %.loc54_1: %struct_type.c = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var c +// CHECK:STDOUT: %.loc54_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] { +// CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc54: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc55_1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d +// CHECK:STDOUT: %.loc55_9.1: type = splice_block %.loc55_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc55_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc55_9.3: type = converted %.loc55_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc56_1: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc56_9.1: type = splice_block %.loc56_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc56_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc56_9.3: type = converted %.loc56_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon b/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon index a1244d9924e1..2dd8e7b5c5c5 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/export_name.carbon @@ -93,7 +93,15 @@ var f: () = F(); // CHECK:STDOUT: .f = %f // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon b/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon index f48ad0f42ae0..c614f15f43d5 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/extern.carbon @@ -115,7 +115,15 @@ extern library "basic" fn F(); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/fail_todo_no_params.carbon b/toolchain/check/testdata/function/declaration/no_prelude/fail_todo_no_params.carbon index 6ca4c928e150..d3e23fca3818 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/fail_todo_no_params.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/fail_todo_no_params.carbon @@ -103,6 +103,7 @@ fn A { // CHECK:STDOUT: constants { // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x [symbolic] +// CHECK:STDOUT: %x.patt: %empty_tuple.type = symbolic_binding_pattern x [symbolic] // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template] // CHECK:STDOUT: %A.type: type = fn_type @A [template] // CHECK:STDOUT: %A: %A.type = struct_value () [template] @@ -113,8 +114,16 @@ fn A { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x, %x.var [symbolic = constants.%x] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = symbolic_binding_pattern x [symbolic = constants.%x.patt] +// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %empty_tuple.type = var +// CHECK:STDOUT: %.loc8_10.1: type = splice_block %.loc8_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc8_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_10.3: type = converted %.loc8_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x, %.var [symbolic = constants.%x] // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -128,9 +137,9 @@ fn A { // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_15.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc8_15.2: init %empty_tuple.type = tuple_init () to file.%x.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc8_16: init %empty_tuple.type = converted %.loc8_15.1, %.loc8_15.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%x.var, %.loc8_16 +// CHECK:STDOUT: %.loc8_15.2: init %empty_tuple.type = tuple_init () to file.%.var [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc8_1: init %empty_tuple.type = converted %.loc8_15.1, %.loc8_15.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%.var, %.loc8_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon b/toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon index b9fc7667e226..d7f09a524296 100644 --- a/toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon +++ b/toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon @@ -606,7 +606,11 @@ fn F() { // CHECK:STDOUT: %x: %C1 = bind_name x, %x.param // CHECK:STDOUT: } // CHECK:STDOUT: %C2.decl: type = class_decl @C2 [template = constants.%C2] {} {} -// CHECK:STDOUT: %.loc18: %D.elem = field_decl C1, element0 [template] +// CHECK:STDOUT: %.loc18_9: %D.elem = field_decl C1, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc18_3: %D.elem = var_pattern %.loc18_9 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %D.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.C1 [template = constants.%complete_type.ec1] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -1170,7 +1174,11 @@ fn F() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @B { -// CHECK:STDOUT: %.loc9: %B.elem = field_decl v, element0 [template] +// CHECK:STDOUT: %.loc9_10: %B.elem = field_decl v, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc9_5: %B.elem = var_pattern %.loc9_10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %B.elem = var // CHECK:STDOUT: %.decl: type = class_decl @.1 [template = constants.%.96d] {} {} // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.v [template = constants.%complete_type.57e] // CHECK:STDOUT: complete_type_witness = %complete_type diff --git a/toolchain/check/testdata/function/definition/import.carbon b/toolchain/check/testdata/function/definition/import.carbon index f72ac2d4b63a..2786b458414a 100644 --- a/toolchain/check/testdata/function/definition/import.carbon +++ b/toolchain/check/testdata/function/definition/import.carbon @@ -288,11 +288,36 @@ fn D() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc7_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc7_8: type = splice_block %i32.loc7 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c +// CHECK:STDOUT: %.loc8_1: %struct_type.c = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var c +// CHECK:STDOUT: %.loc8_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] { +// CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/definition/import_access.carbon b/toolchain/check/testdata/function/definition/import_access.carbon index a05a6dc17c57..f004141963d0 100644 --- a/toolchain/check/testdata/function/definition/import_access.carbon +++ b/toolchain/check/testdata/function/definition/import_access.carbon @@ -243,7 +243,15 @@ private fn Redecl() {} // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -277,7 +285,15 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -312,7 +328,15 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -349,7 +373,15 @@ private fn Redecl() {} // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -383,7 +415,15 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -418,7 +458,15 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -455,7 +503,15 @@ private fn Redecl() {} // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: %Forward.decl: %Forward.type = fn_decl @Forward [template = constants.%Forward] {} {} // CHECK:STDOUT: } @@ -493,7 +549,15 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -528,7 +592,15 @@ private fn Redecl() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %empty_tuple.type = binding_pattern f +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %empty_tuple.type = var f +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %empty_tuple.type = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/definition/no_prelude/fail_local_decl.carbon b/toolchain/check/testdata/function/definition/no_prelude/fail_local_decl.carbon index 06b65bcc60bb..476d7a1e3aa5 100644 --- a/toolchain/check/testdata/function/definition/no_prelude/fail_local_decl.carbon +++ b/toolchain/check/testdata/function/definition/no_prelude/fail_local_decl.carbon @@ -98,9 +98,25 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %empty_struct_type = binding_pattern v +// CHECK:STDOUT: %.loc9_11: %empty_struct_type = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %empty_struct_type = var v +// CHECK:STDOUT: %.loc9_19.1: type = splice_block %.loc9_19.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc9_19.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_19.3: type = converted %.loc9_19.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %v: ref %empty_struct_type = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %empty_struct_type = binding_pattern w +// CHECK:STDOUT: %.loc14_13: %empty_struct_type = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %empty_struct_type = var w +// CHECK:STDOUT: %.loc14_21.1: type = splice_block %.loc14_21.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc14_21.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc14_21.3: type = converted %.loc14_21.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %w: ref %empty_struct_type = bind_name w, %w.var // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon index 56f2779dae8d..86b2aed2e447 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon @@ -10,9 +10,9 @@ fn F(T:! type, U:! type) { var p: T*; - // CHECK:STDERR: fail_type_param_mismatch.carbon:[[@LINE+4]]:3: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound] + // CHECK:STDERR: fail_type_param_mismatch.carbon:[[@LINE+4]]:14: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound] // CHECK:STDERR: let n: U = *p; - // CHECK:STDERR: ^~~~~~~~~~~~~~ + // CHECK:STDERR: ^~ // CHECK:STDERR: let n: U = *p; } @@ -55,18 +55,30 @@ fn F(T:! type, U:! type) { // CHECK:STDOUT: %U.patt.loc11_16.2: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc11_16.2 (constants.%U.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %ptr: type = ptr_type @F.%T.loc11_6.2 (%T) [symbolic = %ptr (constants.%ptr)] -// CHECK:STDOUT: %require_complete.loc12: = require_complete_type @F.%ptr (%ptr) [symbolic = %require_complete.loc12 (constants.%require_complete.6e5)] +// CHECK:STDOUT: %ptr.loc12_11.2: type = ptr_type @F.%T.loc11_6.2 (%T) [symbolic = %ptr.loc12_11.2 (constants.%ptr)] +// CHECK:STDOUT: %require_complete.loc12: = require_complete_type @F.%ptr.loc12_11.2 (%ptr) [symbolic = %require_complete.loc12 (constants.%require_complete.6e5)] // CHECK:STDOUT: %require_complete.loc17: = require_complete_type @F.%U.loc11_16.2 (%U) [symbolic = %require_complete.loc17 (constants.%require_complete.b54)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type, %U.param_patt: type) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %p.var: ref @F.%ptr (%ptr) = var p -// CHECK:STDOUT: %p: ref @F.%ptr (%ptr) = bind_name p, %p.var -// CHECK:STDOUT: %p.ref: ref @F.%ptr (%ptr) = name_ref p, %p -// CHECK:STDOUT: %.loc17_15: @F.%ptr (%ptr) = bind_value %p.ref -// CHECK:STDOUT: %.loc17_14: ref @F.%T.loc11_6.2 (%T) = deref %.loc17_15 -// CHECK:STDOUT: %.loc17_16: @F.%U.loc11_16.2 (%U) = converted %.loc17_14, [template = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: @F.%ptr.loc12_11.2 (%ptr) = binding_pattern p +// CHECK:STDOUT: %.loc12_3: @F.%ptr.loc12_11.2 (%ptr) = var_pattern %p.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %p.var: ref @F.%ptr.loc12_11.2 (%ptr) = var p +// CHECK:STDOUT: %.loc12_11: type = splice_block %ptr.loc12_11.1 [symbolic = %ptr.loc12_11.2 (constants.%ptr)] { +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)] +// CHECK:STDOUT: %ptr.loc12_11.1: type = ptr_type %T [symbolic = %ptr.loc12_11.2 (constants.%ptr)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: ref @F.%ptr.loc12_11.2 (%ptr) = bind_name p, %p.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: @F.%U.loc11_16.2 (%U) = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %p.ref: ref @F.%ptr.loc12_11.2 (%ptr) = name_ref p, %p +// CHECK:STDOUT: %.loc17_15: @F.%ptr.loc12_11.2 (%ptr) = bind_value %p.ref +// CHECK:STDOUT: %.loc17_14.1: ref @F.%T.loc11_6.2 (%T) = deref %.loc17_15 +// CHECK:STDOUT: %U.ref: type = name_ref U, %U.loc11_16.1 [symbolic = %U.loc11_16.2 (constants.%U)] +// CHECK:STDOUT: %.loc17_14.2: @F.%U.loc11_16.2 (%U) = converted %.loc17_14.1, [template = ] // CHECK:STDOUT: %n: @F.%U.loc11_16.2 (%U) = bind_name n, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon index 306be0806687..a775246af236 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon @@ -43,19 +43,30 @@ fn F(T:! type) { // CHECK:STDOUT: %T.patt.loc11_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %ptr: type = ptr_type @F.%T.loc11_6.2 (%T) [symbolic = %ptr (constants.%ptr)] -// CHECK:STDOUT: %require_complete.loc12: = require_complete_type @F.%ptr (%ptr) [symbolic = %require_complete.loc12 (constants.%require_complete.6e5)] +// CHECK:STDOUT: %ptr.loc12_11.2: type = ptr_type @F.%T.loc11_6.2 (%T) [symbolic = %ptr.loc12_11.2 (constants.%ptr)] +// CHECK:STDOUT: %require_complete.loc12: = require_complete_type @F.%ptr.loc12_11.2 (%ptr) [symbolic = %require_complete.loc12 (constants.%require_complete.6e5)] // CHECK:STDOUT: %require_complete.loc13: = require_complete_type @F.%T.loc11_6.2 (%T) [symbolic = %require_complete.loc13 (constants.%require_complete.4ae)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %p.var: ref @F.%ptr (%ptr) = var p -// CHECK:STDOUT: %p: ref @F.%ptr (%ptr) = bind_name p, %p.var -// CHECK:STDOUT: %p.ref: ref @F.%ptr (%ptr) = name_ref p, %p -// CHECK:STDOUT: %.loc13_15: @F.%ptr (%ptr) = bind_value %p.ref -// CHECK:STDOUT: %.loc13_14.1: ref @F.%T.loc11_6.2 (%T) = deref %.loc13_15 -// CHECK:STDOUT: %.loc13_14.2: @F.%T.loc11_6.2 (%T) = bind_value %.loc13_14.1 -// CHECK:STDOUT: %n: @F.%T.loc11_6.2 (%T) = bind_name n, %.loc13_14.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: @F.%ptr.loc12_11.2 (%ptr) = binding_pattern p +// CHECK:STDOUT: %.loc12_3: @F.%ptr.loc12_11.2 (%ptr) = var_pattern %p.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %p.var: ref @F.%ptr.loc12_11.2 (%ptr) = var p +// CHECK:STDOUT: %.loc12_11: type = splice_block %ptr.loc12_11.1 [symbolic = %ptr.loc12_11.2 (constants.%ptr)] { +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)] +// CHECK:STDOUT: %ptr.loc12_11.1: type = ptr_type %T [symbolic = %ptr.loc12_11.2 (constants.%ptr)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: ref @F.%ptr.loc12_11.2 (%ptr) = bind_name p, %p.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: @F.%T.loc11_6.2 (%T) = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %p.ref: ref @F.%ptr.loc12_11.2 (%ptr) = name_ref p, %p +// CHECK:STDOUT: %.loc13_15: @F.%ptr.loc12_11.2 (%ptr) = bind_value %p.ref +// CHECK:STDOUT: %.loc13_14: ref @F.%T.loc11_6.2 (%T) = deref %.loc13_15 +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)] +// CHECK:STDOUT: %n: ref @F.%T.loc11_6.2 (%T) = bind_name n, %.loc13_14 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon index 2d71c084fe0f..a394b16543da 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon @@ -55,7 +55,11 @@ fn F(T:! type, n: T) -> T { // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type, %n.param_patt: @F.%T.loc11_6.2 (%T)) -> @F.%T.loc11_6.2 (%T) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %m.patt: @F.%T.loc11_6.2 (%T) = binding_pattern m +// CHECK:STDOUT: } // CHECK:STDOUT: %n.ref: @F.%T.loc11_6.2 (%T) = name_ref n, %n +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)] // CHECK:STDOUT: %m: @F.%T.loc11_6.2 (%T) = bind_name m, %n.ref // CHECK:STDOUT: %m.ref: @F.%T.loc11_6.2 (%T) = name_ref m, %m // CHECK:STDOUT: return %m.ref diff --git a/toolchain/check/testdata/function/generic/resolve_used.carbon b/toolchain/check/testdata/function/generic/resolve_used.carbon index bb0073289895..282be33a1c34 100644 --- a/toolchain/check/testdata/function/generic/resolve_used.carbon +++ b/toolchain/check/testdata/function/generic/resolve_used.carbon @@ -44,6 +44,8 @@ fn CallNegative() { // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic] // CHECK:STDOUT: %ErrorIfNIsZero.type: type = fn_type @ErrorIfNIsZero [template] // CHECK:STDOUT: %ErrorIfNIsZero: %ErrorIfNIsZero.type = struct_value () [template] +// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [template] +// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [template] // CHECK:STDOUT: %Int: type = class_type @Int, @Int(%N) [symbolic] // CHECK:STDOUT: %require_complete.b4f: = require_complete_type %Int [symbolic] // CHECK:STDOUT: %CallNegative.type: type = fn_type @CallNegative [template] @@ -62,6 +64,7 @@ fn CallNegative() { // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.72f: %IntLiteral.type = import_ref Core//prelude/types/int_literal, IntLiteral, loaded [template = constants.%IntLiteral] +// CHECK:STDOUT: %import_ref.485: %Int.type = import_ref Core//prelude/types/int, Int, loaded [template = constants.%Int.generic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -77,7 +80,7 @@ fn CallNegative() { // CHECK:STDOUT: } { // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param // CHECK:STDOUT: %.loc4_39.1: type = splice_block %.loc4_39.3 [template = Core.IntLiteral] { -// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [template = imports.%Core] +// CHECK:STDOUT: %Core.ref.loc4: = name_ref Core, imports.%Core [template = imports.%Core] // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%import_ref.72f [template = constants.%IntLiteral] // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral] // CHECK:STDOUT: %.loc4_39.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral] @@ -93,13 +96,23 @@ fn CallNegative() { // CHECK:STDOUT: %N.patt.loc4_19.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc4_19.2 (constants.%N.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Int: type = class_type @Int, @Int(%N.loc4_19.2) [symbolic = %Int (constants.%Int)] -// CHECK:STDOUT: %require_complete: = require_complete_type @ErrorIfNIsZero.%Int (%Int) [symbolic = %require_complete (constants.%require_complete.b4f)] +// CHECK:STDOUT: %Int.loc15_20.2: type = class_type @Int, @Int(%N.loc4_19.2) [symbolic = %Int.loc15_20.2 (constants.%Int)] +// CHECK:STDOUT: %require_complete: = require_complete_type @ErrorIfNIsZero.%Int.loc15_20.2 (%Int) [symbolic = %require_complete (constants.%require_complete.b4f)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%N.param_patt: Core.IntLiteral) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %v.var: ref @ErrorIfNIsZero.%Int (%Int) = var v -// CHECK:STDOUT: %v: ref @ErrorIfNIsZero.%Int (%Int) = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: @ErrorIfNIsZero.%Int.loc15_20.2 (%Int) = binding_pattern v +// CHECK:STDOUT: %.loc15_3: @ErrorIfNIsZero.%Int.loc15_20.2 (%Int) = var_pattern %v.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %v.var: ref @ErrorIfNIsZero.%Int.loc15_20.2 (%Int) = var v +// CHECK:STDOUT: %.loc15_20: type = splice_block %Int.loc15_20.1 [symbolic = %Int.loc15_20.2 (constants.%Int)] { +// CHECK:STDOUT: %Core.ref.loc15: = name_ref Core, imports.%Core [template = imports.%Core] +// CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, imports.%import_ref.485 [template = constants.%Int.generic] +// CHECK:STDOUT: %N.ref: Core.IntLiteral = name_ref N, %N.loc4_19.1 [symbolic = %N.loc4_19.2 (constants.%N)] +// CHECK:STDOUT: %Int.loc15_20.1: type = class_type @Int, @Int(constants.%N) [symbolic = %Int.loc15_20.2 (constants.%Int)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref @ErrorIfNIsZero.%Int.loc15_20.2 (%Int) = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -123,7 +136,7 @@ fn CallNegative() { // CHECK:STDOUT: %N.patt.loc4_19.2 => constants.%int_0 // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Int => constants.%i0 +// CHECK:STDOUT: %Int.loc15_20.2 => constants.%i0 // CHECK:STDOUT: %require_complete => constants.%complete_type.d94 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/return_slot.carbon b/toolchain/check/testdata/function/generic/return_slot.carbon index 80fc8ac8bd6a..cda144380bda 100644 --- a/toolchain/check/testdata/function/generic/return_slot.carbon +++ b/toolchain/check/testdata/function/generic/return_slot.carbon @@ -111,7 +111,11 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc15: %C.elem = field_decl arr, element0 [template] +// CHECK:STDOUT: %.loc15_18: %C.elem = field_decl arr, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc15_11: %C.elem = var_pattern %.loc15_18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.arr.5f2 [template = constants.%complete_type.22a] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -139,19 +143,30 @@ fn G() { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc18_3: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a -// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %Wrap.ref.loc18: %Wrap.type = name_ref Wrap, file.%Wrap.decl [template = constants.%Wrap.generic] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %Wrap.loc18: type = class_type @Wrap, @Wrap(constants.%i32) [template = constants.%Wrap.f84] -// CHECK:STDOUT: %.loc18: %Make.type.572 = specific_constant @Wrap.%Make.decl, @Wrap(constants.%i32) [template = constants.%Make.2c5] -// CHECK:STDOUT: %Make.ref.loc18: %Make.type.572 = name_ref Make, %.loc18 [template = constants.%Make.2c5] +// CHECK:STDOUT: %.loc18_25: %Make.type.572 = specific_constant @Wrap.%Make.decl, @Wrap(constants.%i32) [template = constants.%Make.2c5] +// CHECK:STDOUT: %Make.ref.loc18: %Make.type.572 = name_ref Make, %.loc18_25 [template = constants.%Make.2c5] // CHECK:STDOUT: %Make.specific_fn.loc18: = specific_function %Make.ref.loc18, @Make(constants.%i32) [template = constants.%Make.specific_fn.f29] // CHECK:STDOUT: %Make.call.loc18: init %i32 = call %Make.specific_fn.loc18() // CHECK:STDOUT: assign %a.var, %Make.call.loc18 +// CHECK:STDOUT: %.loc18_10: type = splice_block %i32.loc18_10 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc18_10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc19_3: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b -// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: %Wrap.ref.loc19: %Wrap.type = name_ref Wrap, file.%Wrap.decl [template = constants.%Wrap.generic] // CHECK:STDOUT: %.loc19_21: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc19_22: type = converted %.loc19_21, constants.%empty_tuple.type [template = constants.%empty_tuple.type] @@ -161,17 +176,27 @@ fn G() { // CHECK:STDOUT: %Make.specific_fn.loc19: = specific_function %Make.ref.loc19, @Make(constants.%empty_tuple.type) [template = constants.%Make.specific_fn.e43] // CHECK:STDOUT: %Make.call.loc19: init %empty_tuple.type = call %Make.specific_fn.loc19() // CHECK:STDOUT: assign %b.var, %Make.call.loc19 +// CHECK:STDOUT: %.loc19_11.1: type = splice_block %.loc19_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc19_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_11.3: type = converted %.loc19_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc20_3.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %Wrap.ref.loc20: %Wrap.type = name_ref Wrap, file.%Wrap.decl [template = constants.%Wrap.generic] -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc20_19: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %Wrap.loc20: type = class_type @Wrap, @Wrap(constants.%C) [template = constants.%Wrap.2eb] // CHECK:STDOUT: %.loc20_21: %Make.type.708 = specific_constant @Wrap.%Make.decl, @Wrap(constants.%C) [template = constants.%Make.e4b] // CHECK:STDOUT: %Make.ref.loc20: %Make.type.708 = name_ref Make, %.loc20_21 [template = constants.%Make.e4b] // CHECK:STDOUT: %Make.specific_fn.loc20: = specific_function %Make.ref.loc20, @Make(constants.%C) [template = constants.%Make.specific_fn.834] -// CHECK:STDOUT: %.loc20_7: ref %C = splice_block %c.var {} -// CHECK:STDOUT: %Make.call.loc20: init %C = call %Make.specific_fn.loc20() to %.loc20_7 +// CHECK:STDOUT: %.loc20_3.2: ref %C = splice_block %c.var {} +// CHECK:STDOUT: %Make.call.loc20: init %C = call %Make.specific_fn.loc20() to %.loc20_3.2 // CHECK:STDOUT: assign %c.var, %Make.call.loc20 +// CHECK:STDOUT: %C.ref.loc20_10: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/generic/complete_type.carbon b/toolchain/check/testdata/generic/complete_type.carbon index cfa5444ad084..d91098db33d1 100644 --- a/toolchain/check/testdata/generic/complete_type.carbon +++ b/toolchain/check/testdata/generic/complete_type.carbon @@ -154,7 +154,11 @@ fn G() { F(B); } // CHECK:STDOUT: %complete_type.loc14_1.2: = complete_type_witness @A.%struct_type.v (%struct_type.v.ff1) [symbolic = %complete_type.loc14_1.2 (constants.%complete_type.460)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc13: @A.%A.elem (%A.elem.1ce) = field_decl v, element0 [template] +// CHECK:STDOUT: %.loc13_8: @A.%A.elem (%A.elem.1ce) = field_decl v, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: @A.%A.elem (%A.elem.1ce) = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @A.%A.elem (%A.elem.1ce) = var // CHECK:STDOUT: %complete_type.loc14_1.1: = complete_type_witness %struct_type.v.ff1 [symbolic = %complete_type.loc14_1.2 (constants.%complete_type.460)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc14_1.1 // CHECK:STDOUT: } @@ -242,7 +246,12 @@ fn G() { F(B); } // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: @F.%T.loc6_6.2 (%T) = binding_pattern v +// CHECK:STDOUT: %.loc7: @F.%T.loc6_6.2 (%T) = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref @F.%T.loc6_6.2 (%T) = var v +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %v: ref @F.%T.loc6_6.2 (%T) = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -322,7 +331,12 @@ fn G() { F(B); } // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: @F.%T.loc6_6.2 (%T) = binding_pattern v +// CHECK:STDOUT: %.loc13: @F.%T.loc6_6.2 (%T) = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref @F.%T.loc6_6.2 (%T) = var v +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)] // CHECK:STDOUT: %v: ref @F.%T.loc6_6.2 (%T) = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/generic/local.carbon b/toolchain/check/testdata/generic/local.carbon index 5d2e3507a213..49c770904d0d 100644 --- a/toolchain/check/testdata/generic/local.carbon +++ b/toolchain/check/testdata/generic/local.carbon @@ -107,7 +107,11 @@ class C(C:! type) { // CHECK:STDOUT: %complete_type.loc7_3.2: = complete_type_witness @C.%struct_type.x (%struct_type.x.2ac) [symbolic = %complete_type.loc7_3.2 (constants.%complete_type.4339)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc6: @C.%C.elem (%C.elem.cca) = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc6_10: @C.%C.elem (%C.elem.cca) = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc6_5: @C.%C.elem (%C.elem.cca) = var_pattern %.loc6_10 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @C.%C.elem (%C.elem.cca) = var // CHECK:STDOUT: %complete_type.loc7_3.1: = complete_type_witness %struct_type.x.2ac [symbolic = %complete_type.loc7_3.2 (constants.%complete_type.4339)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc7_3.1 // CHECK:STDOUT: } @@ -122,8 +126,11 @@ class C(C:! type) { // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc5_11.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc5_11.2 (constants.%T)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %C.d45 = binding_pattern v +// CHECK:STDOUT: %.loc8_3.1: %C.d45 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %C.d45 = var v -// CHECK:STDOUT: %v: ref %C.d45 = bind_name v, %v.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc8_26.1: %struct_type.x.c96 = struct_literal (%int_1) // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -134,8 +141,15 @@ class C(C:! type) { // CHECK:STDOUT: %.loc8_26.3: ref %i32 = class_element_access %v.var, element0 // CHECK:STDOUT: %.loc8_26.4: init %i32 = initialize_from %.loc8_26.2 to %.loc8_26.3 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc8_26.5: init %C.d45 = class_init (%.loc8_26.4), %v.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc8_27: init %C.d45 = converted %.loc8_26.1, %.loc8_26.5 [template = constants.%C.val] -// CHECK:STDOUT: assign %v.var, %.loc8_27 +// CHECK:STDOUT: %.loc8_3.2: init %C.d45 = converted %.loc8_26.1, %.loc8_26.5 [template = constants.%C.val] +// CHECK:STDOUT: assign %v.var, %.loc8_3.2 +// CHECK:STDOUT: %.loc8_15: type = splice_block %C [template = constants.%C.d45] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, %C.decl [template = constants.%C.generic] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%i32) [template = constants.%C.d45] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %C.d45 = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/global/class_obj.carbon b/toolchain/check/testdata/global/class_obj.carbon index 3d7236822d92..e6502bdb6db1 100644 --- a/toolchain/check/testdata/global/class_obj.carbon +++ b/toolchain/check/testdata/global/class_obj.carbon @@ -35,7 +35,12 @@ var a: A = {}; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: %.loc12: %A = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %A = var a +// CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A] // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -48,8 +53,8 @@ var a: A = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc12_13.2: init %A = class_init (), file.%a.var [template = constants.%A.val] -// CHECK:STDOUT: %.loc12_14: init %A = converted %.loc12_13.1, %.loc12_13.2 [template = constants.%A.val] -// CHECK:STDOUT: assign file.%a.var, %.loc12_14 +// CHECK:STDOUT: %.loc12_1: init %A = converted %.loc12_13.1, %.loc12_13.2 [template = constants.%A.val] +// CHECK:STDOUT: assign file.%a.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/global/class_with_fun.carbon b/toolchain/check/testdata/global/class_with_fun.carbon index 7a9ea821c727..6631c5113658 100644 --- a/toolchain/check/testdata/global/class_with_fun.carbon +++ b/toolchain/check/testdata/global/class_with_fun.carbon @@ -50,7 +50,12 @@ var a: A = {}; // CHECK:STDOUT: %return.param: ref %A = out_param runtime_param0 // CHECK:STDOUT: %return: ref %A = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: %.loc16: %A = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %A = var a +// CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A] // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -71,8 +76,8 @@ var a: A = {}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc16_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc16_13.2: init %A = class_init (), file.%a.var [template = constants.%A.val] -// CHECK:STDOUT: %.loc16_14: init %A = converted %.loc16_13.1, %.loc16_13.2 [template = constants.%A.val] -// CHECK:STDOUT: assign file.%a.var, %.loc16_14 +// CHECK:STDOUT: %.loc16_1: init %A = converted %.loc16_13.1, %.loc16_13.2 [template = constants.%A.val] +// CHECK:STDOUT: assign file.%a.var, %.loc16_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/global/decl.carbon b/toolchain/check/testdata/global/decl.carbon index 12bfb9ce58b6..43ef14d2188b 100644 --- a/toolchain/check/testdata/global/decl.carbon +++ b/toolchain/check/testdata/global/decl.carbon @@ -30,7 +30,15 @@ var a: i32; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc10_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc10_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/global/simple_init.carbon b/toolchain/check/testdata/global/simple_init.carbon index b1f78fd559bf..7d47c485687e 100644 --- a/toolchain/check/testdata/global/simple_init.carbon +++ b/toolchain/check/testdata/global/simple_init.carbon @@ -39,7 +39,15 @@ var a: i32 = 0; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc10_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc10_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/global/simple_with_fun.carbon b/toolchain/check/testdata/global/simple_with_fun.carbon index d367cb8d339d..b9b2b682cb66 100644 --- a/toolchain/check/testdata/global/simple_with_fun.carbon +++ b/toolchain/check/testdata/global/simple_with_fun.carbon @@ -56,7 +56,15 @@ var a: i32 = test_a(); // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc15_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc15_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/if/fail_scope.carbon b/toolchain/check/testdata/if/fail_scope.carbon index dc4524e13738..84382b136b00 100644 --- a/toolchain/check/testdata/if/fail_scope.carbon +++ b/toolchain/check/testdata/if/fail_scope.carbon @@ -61,8 +61,8 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %b.param: bool = value_param runtime_param0 // CHECK:STDOUT: %.loc11_16.1: type = splice_block %.loc11_16.3 [template = bool] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] @@ -81,15 +81,23 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: %.loc13_5.1: %i32 = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %i32 = var n -// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_2, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_2) [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc13: init %i32 = converted %int_2, %int.convert_checked [template = constants.%int_2.ef8] -// CHECK:STDOUT: assign %n.var, %.loc13 +// CHECK:STDOUT: %.loc13_5.2: init %i32 = converted %int_2, %int.convert_checked [template = constants.%int_2.ef8] +// CHECK:STDOUT: assign %n.var, %.loc13_5.2 +// CHECK:STDOUT: %.loc13_12: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %n.ref.loc14: ref %i32 = name_ref n, %n // CHECK:STDOUT: %.loc14: %i32 = bind_value %n.ref.loc14 // CHECK:STDOUT: return %.loc14 diff --git a/toolchain/check/testdata/if_expr/basic.carbon b/toolchain/check/testdata/if_expr/basic.carbon index f95d03b387d6..ff0002216668 100644 --- a/toolchain/check/testdata/if_expr/basic.carbon +++ b/toolchain/check/testdata/if_expr/basic.carbon @@ -90,8 +90,11 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b.param_patt: bool, %n.param_patt: %i32, %m.param_patt: %i32) -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %array_type = binding_pattern x +// CHECK:STDOUT: %.loc12_3.1: %array_type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %array_type = var x -// CHECK:STDOUT: %x: ref %array_type = bind_name x, %x.var // CHECK:STDOUT: %int_0.loc12_22: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %.loc12_24.1: %tuple.type = tuple_literal (%int_0.loc12_22) // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -103,8 +106,15 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: %.loc12_24.3: ref %i32 = array_index %x.var, %int_0.loc12_24 // CHECK:STDOUT: %.loc12_24.4: init %i32 = initialize_from %.loc12_24.2 to %.loc12_24.3 [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc12_24.5: init %array_type = array_init (%.loc12_24.4) to %x.var [template = constants.%array] -// CHECK:STDOUT: %.loc12_25: init %array_type = converted %.loc12_24.1, %.loc12_24.5 [template = constants.%array] -// CHECK:STDOUT: assign %x.var, %.loc12_25 +// CHECK:STDOUT: %.loc12_3.2: init %array_type = converted %.loc12_24.1, %.loc12_24.5 [template = constants.%array] +// CHECK:STDOUT: assign %x.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_17: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %array_type = bind_name x, %x.var // CHECK:STDOUT: %b.ref: bool = name_ref b, %b // CHECK:STDOUT: if %b.ref br !if.expr.then else br !if.expr.else // CHECK:STDOUT: diff --git a/toolchain/check/testdata/if_expr/constant_condition.carbon b/toolchain/check/testdata/if_expr/constant_condition.carbon index 4b5a565048ba..cc542a59bbb9 100644 --- a/toolchain/check/testdata/if_expr/constant_condition.carbon +++ b/toolchain/check/testdata/if_expr/constant_condition.carbon @@ -125,8 +125,8 @@ fn PartiallyConstant(t: type) -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -136,8 +136,8 @@ fn PartiallyConstant(t: type) -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc28: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc28: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %t.param: type = value_param runtime_param0 // CHECK:STDOUT: %t: type = bind_name t, %t.param // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1 @@ -219,20 +219,72 @@ fn PartiallyConstant(t: type) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Constant() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc23_3.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_1, %impl.elem0 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc23: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %v.var, %.loc23 +// CHECK:STDOUT: %.loc23_3.2: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %v.var, %.loc23_3.2 +// CHECK:STDOUT: br !.loc23_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc23_13: +// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %true br !if.expr.then.loc23 else br !if.expr.else.loc23 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc23: +// CHECK:STDOUT: %int_32.loc23_23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result.loc23(%i32.loc23_23) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc23: +// CHECK:STDOUT: %int_32.loc23_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc23: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: br !if.expr.result.loc23(%ptr.loc23) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc23: +// CHECK:STDOUT: %.loc23_10: type = block_arg !if.expr.result.loc23 [template = constants.%i32] +// CHECK:STDOUT: br !.loc23_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc23_7: +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %ptr = binding_pattern w +// CHECK:STDOUT: %.loc24_3: %ptr = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %ptr = var w -// CHECK:STDOUT: %w: ref %ptr = bind_name w, %w.var // CHECK:STDOUT: %v.ref: ref %i32 = name_ref v, %v // CHECK:STDOUT: %addr: %ptr = addr_of %v.ref // CHECK:STDOUT: assign %w.var, %addr +// CHECK:STDOUT: br !.loc24_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc24_13: +// CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %false br !if.expr.then.loc24 else br !if.expr.else.loc24 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc24: +// CHECK:STDOUT: %int_32.loc24_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc24_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result.loc24(%i32.loc24_24) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc24: +// CHECK:STDOUT: %int_32.loc24_33: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc24_33: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc24: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: br !if.expr.result.loc24(%ptr.loc24) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc24: +// CHECK:STDOUT: %.loc24_10: type = block_arg !if.expr.result.loc24 [template = constants.%ptr] +// CHECK:STDOUT: br !.loc24_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc24_7: +// CHECK:STDOUT: %w: ref %ptr = bind_name w, %w.var // CHECK:STDOUT: %w.ref: ref %ptr = name_ref w, %w // CHECK:STDOUT: %.loc25_11: %ptr = bind_value %w.ref // CHECK:STDOUT: %.loc25_10.1: ref %i32 = deref %.loc25_11 @@ -242,20 +294,69 @@ fn PartiallyConstant(t: type) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @PartiallyConstant(%t.param_patt: type) -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc29_3.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_1, %impl.elem0 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc29: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %v.var, %.loc29 +// CHECK:STDOUT: %.loc29_3.2: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %v.var, %.loc29_3.2 +// CHECK:STDOUT: br !.loc29_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc29_13: +// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %true br !if.expr.then.loc29 else br !if.expr.else.loc29 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc29: +// CHECK:STDOUT: %int_32.loc29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result.loc29(%i32.loc29) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc29: +// CHECK:STDOUT: %t.ref.loc29: type = name_ref t, %t +// CHECK:STDOUT: br !if.expr.result.loc29(%t.ref.loc29) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc29: +// CHECK:STDOUT: %.loc29_10: type = block_arg !if.expr.result.loc29 [template = constants.%i32] +// CHECK:STDOUT: br !.loc29_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc29_7: +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %ptr = binding_pattern w +// CHECK:STDOUT: %.loc30_3: %ptr = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %ptr = var w -// CHECK:STDOUT: %w: ref %ptr = bind_name w, %w.var // CHECK:STDOUT: %v.ref: ref %i32 = name_ref v, %v // CHECK:STDOUT: %addr: %ptr = addr_of %v.ref // CHECK:STDOUT: assign %w.var, %addr +// CHECK:STDOUT: br !.loc30_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc30_13: +// CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %false br !if.expr.then.loc30 else br !if.expr.else.loc30 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc30: +// CHECK:STDOUT: %t.ref.loc30: type = name_ref t, %t +// CHECK:STDOUT: br !if.expr.result.loc30(%t.ref.loc30) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc30: +// CHECK:STDOUT: %int_32.loc30: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc30: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: br !if.expr.result.loc30(%ptr) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc30: +// CHECK:STDOUT: %.loc30_10: type = block_arg !if.expr.result.loc30 [template = constants.%ptr] +// CHECK:STDOUT: br !.loc30_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc30_7: +// CHECK:STDOUT: %w: ref %ptr = bind_name w, %w.var // CHECK:STDOUT: %w.ref: ref %ptr = name_ref w, %w // CHECK:STDOUT: %.loc31_11: %ptr = bind_value %w.ref // CHECK:STDOUT: %.loc31_10.1: ref %i32 = deref %.loc31_11 diff --git a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon index fe5c3898170c..c754614d2884 100644 --- a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon +++ b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon @@ -26,10 +26,14 @@ // CHECK:STDERR: let x: i32 = if true then 1 else 0; -// CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+4]]:8: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] +// CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+8]]:8: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] // CHECK:STDERR: var y: if true then i32 else f64; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: +// CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+4]]:8: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] +// CHECK:STDERR: var y: if true then i32 else f64; +// CHECK:STDERR: ^~~~~~~ +// CHECK:STDERR: var y: if true then i32 else f64; // CHECK:STDERR: fail_not_in_function.carbon:[[@LINE+8]]:9: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] @@ -77,12 +81,24 @@ class C { // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .x = .inst43.loc27_5 +// CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc27: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: %i32 = bind_name x, .inst998.loc27_14 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc37: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y // CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { @@ -96,7 +112,11 @@ class C { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc50: %C.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc54_8: %C.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc54_3: %C.elem = var_pattern %.loc54_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/if_expr/fail_partial_constant.carbon b/toolchain/check/testdata/if_expr/fail_partial_constant.carbon index 2bb78a8d9184..d6cf535fe59e 100644 --- a/toolchain/check/testdata/if_expr/fail_partial_constant.carbon +++ b/toolchain/check/testdata/if_expr/fail_partial_constant.carbon @@ -47,6 +47,8 @@ fn ChosenBranchIsNonConstant(t: type) { // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: %ConditionIsNonConstant.type: type = fn_type @ConditionIsNonConstant [template] // CHECK:STDOUT: %ConditionIsNonConstant: %ConditionIsNonConstant.type = struct_value () [template] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -81,10 +83,35 @@ fn ChosenBranchIsNonConstant(t: type) { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConditionIsNonConstant(%b.param_patt: bool) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: %.loc12_3: = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref = var v -// CHECK:STDOUT: %v: ref = bind_name v, %v.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: assign %v.var, +// CHECK:STDOUT: br !.loc12_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc12_13: +// CHECK:STDOUT: %b.ref: bool = name_ref b, %b +// CHECK:STDOUT: if %b.ref br !if.expr.then else br !if.expr.else +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then: +// CHECK:STDOUT: %int_32.loc12_20: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result(%i32.loc12_20) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else: +// CHECK:STDOUT: %int_32.loc12_29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result(%i32.loc12_29) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result: +// CHECK:STDOUT: %.loc12_10: type = block_arg !if.expr.result +// CHECK:STDOUT: br !.loc12_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc12_7: +// CHECK:STDOUT: %v: = bind_name v, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -93,7 +120,11 @@ fn ChosenBranchIsNonConstant(t: type) { // CHECK:STDOUT: constants { // CHECK:STDOUT: %ChosenBranchIsNonConstant.type: type = fn_type @ChosenBranchIsNonConstant [template] // CHECK:STDOUT: %ChosenBranchIsNonConstant: %ChosenBranchIsNonConstant.type = struct_value () [template] +// CHECK:STDOUT: %true: bool = bool_literal true [template] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %false: bool = bool_literal false [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -121,14 +152,62 @@ fn ChosenBranchIsNonConstant(t: type) { // CHECK:STDOUT: // CHECK:STDOUT: fn @ChosenBranchIsNonConstant(%t.param_patt: type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: %.loc9_3: = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref = var v -// CHECK:STDOUT: %v: ref = bind_name v, %v.var // CHECK:STDOUT: %int_1.loc9: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: assign %v.var, +// CHECK:STDOUT: br !.loc9_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc9_13: +// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %true br !if.expr.then.loc9 else br !if.expr.else.loc9 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc9: +// CHECK:STDOUT: %t.ref.loc9: type = name_ref t, %t +// CHECK:STDOUT: br !if.expr.result.loc9(%t.ref.loc9) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc9: +// CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result.loc9(%i32.loc9) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc9: +// CHECK:STDOUT: %.loc9_10: type = block_arg !if.expr.result.loc9 +// CHECK:STDOUT: br !.loc9_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc9_7: +// CHECK:STDOUT: %v: = bind_name v, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: = binding_pattern w +// CHECK:STDOUT: %.loc14_3: = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref = var w -// CHECK:STDOUT: %w: ref = bind_name w, %w.var // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: assign %w.var, +// CHECK:STDOUT: br !.loc14_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc14_13: +// CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %false br !if.expr.then.loc14 else br !if.expr.else.loc14 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc14: +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: br !if.expr.result.loc14(%i32.loc14) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc14: +// CHECK:STDOUT: %t.ref.loc14: type = name_ref t, %t +// CHECK:STDOUT: br !if.expr.result.loc14(%t.ref.loc14) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc14: +// CHECK:STDOUT: %.loc14_10: type = block_arg !if.expr.result.loc14 +// CHECK:STDOUT: br !.loc14_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc14_7: +// CHECK:STDOUT: %w: = bind_name w, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/if_expr/struct.carbon b/toolchain/check/testdata/if_expr/struct.carbon index dfbe6e1f8f1f..c9c286b96d36 100644 --- a/toolchain/check/testdata/if_expr/struct.carbon +++ b/toolchain/check/testdata/if_expr/struct.carbon @@ -93,8 +93,11 @@ fn F(cond: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%cond.param_patt: bool) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %struct_type.a.b.501 = binding_pattern a +// CHECK:STDOUT: %.loc14_3.1: %struct_type.a.b.501 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %struct_type.a.b.501 = var a -// CHECK:STDOUT: %a: ref %struct_type.a.b.501 = bind_name a, %a.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc14_46.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) @@ -113,8 +116,16 @@ fn F(cond: bool) { // CHECK:STDOUT: %.loc14_46.6: ref %i32 = struct_access %a.var, element1 // CHECK:STDOUT: %.loc14_46.7: init %i32 = initialize_from %.loc14_46.5 to %.loc14_46.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc14_46.8: init %struct_type.a.b.501 = struct_init (%.loc14_46.4, %.loc14_46.7) to %a.var [template = constants.%struct] -// CHECK:STDOUT: %.loc14_47: init %struct_type.a.b.501 = converted %.loc14_46.1, %.loc14_46.8 [template = constants.%struct] -// CHECK:STDOUT: assign %a.var, %.loc14_47 +// CHECK:STDOUT: %.loc14_3.2: init %struct_type.a.b.501 = converted %.loc14_46.1, %.loc14_46.8 [template = constants.%struct] +// CHECK:STDOUT: assign %a.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_27: type = splice_block %struct_type.a.b [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc14_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %struct_type.a.b.501 = bind_name a, %a.var // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [template = constants.%G] // CHECK:STDOUT: %cond.ref: bool = name_ref cond, %cond // CHECK:STDOUT: if %cond.ref br !if.expr.then else br !if.expr.else diff --git a/toolchain/check/testdata/impl/extend_impl_generic.carbon b/toolchain/check/testdata/impl/extend_impl_generic.carbon index 86c74e733e2a..dc446e9214d1 100644 --- a/toolchain/check/testdata/impl/extend_impl_generic.carbon +++ b/toolchain/check/testdata/impl/extend_impl_generic.carbon @@ -176,7 +176,11 @@ class X(U:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Param { -// CHECK:STDOUT: %.loc9: %Param.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc9_8: %Param.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc9_3: %Param.elem = var_pattern %.loc9_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %Param.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x.ed6 [template = constants.%complete_type.1ec] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -217,6 +221,9 @@ class X(U:! type) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%c.param_patt: %C) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %C.ref.loc21: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %.loc21_17: %F.assoc_type.b26 = specific_constant @HasF.%assoc0.loc5_14.1, @HasF(constants.%Param) [template = constants.%assoc0.501] // CHECK:STDOUT: %F.ref.loc21: %F.assoc_type.b26 = name_ref F, %.loc21_17 [template = constants.%assoc0.501] @@ -224,12 +231,18 @@ class X(U:! type) { // CHECK:STDOUT: %.loc21_20.1: ref %Param = temporary_storage // CHECK:STDOUT: %F.call.loc21: init %Param = call %impl.elem0.loc21() to %.loc21_20.1 // CHECK:STDOUT: %.loc21_20.2: ref %Param = temporary %.loc21_20.1, %F.call.loc21 -// CHECK:STDOUT: %x.ref.loc21: %Param.elem = name_ref x, @Param.%.loc9 [template = @Param.%.loc9] -// CHECK:STDOUT: %.loc21_21.1: ref %i32 = class_element_access %.loc21_20.2, element0 -// CHECK:STDOUT: %.loc21_21.2: %i32 = bind_value %.loc21_21.1 -// CHECK:STDOUT: %a: %i32 = bind_name a, %.loc21_21.2 +// CHECK:STDOUT: %x.ref.loc21: %Param.elem = name_ref x, @Param.%.loc9_8 [template = @Param.%.loc9_8] +// CHECK:STDOUT: %.loc21_21: ref %i32 = class_element_access %.loc21_20.2, element0 +// CHECK:STDOUT: %.loc21_10: type = splice_block %i32.loc21 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %i32 = bind_name a, %.loc21_21 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc22_3: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b -// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: %c.ref: %C = name_ref c, %c // CHECK:STDOUT: %.loc22_17: %F.assoc_type.b26 = specific_constant @HasF.%assoc0.loc5_14.1, @HasF(constants.%Param) [template = constants.%assoc0.501] // CHECK:STDOUT: %F.ref.loc22: %F.assoc_type.b26 = name_ref F, %.loc22_17 [template = constants.%assoc0.501] @@ -237,10 +250,15 @@ class X(U:! type) { // CHECK:STDOUT: %.loc22_20.1: ref %Param = temporary_storage // CHECK:STDOUT: %F.call.loc22: init %Param = call %impl.elem0.loc22() to %.loc22_20.1 // CHECK:STDOUT: %.loc22_20.2: ref %Param = temporary %.loc22_20.1, %F.call.loc22 -// CHECK:STDOUT: %x.ref.loc22: %Param.elem = name_ref x, @Param.%.loc9 [template = @Param.%.loc9] +// CHECK:STDOUT: %x.ref.loc22: %Param.elem = name_ref x, @Param.%.loc9_8 [template = @Param.%.loc9_8] // CHECK:STDOUT: %.loc22_21.1: ref %i32 = class_element_access %.loc22_20.2, element0 // CHECK:STDOUT: %.loc22_21.2: %i32 = bind_value %.loc22_21.1 // CHECK:STDOUT: assign %b.var, %.loc22_21.2 +// CHECK:STDOUT: %.loc22_10: type = splice_block %i32.loc22 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/impl_as.carbon b/toolchain/check/testdata/impl/impl_as.carbon index 4e1ecfcf045e..f2c8182ea986 100644 --- a/toolchain/check/testdata/impl/impl_as.carbon +++ b/toolchain/check/testdata/impl/impl_as.carbon @@ -94,12 +94,17 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc19_7.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %.loc19_19.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc19_19.2: init %C = class_init (), %c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc19_20: init %C = converted %.loc19_19.1, %.loc19_19.2 [template = constants.%C.val] -// CHECK:STDOUT: assign %c.var, %.loc19_20 +// CHECK:STDOUT: %.loc19_7.2: init %C = converted %.loc19_19.1, %.loc19_19.2 [template = constants.%C.val] +// CHECK:STDOUT: assign %c.var, %.loc19_7.2 +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/impl_forall.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/impl_forall.carbon index 5f0d7ab5bada..e5d09a5cf8fc 100644 --- a/toolchain/check/testdata/impl/lookup/no_prelude/impl_forall.carbon +++ b/toolchain/check/testdata/impl/lookup/no_prelude/impl_forall.carbon @@ -275,7 +275,11 @@ fn TestSpecific(a: A({})) -> {} { // CHECK:STDOUT: %complete_type.loc4_1.2: = complete_type_witness @A.%struct_type.n (%struct_type.n.848971.1) [symbolic = %complete_type.loc4_1.2 (constants.%complete_type.84bb3d.1)] // CHECK:STDOUT: // CHECK:STDOUT: class { -// CHECK:STDOUT: %.loc3: @A.%A.elem (%A.elem.1ceb36.1) = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc3_8: @A.%A.elem (%A.elem.1ceb36.1) = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc3_3: @A.%A.elem (%A.elem.1ceb36.1) = var_pattern %.loc3_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref @A.%A.elem (%A.elem.1ceb36.1) = var // CHECK:STDOUT: %complete_type.loc4_1.1: = complete_type_witness %struct_type.n.848971.1 [symbolic = %complete_type.loc4_1.2 (constants.%complete_type.84bb3d.1)] // CHECK:STDOUT: complete_type_witness = %complete_type.loc4_1.1 // CHECK:STDOUT: } @@ -302,7 +306,7 @@ fn TestSpecific(a: A({})) -> {} { // CHECK:STDOUT: fn[%self.param_patt: @F.2.%A (%A.13025a.2)]() -> @F.2.%V (%V) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: @F.2.%A (%A.13025a.2) = name_ref self, %self -// CHECK:STDOUT: %n.ref: @F.2.%A.elem (%A.elem.1ceb36.2) = name_ref n, @A.%.loc3 [template = @A.%.loc3] +// CHECK:STDOUT: %n.ref: @F.2.%A.elem (%A.elem.1ceb36.2) = name_ref n, @A.%.loc3_8 [template = @A.%.loc3_8] // CHECK:STDOUT: %.loc12_16.1: ref @F.2.%V (%V) = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc12_16.2: @F.2.%V (%V) = bind_value %.loc12_16.1 // CHECK:STDOUT: return %.loc12_16.2 diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon index 9d1dbb6285f2..75ba7860f63f 100644 --- a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon +++ b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon @@ -1255,14 +1255,24 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: // CHECK:STDOUT: fn @L() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %obj.patt: %AnyParam.241 = binding_pattern obj +// CHECK:STDOUT: %.loc13_3.1: %AnyParam.241 = var_pattern %obj.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %obj.var: ref %AnyParam.241 = var obj -// CHECK:STDOUT: %obj: ref %AnyParam.241 = bind_name obj, %obj.var // CHECK:STDOUT: %.loc13_58.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc13_58.2: init %AnyParam.241 = class_init (), %obj.var [template = constants.%AnyParam.val] -// CHECK:STDOUT: %.loc13_59: init %AnyParam.241 = converted %.loc13_58.1, %.loc13_58.2 [template = constants.%AnyParam.val] -// CHECK:STDOUT: assign %obj.var, %.loc13_59 +// CHECK:STDOUT: %.loc13_3.2: init %AnyParam.241 = converted %.loc13_58.1, %.loc13_58.2 [template = constants.%AnyParam.val] +// CHECK:STDOUT: assign %obj.var, %.loc13_3.2 +// CHECK:STDOUT: %.loc13_53: type = splice_block %AnyParam [template = constants.%AnyParam.241] { +// CHECK:STDOUT: %PackageHasParam.ref.loc13: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %AnyParam.ref: %AnyParam.type = name_ref AnyParam, imports.%import_ref.8b7 [template = constants.%AnyParam.generic] +// CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.c92 = name_ref GenericInterface, file.%GenericInterface.decl [template = constants.%GenericInterface.generic] +// CHECK:STDOUT: %AnyParam: type = class_type @AnyParam, @AnyParam(constants.%GenericInterface.type.c92, constants.%GenericInterface.generic) [template = constants.%AnyParam.241] +// CHECK:STDOUT: } +// CHECK:STDOUT: %obj: ref %AnyParam.241 = bind_name obj, %obj.var // CHECK:STDOUT: %obj.ref: ref %AnyParam.241 = name_ref obj, %obj -// CHECK:STDOUT: %PackageHasParam.ref: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %PackageHasParam.ref.loc14: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] // CHECK:STDOUT: %Y.ref: type = name_ref Y, imports.%import_ref.d7e [template = constants.%Y.type] // CHECK:STDOUT: %K.ref: %K.assoc_type = name_ref K, imports.%import_ref.df6 [template = constants.%assoc0] // CHECK:STDOUT: %impl.elem0: %K.type.311 = impl_witness_access constants.%impl_witness, element0 [template = constants.%K.2e9] @@ -1303,6 +1313,8 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: %M.type: type = fn_type @M [template] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %M: %M.type = struct_value () [template] +// CHECK:STDOUT: %AnyParam.type: type = generic_class_type @AnyParam [template] +// CHECK:STDOUT: %AnyParam.generic: %AnyParam.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] @@ -1337,7 +1349,9 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: .GenericInterface = %import_ref.3e7 // CHECK:STDOUT: import PackageGenericInterface//default // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.8b7: %AnyParam.type = import_ref PackageHasParam//default, AnyParam, loaded [template = constants.%AnyParam.generic] // CHECK:STDOUT: %import_ref.8f2: = import_ref PackageHasParam//default, loc4_34, loaded [template = constants.%complete_type] +// CHECK:STDOUT: %import_ref.3e7: %GenericInterface.type.0da = import_ref PackageGenericInterface//default, GenericInterface, loaded [template = constants.%GenericInterface.generic] // CHECK:STDOUT: %import_ref.c3b = import_ref PackageGenericInterface//default, inst28 [no loc], unloaded // CHECK:STDOUT: %import_ref.d7e: type = import_ref PackageHasParam//default, Y, loaded [template = constants.%Y.type] // CHECK:STDOUT: %import_ref.dc1 = import_ref PackageHasParam//default, inst40 [no loc], unloaded @@ -1401,14 +1415,25 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: // CHECK:STDOUT: fn @M() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %obj.patt: %AnyParam.861 = binding_pattern obj +// CHECK:STDOUT: %.loc8_3.1: %AnyParam.861 = var_pattern %obj.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %obj.var: ref %AnyParam.861 = var obj -// CHECK:STDOUT: %obj: ref %AnyParam.861 = bind_name obj, %obj.var // CHECK:STDOUT: %.loc9_50.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc9_50.2: init %AnyParam.861 = class_init (), %obj.var [template = constants.%AnyParam.val] -// CHECK:STDOUT: %.loc9_51: init %AnyParam.861 = converted %.loc9_50.1, %.loc9_50.2 [template = constants.%AnyParam.val] -// CHECK:STDOUT: assign %obj.var, %.loc9_51 +// CHECK:STDOUT: %.loc8_3.2: init %AnyParam.861 = converted %.loc9_50.1, %.loc9_50.2 [template = constants.%AnyParam.val] +// CHECK:STDOUT: assign %obj.var, %.loc8_3.2 +// CHECK:STDOUT: %.loc9_45: type = splice_block %AnyParam [template = constants.%AnyParam.861] { +// CHECK:STDOUT: %PackageHasParam.ref.loc8: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %AnyParam.ref: %AnyParam.type = name_ref AnyParam, imports.%import_ref.8b7 [template = constants.%AnyParam.generic] +// CHECK:STDOUT: %PackageGenericInterface.ref: = name_ref PackageGenericInterface, imports.%PackageGenericInterface [template = imports.%PackageGenericInterface] +// CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.0da = name_ref GenericInterface, imports.%import_ref.3e7 [template = constants.%GenericInterface.generic] +// CHECK:STDOUT: %AnyParam: type = class_type @AnyParam, @AnyParam(constants.%GenericInterface.type.0da, constants.%GenericInterface.generic) [template = constants.%AnyParam.861] +// CHECK:STDOUT: } +// CHECK:STDOUT: %obj: ref %AnyParam.861 = bind_name obj, %obj.var // CHECK:STDOUT: %obj.ref: ref %AnyParam.861 = name_ref obj, %obj -// CHECK:STDOUT: %PackageHasParam.ref: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %PackageHasParam.ref.loc10: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] // CHECK:STDOUT: %Y.ref: type = name_ref Y, imports.%import_ref.d7e [template = constants.%Y.type] // CHECK:STDOUT: %K.ref: %K.assoc_type = name_ref K, imports.%import_ref.df6 [template = constants.%assoc0] // CHECK:STDOUT: %impl.elem0: %K.type.311 = impl_witness_access constants.%impl_witness, element0 [template = constants.%K.c3c] diff --git a/toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon b/toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon index 0fdc707f9e0f..fe493abcc7c7 100644 --- a/toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon +++ b/toolchain/check/testdata/impl/no_prelude/fail_impl_bad_assoc_const.carbon @@ -13,9 +13,9 @@ interface I { let T:! type; } // CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE+7]]:12: error: associated constant T not given a value in impl of interface I [ImplAssociatedConstantNeedsValue] // CHECK:STDERR: impl () as I {} // CHECK:STDERR: ^ -// CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE-5]]:15: note: associated constant T declared here [AssociatedConstantHere] +// CHECK:STDERR: fail_impl_bad_assoc_const.carbon:[[@LINE-5]]:19: note: associated constant T declared here [AssociatedConstantHere] // CHECK:STDERR: interface I { let T:! type; } -// CHECK:STDERR: ^~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: impl () as I {} diff --git a/toolchain/check/testdata/impl/no_prelude/import_builtin_call.carbon b/toolchain/check/testdata/impl/no_prelude/import_builtin_call.carbon index 725d01006111..785e4b17a0fa 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_builtin_call.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_builtin_call.carbon @@ -1043,9 +1043,31 @@ var n: Int(64) = MakeFromClass(FromLiteral(64) as OtherInt); // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %m.patt: %i64.builtin = binding_pattern m +// CHECK:STDOUT: %.loc6_1: %i64.builtin = var_pattern %m.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %m.var: ref %i64.builtin = var m +// CHECK:STDOUT: %.loc6_14.1: type = splice_block %.loc6_14.3 [template = constants.%i64.builtin] { +// CHECK:STDOUT: %Int.ref.loc6: %Int.type = name_ref Int, imports.%import_ref.4a2 [template = constants.%Int] +// CHECK:STDOUT: %int_64.loc6: Core.IntLiteral = int_value 64 [template = constants.%int_64.fab] +// CHECK:STDOUT: %int.make_type_signed.loc6: init type = call %Int.ref.loc6(%int_64.loc6) [template = constants.%i64.builtin] +// CHECK:STDOUT: %.loc6_14.2: type = value_of_initializer %int.make_type_signed.loc6 [template = constants.%i64.builtin] +// CHECK:STDOUT: %.loc6_14.3: type = converted %int.make_type_signed.loc6, %.loc6_14.2 [template = constants.%i64.builtin] +// CHECK:STDOUT: } // CHECK:STDOUT: %m: ref %i64.builtin = bind_name m, %m.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i64.builtin = binding_pattern n +// CHECK:STDOUT: %.loc7_1: %i64.builtin = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %i64.builtin = var n +// CHECK:STDOUT: %.loc7_14.1: type = splice_block %.loc7_14.3 [template = constants.%i64.builtin] { +// CHECK:STDOUT: %Int.ref.loc7: %Int.type = name_ref Int, imports.%import_ref.4a2 [template = constants.%Int] +// CHECK:STDOUT: %int_64.loc7: Core.IntLiteral = int_value 64 [template = constants.%int_64.fab] +// CHECK:STDOUT: %int.make_type_signed.loc7: init type = call %Int.ref.loc7(%int_64.loc7) [template = constants.%i64.builtin] +// CHECK:STDOUT: %.loc7_14.2: type = value_of_initializer %int.make_type_signed.loc7 [template = constants.%i64.builtin] +// CHECK:STDOUT: %.loc7_14.3: type = converted %int.make_type_signed.loc7, %.loc7_14.2 [template = constants.%i64.builtin] +// CHECK:STDOUT: } // CHECK:STDOUT: %n: ref %i64.builtin = bind_name n, %n.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon b/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon index 09c113e958af..14b1cc699c5b 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_interface_assoc_const.carbon @@ -266,7 +266,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -334,7 +334,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -416,7 +416,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -490,7 +490,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -576,9 +576,9 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.f40: type = import_ref Main//interface, I3, loaded [template = constants.%I3.type] // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.148 = import_ref Main//interface, inst23 [no loc], unloaded -// CHECK:STDOUT: %import_ref.4d5: %assoc_type = import_ref Main//interface, loc6_16, loaded [template = constants.%assoc0] -// CHECK:STDOUT: %import_ref.2f7: %assoc_type = import_ref Main//interface, loc7_16, loaded [template = constants.%assoc1] -// CHECK:STDOUT: %import_ref.fc4: %assoc_type = import_ref Main//interface, loc8_16, loaded [template = constants.%assoc2] +// CHECK:STDOUT: %import_ref.4d5: %assoc_type = import_ref Main//interface, loc6_9, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.2f7: %assoc_type = import_ref Main//interface, loc7_9, loaded [template = constants.%assoc1] +// CHECK:STDOUT: %import_ref.fc4: %assoc_type = import_ref Main//interface, loc8_9, loaded [template = constants.%assoc2] // CHECK:STDOUT: %import_ref.cdd = import_ref Main//interface, T1, unloaded // CHECK:STDOUT: %import_ref.bad = import_ref Main//interface, T2, unloaded // CHECK:STDOUT: %import_ref.742 = import_ref Main//interface, T3, unloaded @@ -689,7 +689,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -762,7 +762,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -836,7 +836,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.08d = import_ref Main//interface, T, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: @@ -907,7 +907,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.08d = import_ref Main//interface, T, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: @@ -978,7 +978,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.08d = import_ref Main//interface, T, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1050,7 +1050,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.dfc = import_ref Main//interface, NonType, unloaded // CHECK:STDOUT: %import_ref.e5d = import_ref Main//interface, inst15 [no loc], unloaded -// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_27, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.15c: %assoc_type = import_ref Main//interface, loc3_20, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.3b7: type = import_ref Main//interface, T, loaded [template = %T] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1128,7 +1128,7 @@ impl CC as NonType where .Y = {.a = {}} { } // CHECK:STDOUT: %import_ref.43d = import_ref Main//interface, I3, unloaded // CHECK:STDOUT: %import_ref.22d: type = import_ref Main//interface, NonType, loaded [template = constants.%NonType.type] // CHECK:STDOUT: %import_ref.8b7 = import_ref Main//interface, inst37 [no loc], unloaded -// CHECK:STDOUT: %import_ref.abe: %assoc_type = import_ref Main//interface, loc12_19, loaded [template = constants.%assoc0] +// CHECK:STDOUT: %import_ref.abe: %assoc_type = import_ref Main//interface, loc12_8, loaded [template = constants.%assoc0] // CHECK:STDOUT: %import_ref.d24: %struct_type.a.225 = import_ref Main//interface, Y, loaded [template = %Y] // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/no_prelude/import_use_generic.carbon b/toolchain/check/testdata/impl/no_prelude/import_use_generic.carbon index 847026a73723..d84eec6d3b5c 100644 --- a/toolchain/check/testdata/impl/no_prelude/import_use_generic.carbon +++ b/toolchain/check/testdata/impl/no_prelude/import_use_generic.carbon @@ -222,7 +222,17 @@ fn F() -> c.(I.F)() {} // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.7a7 = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C.7a7 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.7a7 = var c +// CHECK:STDOUT: %.loc6_12.1: type = splice_block %C [template = constants.%C.7a7] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %.loc6_11: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc6_12.2: type = converted %.loc6_11, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%empty_struct_type) [template = constants.%C.7a7] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.7a7 = bind_name c, %c.var // CHECK:STDOUT: %F.decl: %F.type.b25 = fn_decl @F.3 [template = constants.%F.c41] { // CHECK:STDOUT: %return.patt: = return_slot_pattern @@ -295,8 +305,8 @@ fn F() -> c.(I.F)() {} // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_17.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_17.2: init %C.7a7 = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_18: init %C.7a7 = converted %.loc6_17.1, %.loc6_17.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_18 +// CHECK:STDOUT: %.loc6_1: init %C.7a7 = converted %.loc6_17.1, %.loc6_17.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/array_element_access.carbon b/toolchain/check/testdata/index/array_element_access.carbon index 42be8c4608de..9154df6ff8cf 100644 --- a/toolchain/check/testdata/index/array_element_access.carbon +++ b/toolchain/check/testdata/index/array_element_access.carbon @@ -62,13 +62,47 @@ var d: i32 = a[b]; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] +// CHECK:STDOUT: %array_type: type = array_type %int_2, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc12_8: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc13_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc13_8: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: %.loc14_1: %i32 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %i32 = var d +// CHECK:STDOUT: %.loc14_8: type = splice_block %i32.loc14 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %i32 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -94,8 +128,8 @@ var d: i32 = a[b]; // CHECK:STDOUT: %.loc11_26.6: ref %i32 = array_index file.%a.var, %int_1.loc11 // CHECK:STDOUT: %.loc11_26.7: init %i32 = initialize_from %.loc11_26.5 to %.loc11_26.6 [template = constants.%int_24.365] // CHECK:STDOUT: %.loc11_26.8: init %array_type = array_init (%.loc11_26.4, %.loc11_26.7) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_27: init %array_type = converted %.loc11_26.1, %.loc11_26.8 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_27 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_26.1, %.loc11_26.8 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc12: = bound_method %int_1.loc12, %impl.elem0.loc12 [template = constants.%Convert.bound.ab5] diff --git a/toolchain/check/testdata/index/expr_category.carbon b/toolchain/check/testdata/index/expr_category.carbon index 4a632186a547..da39a9125a8b 100644 --- a/toolchain/check/testdata/index/expr_category.carbon +++ b/toolchain/check/testdata/index/expr_category.carbon @@ -102,11 +102,11 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %b.param_patt: %array_type = value_param_pattern %b.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %b.param: %array_type = value_param runtime_param0 -// CHECK:STDOUT: %.loc13: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %.loc13: type = splice_block %array_type.loc13 [template = constants.%array_type] { // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %int_3.loc13: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %int_3.loc13, %i32 [template = constants.%array_type] +// CHECK:STDOUT: %array_type.loc13: type = array_type %int_3.loc13, %i32 [template = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %b: %array_type = bind_name b, %b.param // CHECK:STDOUT: } @@ -115,11 +115,11 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %b.param_patt: %array_type = value_param_pattern %b.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %b.param: %array_type = value_param runtime_param0 -// CHECK:STDOUT: %.loc21: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %.loc21: type = splice_block %array_type.loc21 [template = constants.%array_type] { // CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %int_3.loc21: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] -// CHECK:STDOUT: %array_type: type = array_type %int_3.loc21, %i32 [template = constants.%array_type] +// CHECK:STDOUT: %array_type.loc21: type = array_type %int_3.loc21, %i32 [template = constants.%array_type] // CHECK:STDOUT: } // CHECK:STDOUT: %b: %array_type = bind_name b, %b.param // CHECK:STDOUT: } @@ -129,12 +129,15 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%b.param_patt: %array_type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc14_3.1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: %int_1.loc14_22: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc14_25: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc14: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc14_29.1: %tuple.type = tuple_literal (%int_1.loc14_22, %int_2.loc14_25, %int_3.loc14) +// CHECK:STDOUT: %int_3.loc14_28: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc14_29.1: %tuple.type = tuple_literal (%int_1.loc14_22, %int_2.loc14_25, %int_3.loc14_28) // CHECK:STDOUT: %impl.elem0.loc14_29.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc14_29.1: = bound_method %int_1.loc14_22, %impl.elem0.loc14_29.1 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc14_29.1: = specific_function %Convert.bound.loc14_29.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] @@ -152,22 +155,32 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc14_29.6: ref %i32 = array_index %a.var, %int_1.loc14_29 // CHECK:STDOUT: %.loc14_29.7: init %i32 = initialize_from %.loc14_29.5 to %.loc14_29.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %impl.elem0.loc14_29.3: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc14_29.3: = bound_method %int_3.loc14, %impl.elem0.loc14_29.3 [template = constants.%Convert.bound.b30] +// CHECK:STDOUT: %Convert.bound.loc14_29.3: = bound_method %int_3.loc14_28, %impl.elem0.loc14_29.3 [template = constants.%Convert.bound.b30] // CHECK:STDOUT: %Convert.specific_fn.loc14_29.3: = specific_function %Convert.bound.loc14_29.3, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc14_29.3: init %i32 = call %Convert.specific_fn.loc14_29.3(%int_3.loc14) [template = constants.%int_3.822] -// CHECK:STDOUT: %.loc14_29.8: init %i32 = converted %int_3.loc14, %int.convert_checked.loc14_29.3 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc14_29.3: init %i32 = call %Convert.specific_fn.loc14_29.3(%int_3.loc14_28) [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc14_29.8: init %i32 = converted %int_3.loc14_28, %int.convert_checked.loc14_29.3 [template = constants.%int_3.822] // CHECK:STDOUT: %int_2.loc14_29: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc14_29.9: ref %i32 = array_index %a.var, %int_2.loc14_29 // CHECK:STDOUT: %.loc14_29.10: init %i32 = initialize_from %.loc14_29.8 to %.loc14_29.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc14_29.11: init %array_type = array_init (%.loc14_29.4, %.loc14_29.7, %.loc14_29.10) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc14_30: init %array_type = converted %.loc14_29.1, %.loc14_29.11 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc14_30 +// CHECK:STDOUT: %.loc14_3.2: init %array_type = converted %.loc14_29.1, %.loc14_29.11 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_17: type = splice_block %array_type.loc14 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc14_16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc14: type = array_type %int_3.loc14_16, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %pa.patt: %ptr.235 = binding_pattern pa +// CHECK:STDOUT: %.loc17_3: %ptr.235 = var_pattern %pa.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %pa.var: ref %ptr.235 = var pa -// CHECK:STDOUT: %pa: ref %ptr.235 = bind_name pa, %pa.var // CHECK:STDOUT: %a.ref.loc17: ref %array_type = name_ref a, %a // CHECK:STDOUT: %int_0.loc17: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] -// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc17_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %impl.elem0.loc17: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc17: = bound_method %int_0.loc17, %impl.elem0.loc17 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc17: = specific_function %Convert.bound.loc17, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] @@ -177,6 +190,12 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc17_22: ref %i32 = array_index %a.ref.loc17, %.loc17_21.2 // CHECK:STDOUT: %addr: %ptr.235 = addr_of %.loc17_22 // CHECK:STDOUT: assign %pa.var, %addr +// CHECK:STDOUT: %.loc17_14: type = splice_block %ptr [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc17_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %pa: ref %ptr.235 = bind_name pa, %pa.var // CHECK:STDOUT: %a.ref.loc18: ref %array_type = name_ref a, %a // CHECK:STDOUT: %int_0.loc18: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32] @@ -200,12 +219,15 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: // CHECK:STDOUT: fn @ValueBinding(%b.param_patt: %array_type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc22_3.1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a -// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: %int_1.loc22_22: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc22_25: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %int_3.loc22: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] -// CHECK:STDOUT: %.loc22_29.1: %tuple.type = tuple_literal (%int_1.loc22_22, %int_2.loc22_25, %int_3.loc22) +// CHECK:STDOUT: %int_3.loc22_28: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %.loc22_29.1: %tuple.type = tuple_literal (%int_1.loc22_22, %int_2.loc22_25, %int_3.loc22_28) // CHECK:STDOUT: %impl.elem0.loc22_29.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc22_29.1: = bound_method %int_1.loc22_22, %impl.elem0.loc22_29.1 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc22_29.1: = specific_function %Convert.bound.loc22_29.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] @@ -223,16 +245,23 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc22_29.6: ref %i32 = array_index %a.var, %int_1.loc22_29 // CHECK:STDOUT: %.loc22_29.7: init %i32 = initialize_from %.loc22_29.5 to %.loc22_29.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %impl.elem0.loc22_29.3: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc22_29.3: = bound_method %int_3.loc22, %impl.elem0.loc22_29.3 [template = constants.%Convert.bound.b30] +// CHECK:STDOUT: %Convert.bound.loc22_29.3: = bound_method %int_3.loc22_28, %impl.elem0.loc22_29.3 [template = constants.%Convert.bound.b30] // CHECK:STDOUT: %Convert.specific_fn.loc22_29.3: = specific_function %Convert.bound.loc22_29.3, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] -// CHECK:STDOUT: %int.convert_checked.loc22_29.3: init %i32 = call %Convert.specific_fn.loc22_29.3(%int_3.loc22) [template = constants.%int_3.822] -// CHECK:STDOUT: %.loc22_29.8: init %i32 = converted %int_3.loc22, %int.convert_checked.loc22_29.3 [template = constants.%int_3.822] +// CHECK:STDOUT: %int.convert_checked.loc22_29.3: init %i32 = call %Convert.specific_fn.loc22_29.3(%int_3.loc22_28) [template = constants.%int_3.822] +// CHECK:STDOUT: %.loc22_29.8: init %i32 = converted %int_3.loc22_28, %int.convert_checked.loc22_29.3 [template = constants.%int_3.822] // CHECK:STDOUT: %int_2.loc22_29: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc22_29.9: ref %i32 = array_index %a.var, %int_2.loc22_29 // CHECK:STDOUT: %.loc22_29.10: init %i32 = initialize_from %.loc22_29.8 to %.loc22_29.9 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc22_29.11: init %array_type = array_init (%.loc22_29.4, %.loc22_29.7, %.loc22_29.10) to %a.var [template = constants.%array] -// CHECK:STDOUT: %.loc22_30: init %array_type = converted %.loc22_29.1, %.loc22_29.11 [template = constants.%array] -// CHECK:STDOUT: assign %a.var, %.loc22_30 +// CHECK:STDOUT: %.loc22_3.2: init %array_type = converted %.loc22_29.1, %.loc22_29.11 [template = constants.%array] +// CHECK:STDOUT: assign %a.var, %.loc22_3.2 +// CHECK:STDOUT: %.loc22_17: type = splice_block %array_type.loc22 [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_3.loc22_16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %array_type.loc22: type = array_type %int_3.loc22_16, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, %a // CHECK:STDOUT: %int_0.loc26: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [template = constants.%int_32] diff --git a/toolchain/check/testdata/index/fail_array_large_index.carbon b/toolchain/check/testdata/index/fail_array_large_index.carbon index f3f8f8db882a..d063921b2f5a 100644 --- a/toolchain/check/testdata/index/fail_array_large_index.carbon +++ b/toolchain/check/testdata/index/fail_array_large_index.carbon @@ -66,11 +66,37 @@ var c: i32 = a[0x7FFF_FFFF]; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc17_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc17_8: type = splice_block %i32.loc17 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc23_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc23_8: type = splice_block %i32.loc23 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -87,8 +113,8 @@ var c: i32 = a[0x7FFF_FFFF]; // CHECK:STDOUT: %.loc11_23.3: ref %i32 = array_index file.%a.var, %int_0 // CHECK:STDOUT: %.loc11_23.4: init %i32 = initialize_from %.loc11_23.2 to %.loc11_23.3 [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_23.5: init %array_type = array_init (%.loc11_23.4) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_24: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_24 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref.loc17: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] diff --git a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon index 808be111c5f4..c7ac0a347d18 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -55,9 +55,27 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc19_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc19_8: type = splice_block %i32.loc19 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -74,8 +92,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc11_23.3: ref %i32 = array_index file.%a.var, %int_0 // CHECK:STDOUT: %.loc11_23.4: init %i32 = initialize_from %.loc11_23.2 to %.loc11_23.3 [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_23.5: init %array_type = array_init (%.loc11_23.4) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_24: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_24 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %float: f64 = float_literal 2.6000000000000001 [template = constants.%float] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] diff --git a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon index 1fc58a050133..e7626c688c1c 100644 --- a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon @@ -54,9 +54,27 @@ var b: i32 = a[1]; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %array_type = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %array_type = var a +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -73,8 +91,8 @@ var b: i32 = a[1]; // CHECK:STDOUT: %.loc11_23.3: ref %i32 = array_index file.%a.var, %int_0 // CHECK:STDOUT: %.loc11_23.4: init %i32 = initialize_from %.loc11_23.2 to %.loc11_23.3 [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_23.5: init %array_type = array_init (%.loc11_23.4) to file.%a.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_24: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [template = constants.%array] -// CHECK:STDOUT: assign file.%a.var, %.loc11_24 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_23.1, %.loc11_23.5 [template = constants.%array] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] diff --git a/toolchain/check/testdata/index/fail_expr_category.carbon b/toolchain/check/testdata/index/fail_expr_category.carbon index e8f89618b231..1653206dca3f 100644 --- a/toolchain/check/testdata/index/fail_expr_category.carbon +++ b/toolchain/check/testdata/index/fail_expr_category.carbon @@ -109,12 +109,15 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%b.param_patt: %array_type) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %pb.patt: %ptr.235 = binding_pattern pb +// CHECK:STDOUT: %.loc19_3: %ptr.235 = var_pattern %pb.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %pb.var: ref %ptr.235 = var pb -// CHECK:STDOUT: %pb: ref %ptr.235 = bind_name pb, %pb.var // CHECK:STDOUT: %b.ref.loc19: %array_type = name_ref b, %b // CHECK:STDOUT: %int_0.loc19: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] -// CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc19_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %impl.elem0.loc19: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc19: = bound_method %int_0.loc19, %impl.elem0.loc19 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc19: = specific_function %Convert.bound.loc19, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] @@ -126,6 +129,12 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: %.loc19_22.3: %i32 = bind_value %.loc19_22.2 // CHECK:STDOUT: %addr.loc19: %ptr.235 = addr_of [template = ] // CHECK:STDOUT: assign %pb.var, %addr.loc19 +// CHECK:STDOUT: %.loc19_14: type = splice_block %ptr.loc19 [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc19_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc19: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %pb: ref %ptr.235 = bind_name pb, %pb.var // CHECK:STDOUT: %b.ref.loc24: %array_type = name_ref b, %b // CHECK:STDOUT: %int_0.loc24: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %int_32.loc24: Core.IntLiteral = int_value 32 [template = constants.%int_32] @@ -146,15 +155,18 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: %int.convert_checked.loc24_8: init %i32 = call %Convert.specific_fn.loc24_8(%int_4.loc24) [template = constants.%int_4.940] // CHECK:STDOUT: %.loc24_8: init %i32 = converted %int_4.loc24, %int.convert_checked.loc24_8 [template = constants.%int_4.940] // CHECK:STDOUT: assign %.loc24_6.3, %.loc24_8 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %pf.patt: %ptr.235 = binding_pattern pf +// CHECK:STDOUT: %.loc32_3: %ptr.235 = var_pattern %pf.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %pf.var: ref %ptr.235 = var pf -// CHECK:STDOUT: %pf: ref %ptr.235 = bind_name pf, %pf.var // CHECK:STDOUT: %F.ref.loc32: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %.loc32_21.1: ref %array_type = temporary_storage // CHECK:STDOUT: %F.call.loc32: init %array_type = call %F.ref.loc32() to %.loc32_21.1 // CHECK:STDOUT: %int_0.loc32: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %.loc32_21.2: ref %array_type = temporary %.loc32_21.1, %F.call.loc32 -// CHECK:STDOUT: %int_32.loc32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32.loc32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc32_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc32_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %impl.elem0.loc32: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc32: = bound_method %int_0.loc32, %impl.elem0.loc32 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc32: = specific_function %Convert.bound.loc32, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] @@ -165,6 +177,12 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: %.loc32_24.2: %i32 = bind_value %.loc32_24.1 // CHECK:STDOUT: %addr.loc32: %ptr.235 = addr_of [template = ] // CHECK:STDOUT: assign %pf.var, %addr.loc32 +// CHECK:STDOUT: %.loc32_14: type = splice_block %ptr.loc32 [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc32_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc32_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc32: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %pf: ref %ptr.235 = bind_name pf, %pf.var // CHECK:STDOUT: %F.ref.loc37: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %.loc37_5.1: ref %array_type = temporary_storage // CHECK:STDOUT: %F.call.loc37: init %array_type = call %F.ref.loc37() to %.loc37_5.1 diff --git a/toolchain/check/testdata/index/fail_invalid_base.carbon b/toolchain/check/testdata/index/fail_invalid_base.carbon index 3e5ca5f042f9..56da42b55376 100644 --- a/toolchain/check/testdata/index/fail_invalid_base.carbon +++ b/toolchain/check/testdata/index/fail_invalid_base.carbon @@ -70,14 +70,46 @@ var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %N: = namespace [template] {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc23_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc23_8: type = splice_block %i32.loc23 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc29_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc29_8: type = splice_block %i32.loc29 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: %.loc35_1: %i32 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %i32 = var d +// CHECK:STDOUT: %.loc35_8: type = splice_block %i32.loc35 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc35: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc35: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %i32 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_name_not_found.carbon b/toolchain/check/testdata/index/fail_name_not_found.carbon index 53c59cc511de..605e588e8f7d 100644 --- a/toolchain/check/testdata/index/fail_name_not_found.carbon +++ b/toolchain/check/testdata/index/fail_name_not_found.carbon @@ -45,11 +45,19 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b -// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: %a.ref: = name_ref a, [template = ] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: assign %b.var, +// CHECK:STDOUT: %.loc16_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_negative_indexing.carbon b/toolchain/check/testdata/index/fail_negative_indexing.carbon index 9f3f95e5a3dc..8c82fca8da58 100644 --- a/toolchain/check/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/index/fail_negative_indexing.carbon @@ -64,9 +64,27 @@ var d: i32 = c[-10]; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %array_type = binding_pattern c +// CHECK:STDOUT: %.loc11_1: %array_type = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %array_type = var c +// CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] +// CHECK:STDOUT: %array_type: type = array_type %int_2, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %array_type = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %i32 = var d +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %i32 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -92,8 +110,8 @@ var d: i32 = c[-10]; // CHECK:STDOUT: %.loc11_26.6: ref %i32 = array_index file.%c.var, %int_1 // CHECK:STDOUT: %.loc11_26.7: init %i32 = initialize_from %.loc11_26.5 to %.loc11_26.6 [template = constants.%int_42.c68] // CHECK:STDOUT: %.loc11_26.8: init %array_type = array_init (%.loc11_26.4, %.loc11_26.7) to file.%c.var [template = constants.%array] -// CHECK:STDOUT: %.loc11_27: init %array_type = converted %.loc11_26.1, %.loc11_26.8 [template = constants.%array] -// CHECK:STDOUT: assign file.%c.var, %.loc11_27 +// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_26.1, %.loc11_26.8 [template = constants.%array] +// CHECK:STDOUT: assign file.%c.var, %.loc11_1 // CHECK:STDOUT: %c.ref: ref %array_type = name_ref c, file.%c // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [template = constants.%int_10] // CHECK:STDOUT: %impl.elem0.loc16_16.1: %Op.type.e42 = impl_witness_access constants.%impl_witness.0f6, element0 [template = constants.%Op.bba] diff --git a/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon b/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon index 398347e5b6dd..8ad7a0e923ae 100644 --- a/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon +++ b/toolchain/check/testdata/interface/fail_assoc_const_bad_default.carbon @@ -24,9 +24,9 @@ interface I { // CHECK:STDOUT: constants { // CHECK:STDOUT: %I.type: type = facet_type <@I> [template] // CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template] // CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template] // CHECK:STDOUT: %assoc0.790: %assoc_type = assoc_entity element0, @I.%T [template] +// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -48,10 +48,10 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826] -// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42] -// CHECK:STDOUT: %.loc19: type = converted %int_42, [template = ] // CHECK:STDOUT: %T: type = assoc_const_decl T [template] // CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0.790] +// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42] +// CHECK:STDOUT: %.loc19: type = converted %int_42, [template = ] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self diff --git a/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon b/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon index 82c31a509ade..483e897bf46f 100644 --- a/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon +++ b/toolchain/check/testdata/interface/fail_todo_assoc_const_default.carbon @@ -26,12 +26,14 @@ interface I { // CHECK:STDOUT: constants { // CHECK:STDOUT: %I.type: type = facet_type <@I> [template] // CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %assoc_type.579: type = assoc_entity_type %I.type, type [template] +// CHECK:STDOUT: %assoc0.790: %assoc_type.579 = assoc_entity element0, @I.%T [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] -// CHECK:STDOUT: %assoc_type.579: type = assoc_entity_type %I.type, type [template] -// CHECK:STDOUT: %assoc0.790: %assoc_type.579 = assoc_entity element0, @I.%T [template] +// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template] +// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, @I.%N [template] // CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [template] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] @@ -40,8 +42,6 @@ interface I { // CHECK:STDOUT: %Convert.bound: = bound_method %int_42.20e, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_42.c68: %i32 = int_value 42 [template] -// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template] -// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, @I.%N [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -64,14 +64,16 @@ interface I { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826] +// CHECK:STDOUT: %T: type = assoc_const_decl T [template] +// CHECK:STDOUT: %assoc0: %assoc_type.579 = assoc_entity element0, %T [template = constants.%assoc0.790] // CHECK:STDOUT: %int_32.loc16_27: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc16_27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %int_32.loc16_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc16_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %.loc16_35: %tuple.type.24b = tuple_literal (%i32.loc16_27, %i32.loc16_32) // CHECK:STDOUT: %.loc16_36: type = converted %.loc16_35, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] -// CHECK:STDOUT: %T: type = assoc_const_decl T [template] -// CHECK:STDOUT: %assoc0: %assoc_type.579 = assoc_entity element0, %T [template = constants.%assoc0.790] +// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template] +// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, %N [template = constants.%assoc1] // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42.20e] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_42, %impl.elem0 [template = constants.%Convert.bound] @@ -79,8 +81,6 @@ interface I { // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_42) [template = constants.%int_42.c68] // CHECK:STDOUT: %.loc21_27.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_42.c68] // CHECK:STDOUT: %.loc21_27.2: %i32 = converted %int_42, %.loc21_27.1 [template = constants.%int_42.c68] -// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template] -// CHECK:STDOUT: %assoc1: %assoc_type.4fb = assoc_entity element1, %N [template = constants.%assoc1] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self diff --git a/toolchain/check/testdata/interface/member_lookup.carbon b/toolchain/check/testdata/interface/member_lookup.carbon index 7c7a57d9a8a2..b94131b84a69 100644 --- a/toolchain/check/testdata/interface/member_lookup.carbon +++ b/toolchain/check/testdata/interface/member_lookup.carbon @@ -156,16 +156,16 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: %Self.2: %Interface.type.d32 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %require_complete: = require_complete_type @Interface.%T.loc4_21.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)] // CHECK:STDOUT: %assoc_type: type = assoc_entity_type @Interface.%Interface.type (%Interface.type.d32), @Interface.%T.loc4_21.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.376)] -// CHECK:STDOUT: %assoc0.loc5_12.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)] +// CHECK:STDOUT: %assoc0.loc5_8.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)] // CHECK:STDOUT: // CHECK:STDOUT: interface { // CHECK:STDOUT: %Self.1: @Interface.%Interface.type (%Interface.type.d32) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %X: @Interface.%T.loc4_21.2 (%T) = assoc_const_decl X [template] -// CHECK:STDOUT: %assoc0.loc5_12.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)] +// CHECK:STDOUT: %assoc0.loc5_8.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self.1 -// CHECK:STDOUT: .X = %assoc0.loc5_12.1 +// CHECK:STDOUT: .X = %assoc0.loc5_8.1 // CHECK:STDOUT: witness = (%X) // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -188,7 +188,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: fn[%T.param_patt: type](%I.param_patt: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.d32)) -> @AccessGeneric.%T.loc8_18.2 (%T) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %I.ref: @AccessGeneric.%Interface.type.loc8_43.2 (%Interface.type.d32) = name_ref I, %I.loc8_28.1 [symbolic = %I.loc8_28.2 (constants.%I.a5f)] -// CHECK:STDOUT: %.loc9: @AccessGeneric.%assoc_type (%assoc_type.376) = specific_constant @Interface.%assoc0.loc5_12.1, @Interface(constants.%T) [symbolic = %assoc0 (constants.%assoc0.fa3)] +// CHECK:STDOUT: %.loc9: @AccessGeneric.%assoc_type (%assoc_type.376) = specific_constant @Interface.%assoc0.loc5_8.1, @Interface(constants.%T) [symbolic = %assoc0 (constants.%assoc0.fa3)] // CHECK:STDOUT: %X.ref: @AccessGeneric.%assoc_type (%assoc_type.376) = name_ref X, %.loc9 [symbolic = %assoc0 (constants.%assoc0.fa3)] // CHECK:STDOUT: %I.as_wit.loc9_11.1: = facet_access_witness %I.ref [symbolic = %I.as_wit.loc9_11.2 (constants.%I.as_wit.9f4)] // CHECK:STDOUT: %impl.elem0.loc9_11.1: @AccessGeneric.%T.loc8_18.2 (%T) = impl_witness_access %I.as_wit.loc9_11.1, element0 [symbolic = %impl.elem0.loc9_11.2 (constants.%impl.elem0.68a)] @@ -207,7 +207,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: fn(%I.param_patt: %Interface.type.981) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %I.ref: %Interface.type.981 = name_ref I, %I.loc12_19.1 [symbolic = %I.loc12_19.2 (constants.%I.d08)] -// CHECK:STDOUT: %.loc13: %assoc_type.5f0 = specific_constant @Interface.%assoc0.loc5_12.1, @Interface(constants.%i32) [template = constants.%assoc0.ed2] +// CHECK:STDOUT: %.loc13: %assoc_type.5f0 = specific_constant @Interface.%assoc0.loc5_8.1, @Interface(constants.%i32) [template = constants.%assoc0.ed2] // CHECK:STDOUT: %X.ref: %assoc_type.5f0 = name_ref X, %.loc13 [template = constants.%assoc0.ed2] // CHECK:STDOUT: %I.as_wit.loc13_11.1: = facet_access_witness %I.ref [symbolic = %I.as_wit.loc13_11.2 (constants.%I.as_wit.156)] // CHECK:STDOUT: %impl.elem0.loc13_11.1: %i32 = impl_witness_access %I.as_wit.loc13_11.1, element0 [symbolic = %impl.elem0.loc13_11.2 (constants.%impl.elem0.b00)] @@ -224,7 +224,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: %Self.2 => constants.%Self // CHECK:STDOUT: %require_complete => constants.%require_complete.4ae // CHECK:STDOUT: %assoc_type => constants.%assoc_type.376 -// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.fa3 +// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.fa3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Interface(%T.loc4_21.2) {} @@ -248,7 +248,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: %Self.2 => constants.%Self // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a // CHECK:STDOUT: %assoc_type => constants.%assoc_type.5f0 -// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.ed2 +// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.ed2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @AccessConcrete(constants.%I.d08) { @@ -360,16 +360,16 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: %Self.2: %Interface.type.d32 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %require_complete: = require_complete_type @Interface.%T.loc4_21.2 (%T) [symbolic = %require_complete (constants.%require_complete.4ae)] // CHECK:STDOUT: %assoc_type: type = assoc_entity_type @Interface.%Interface.type (%Interface.type.d32), @Interface.%T.loc4_21.2 (%T) [symbolic = %assoc_type (constants.%assoc_type.376)] -// CHECK:STDOUT: %assoc0.loc5_12.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)] +// CHECK:STDOUT: %assoc0.loc5_8.2: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)] // CHECK:STDOUT: // CHECK:STDOUT: interface { // CHECK:STDOUT: %Self.1: @Interface.%Interface.type (%Interface.type.d32) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %X: @Interface.%T.loc4_21.2 (%T) = assoc_const_decl X [template] -// CHECK:STDOUT: %assoc0.loc5_12.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_12.2 (constants.%assoc0.fa3)] +// CHECK:STDOUT: %assoc0.loc5_8.1: @Interface.%assoc_type (%assoc_type.376) = assoc_entity element0, %X [symbolic = %assoc0.loc5_8.2 (constants.%assoc0.fa3)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self.1 -// CHECK:STDOUT: .X = %assoc0.loc5_12.1 +// CHECK:STDOUT: .X = %assoc0.loc5_8.1 // CHECK:STDOUT: witness = (%X) // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -415,7 +415,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: %Self.2 => constants.%Self // CHECK:STDOUT: %require_complete => constants.%require_complete.4ae // CHECK:STDOUT: %assoc_type => constants.%assoc_type.376 -// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.fa3 +// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.fa3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Interface(%T.loc4_21.2) {} @@ -439,7 +439,7 @@ fn AccessMissingConcrete(I:! Interface(i32)) -> i32 { // CHECK:STDOUT: %Self.2 => constants.%Self // CHECK:STDOUT: %require_complete => constants.%complete_type.f8a // CHECK:STDOUT: %assoc_type => constants.%assoc_type.5f0 -// CHECK:STDOUT: %assoc0.loc5_12.2 => constants.%assoc0.ed2 +// CHECK:STDOUT: %assoc0.loc5_8.2 => constants.%assoc0.ed2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @AccessMissingConcrete(constants.%I.d08) { diff --git a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon index 53c11889925e..bbe951da41ee 100644 --- a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon @@ -56,13 +56,22 @@ fn F(T:! Empty) { // CHECK:STDOUT: %T.patt.loc13_6.2: %Empty.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_6.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %T.as_type: type = facet_access_type %T.loc13_6.2 [symbolic = %T.as_type (constants.%T.as_type)] -// CHECK:STDOUT: %require_complete: = require_complete_type @F.%T.as_type (%T.as_type) [symbolic = %require_complete (constants.%require_complete)] +// CHECK:STDOUT: %T.as_type.loc14_10.2: type = facet_access_type %T.loc13_6.2 [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)] +// CHECK:STDOUT: %require_complete: = require_complete_type @F.%T.as_type.loc14_10.2 (%T.as_type) [symbolic = %require_complete (constants.%require_complete)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: %Empty.type) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref @F.%T.as_type (%T.as_type) = var x -// CHECK:STDOUT: %x: ref @F.%T.as_type (%T.as_type) = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: @F.%T.as_type.loc14_10.2 (%T.as_type) = binding_pattern x +// CHECK:STDOUT: %.loc14_3: @F.%T.as_type.loc14_10.2 (%T.as_type) = var_pattern %x.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.var: ref @F.%T.as_type.loc14_10.2 (%T.as_type) = var x +// CHECK:STDOUT: %.loc14_10.1: type = splice_block %.loc14_10.2 [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)] { +// CHECK:STDOUT: %T.ref: %Empty.type = name_ref T, %T.loc13_6.1 [symbolic = %T.loc13_6.2 (constants.%T)] +// CHECK:STDOUT: %T.as_type.loc14_10.1: type = facet_access_type %T.ref [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)] +// CHECK:STDOUT: %.loc14_10.2: type = converted %T.ref, %T.as_type.loc14_10.1 [symbolic = %T.as_type.loc14_10.2 (constants.%T.as_type)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref @F.%T.as_type.loc14_10.2 (%T.as_type) = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/no_prelude/default_fn.carbon b/toolchain/check/testdata/interface/no_prelude/default_fn.carbon index 556d0729be39..710962050822 100644 --- a/toolchain/check/testdata/interface/no_prelude/default_fn.carbon +++ b/toolchain/check/testdata/interface/no_prelude/default_fn.carbon @@ -85,12 +85,17 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: fn() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc16_7.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %.loc16_19.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc16_19.2: init %C = class_init (), %c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc16_20: init %C = converted %.loc16_19.1, %.loc16_19.2 [template = constants.%C.val] -// CHECK:STDOUT: assign %c.var, %.loc16_20 +// CHECK:STDOUT: %.loc16_7.2: init %C = converted %.loc16_19.1, %.loc16_19.2 [template = constants.%C.val] +// CHECK:STDOUT: assign %c.var, %.loc16_7.2 +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c // CHECK:STDOUT: %I.ref: type = name_ref I, @C.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, @I.%assoc0 [template = constants.%assoc0] diff --git a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon index fd13758d8057..4a3088798620 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_binding.carbon @@ -26,6 +26,8 @@ interface I { // CHECK:STDOUT: interface @I { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = .inst15 +// CHECK:STDOUT: .T = .inst19.loc16_9 +// CHECK:STDOUT: .U = .inst22.loc16_19 // CHECK:STDOUT: witness = invalid // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon index 2e45b27a0801..6a844e29b037 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_not_constant.carbon @@ -41,8 +41,8 @@ alias UseOther = I.other; // CHECK:STDOUT: } // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {} // CHECK:STDOUT: %I.ref.loc24: type = name_ref I, %I.decl [template = constants.%I.type] -// CHECK:STDOUT: %a.ref: = name_ref a, [template = ] -// CHECK:STDOUT: %UseA: = bind_alias UseA, [template = ] +// CHECK:STDOUT: %a.ref: = name_ref a, .inst19.loc20_7 +// CHECK:STDOUT: %UseA: = bind_alias UseA, .inst19.loc20_7 // CHECK:STDOUT: %I.ref.loc27: type = name_ref I, %I.decl [template = constants.%I.type] // CHECK:STDOUT: %other.ref: = name_ref other, [template = ] // CHECK:STDOUT: %UseOther: = bind_alias UseOther, [template = ] @@ -53,6 +53,7 @@ alias UseOther = I.other; // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .a = .inst19.loc20_7 // CHECK:STDOUT: has_error // CHECK:STDOUT: witness = () // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon index b6a222e8fac9..18d698b77cf8 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_assoc_const_template.carbon @@ -26,6 +26,7 @@ interface I { // CHECK:STDOUT: interface @I { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = .inst15 +// CHECK:STDOUT: .T = .inst19.loc16_17 // CHECK:STDOUT: witness = invalid // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon b/toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon new file mode 100644 index 000000000000..65b2ba55e21d --- /dev/null +++ b/toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon @@ -0,0 +1,53 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/fail_incomplete_type.carbon + +class C; + +interface I { + // CHECK:STDERR: fail_incomplete_type.carbon:[[@LINE+7]]:11: error: associated constant has incomplete type `C` [IncompleteTypeInAssociatedDecl] + // CHECK:STDERR: let T:! C; + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_incomplete_type.carbon:[[@LINE-6]]:1: note: class was forward declared here [ClassForwardDeclaredHere] + // CHECK:STDERR: class C; + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: + let T:! C; +} + +// CHECK:STDOUT: --- fail_incomplete_type.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %I.type: type = facet_type <@I> [template] +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} +// CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @I { +// CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %T: = assoc_const_decl T [template] +// CHECK:STDOUT: %assoc0: = assoc_entity element0, %T [template = ] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .T = %assoc0 +// CHECK:STDOUT: witness = (%T) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C; +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_lookup_in_type_type.carbon b/toolchain/check/testdata/interface/no_prelude/fail_lookup_in_type_type.carbon index c77a171db057..8a1056bd7c65 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_lookup_in_type_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_lookup_in_type_type.carbon @@ -36,33 +36,49 @@ let U: (type where .Self impls type).missing = {}; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .T = @__global_init.%T +// CHECK:STDOUT: .T = %T // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: = binding_pattern T +// CHECK:STDOUT: } +// CHECK:STDOUT: %T: = bind_name T, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %T: = bind_name T, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_lookup_type_where.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic] +// CHECK:STDOUT: %type_where: type = facet_type [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .U = @__global_init.%U +// CHECK:STDOUT: .U = %U // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %U.patt: = binding_pattern U +// CHECK:STDOUT: } +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.loc8: type = where_expr %.Self [template = constants.%type_where] { +// CHECK:STDOUT: requirement_impls %.Self.ref, type +// CHECK:STDOUT: } +// CHECK:STDOUT: %missing.ref: = name_ref missing, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %U: = bind_name U, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %U: = bind_name U, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon index 38852fc34569..f96121f1889d 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_member_lookup.carbon @@ -113,10 +113,19 @@ fn G(U:! Different) -> U.(Interface.T); // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type] +// CHECK:STDOUT: %Interface.ref.loc22: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type] // CHECK:STDOUT: %F.ref: %F.assoc_type = name_ref F, @Interface.%assoc0 [template = constants.%assoc0] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: %.loc28_3: = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref = var v -// CHECK:STDOUT: %v: ref = bind_name v, %v.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %Interface.ref.loc28: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type] +// CHECK:STDOUT: %T.ref: %assoc_type = name_ref T, @Interface.%assoc1 [template = constants.%assoc1] +// CHECK:STDOUT: %.loc28_19: type = converted %T.ref, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: = bind_name v, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/import.carbon b/toolchain/check/testdata/interface/no_prelude/import.carbon index 69c56f313bf5..85f4ff7abf49 100644 --- a/toolchain/check/testdata/interface/no_prelude/import.carbon +++ b/toolchain/check/testdata/interface/no_prelude/import.carbon @@ -82,7 +82,15 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%Empty.type] {} {} // CHECK:STDOUT: %Basic.decl: type = interface_decl @Basic [template = constants.%Basic.type] {} {} // CHECK:STDOUT: %ForwardDeclared.decl: type = interface_decl @ForwardDeclared [template = constants.%ForwardDeclared.type] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f_ref.patt: %struct_type.f.2f5 = binding_pattern f_ref +// CHECK:STDOUT: %.loc20_1: %struct_type.f.2f5 = var_pattern %f_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f_ref.var: ref %struct_type.f.2f5 = var f_ref +// CHECK:STDOUT: %.loc20_32: type = splice_block %struct_type.f [template = constants.%struct_type.f.2f5] { +// CHECK:STDOUT: %ForwardDeclared.ref: type = name_ref ForwardDeclared, %ForwardDeclared.decl [template = constants.%ForwardDeclared.type] +// CHECK:STDOUT: %struct_type.f: type = struct_type {.f: %ForwardDeclared.type} [template = constants.%struct_type.f.2f5] +// CHECK:STDOUT: } // CHECK:STDOUT: %f_ref: ref %struct_type.f.2f5 = bind_name f_ref, %f_ref.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -171,12 +179,12 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: %import_ref.2ac: ref %struct_type.f.2f5 = import_ref Main//a, f_ref, loaded // CHECK:STDOUT: %import_ref.cc0 = import_ref Main//a, inst15 [no loc], unloaded // CHECK:STDOUT: %import_ref.37f = import_ref Main//a, inst19 [no loc], unloaded -// CHECK:STDOUT: %import_ref.42e: %assoc_type.6af = import_ref Main//a, loc8_15, loaded [template = constants.%assoc0.1d6] +// CHECK:STDOUT: %import_ref.42e: %assoc_type.6af = import_ref Main//a, loc8_8, loaded [template = constants.%assoc0.1d6] // CHECK:STDOUT: %import_ref.b06: %F.assoc_type.94b = import_ref Main//a, loc9_9, loaded [template = constants.%assoc1.d7b] // CHECK:STDOUT: %import_ref.08d600.1 = import_ref Main//a, T, unloaded // CHECK:STDOUT: %import_ref.eea = import_ref Main//a, F, unloaded // CHECK:STDOUT: %import_ref.52b = import_ref Main//a, inst34 [no loc], unloaded -// CHECK:STDOUT: %import_ref.95f: %assoc_type.3e8 = import_ref Main//a, loc16_15, loaded [template = constants.%assoc0.910] +// CHECK:STDOUT: %import_ref.95f: %assoc_type.3e8 = import_ref Main//a, loc16_8, loaded [template = constants.%assoc0.910] // CHECK:STDOUT: %import_ref.7f1: %F.assoc_type.1e3 = import_ref Main//a, loc17_9, loaded [template = constants.%assoc1.68e] // CHECK:STDOUT: %import_ref.08d600.2 = import_ref Main//a, T, unloaded // CHECK:STDOUT: %import_ref.5d0 = import_ref Main//a, F, unloaded @@ -234,7 +242,15 @@ var f: ForwardDeclared* = &f_ref.f; // CHECK:STDOUT: %ForwardDeclared.ref.loc14: type = name_ref ForwardDeclared, imports.%import_ref.e33 [template = constants.%ForwardDeclared.type] // CHECK:STDOUT: %F.ref.loc14: %F.assoc_type.1e3 = name_ref F, imports.%import_ref.7f1 [template = constants.%assoc1.68e] // CHECK:STDOUT: %UseForwardDeclaredF: %F.assoc_type.1e3 = bind_alias UseForwardDeclaredF, imports.%import_ref.7f1 [template = constants.%assoc1.68e] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %ptr = binding_pattern f +// CHECK:STDOUT: %.loc16_1: %ptr = var_pattern %f.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %f.var: ref %ptr = var f +// CHECK:STDOUT: %.loc16_23: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %ForwardDeclared.ref.loc16: type = name_ref ForwardDeclared, imports.%import_ref.e33 [template = constants.%ForwardDeclared.type] +// CHECK:STDOUT: %ptr: type = ptr_type %ForwardDeclared.type [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %f: ref %ptr = bind_name f, %f.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/todo_define_not_default.carbon b/toolchain/check/testdata/interface/todo_define_not_default.carbon index 2368ca1e144a..00f2eb8e6eec 100644 --- a/toolchain/check/testdata/interface/todo_define_not_default.carbon +++ b/toolchain/check/testdata/interface/todo_define_not_default.carbon @@ -34,10 +34,12 @@ interface I { // CHECK:STDOUT: %G: %G.type = struct_value () [template] // CHECK:STDOUT: %G.assoc_type: type = assoc_entity_type %I.type, %G.type [template] // CHECK:STDOUT: %assoc1: %G.assoc_type = assoc_entity element1, @I.%G.decl [template] -// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] -// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %assoc_type.579: type = assoc_entity_type %I.type, type [template] // CHECK:STDOUT: %assoc2: %assoc_type.579 = assoc_entity element2, @I.%T [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] +// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template] +// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, @I.%N [template] // CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [template] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] @@ -46,8 +48,6 @@ interface I { // CHECK:STDOUT: %Convert.bound: = bound_method %int_42.20e, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_42.c68: %i32 = int_value 42 [template] -// CHECK:STDOUT: %assoc_type.4fb: type = assoc_entity_type %I.type, %i32 [template] -// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, @I.%N [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -98,14 +98,16 @@ interface I { // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %assoc1: %G.assoc_type = assoc_entity element1, %G.decl [template = constants.%assoc1] +// CHECK:STDOUT: %T: type = assoc_const_decl T [template] +// CHECK:STDOUT: %assoc2: %assoc_type.579 = assoc_entity element2, %T [template = constants.%assoc2] // CHECK:STDOUT: %int_32.loc18_19: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc18_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %int_32.loc18_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc18_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %.loc18_27: %tuple.type.24b = tuple_literal (%i32.loc18_19, %i32.loc18_24) // CHECK:STDOUT: %.loc18_28: type = converted %.loc18_27, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] -// CHECK:STDOUT: %T: type = assoc_const_decl T [template] -// CHECK:STDOUT: %assoc2: %assoc_type.579 = assoc_entity element2, %T [template = constants.%assoc2] +// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template] +// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, %N [template = constants.%assoc3] // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [template = constants.%int_42.20e] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_42, %impl.elem0 [template = constants.%Convert.bound] @@ -113,8 +115,6 @@ interface I { // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_42) [template = constants.%int_42.c68] // CHECK:STDOUT: %.loc19_19.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_42.c68] // CHECK:STDOUT: %.loc19_19.2: %i32 = converted %int_42, %.loc19_19.1 [template = constants.%int_42.c68] -// CHECK:STDOUT: %N: %i32 = assoc_const_decl N [template] -// CHECK:STDOUT: %assoc3: %assoc_type.4fb = assoc_entity element3, %N [template = constants.%assoc3] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self diff --git a/toolchain/check/testdata/ir/duplicate_name_same_line.carbon b/toolchain/check/testdata/ir/duplicate_name_same_line.carbon index a1410ddb0fb8..4d91134e3adc 100644 --- a/toolchain/check/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/check/testdata/ir/duplicate_name_same_line.carbon @@ -56,15 +56,23 @@ fn A() { if (true) { var n: i32 = 1; } if (true) { var n: i32 = 2; } } // CHECK:STDOUT: if %true.loc11_14 br !if.then.loc11_18 else br !if.else.loc11_18 // CHECK:STDOUT: // CHECK:STDOUT: !if.then.loc11_18: -// CHECK:STDOUT: %n.var.loc11_26: ref %i32 = var n -// CHECK:STDOUT: %n.loc11_26: ref %i32 = bind_name n, %n.var.loc11_26 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt.loc11_26: %i32 = binding_pattern n +// CHECK:STDOUT: %.loc11_22.1: %i32 = var_pattern %n.patt.loc11_26 +// CHECK:STDOUT: } +// CHECK:STDOUT: %n.var.loc11_22: ref %i32 = var n // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc11_36: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11_36: = bound_method %int_1, %impl.elem0.loc11_36 [template = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %Convert.specific_fn.loc11_36: = specific_function %Convert.bound.loc11_36, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc11_36: init %i32 = call %Convert.specific_fn.loc11_36(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_36: init %i32 = converted %int_1, %int.convert_checked.loc11_36 [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %n.var.loc11_26, %.loc11_36 +// CHECK:STDOUT: %impl.elem0.loc11_22: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc11_22: = bound_method %int_1, %impl.elem0.loc11_22 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc11_22: = specific_function %Convert.bound.loc11_22, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc11_22: init %i32 = call %Convert.specific_fn.loc11_22(%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_22.2: init %i32 = converted %int_1, %int.convert_checked.loc11_22 [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %n.var.loc11_22, %.loc11_22.2 +// CHECK:STDOUT: %.loc11_29: type = splice_block %i32.loc11_29 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc11_29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n.loc11_26: ref %i32 = bind_name n, %n.var.loc11_22 // CHECK:STDOUT: br !if.else.loc11_18 // CHECK:STDOUT: // CHECK:STDOUT: !if.else.loc11_18: @@ -72,15 +80,23 @@ fn A() { if (true) { var n: i32 = 1; } if (true) { var n: i32 = 2; } } // CHECK:STDOUT: if %true.loc11_44 br !if.then.loc11_48 else br !if.else.loc11_48 // CHECK:STDOUT: // CHECK:STDOUT: !if.then.loc11_48: -// CHECK:STDOUT: %n.var.loc11_56: ref %i32 = var n -// CHECK:STDOUT: %n.loc11_56: ref %i32 = bind_name n, %n.var.loc11_56 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt.loc11_56: %i32 = binding_pattern n +// CHECK:STDOUT: %.loc11_52.1: %i32 = var_pattern %n.patt.loc11_56 +// CHECK:STDOUT: } +// CHECK:STDOUT: %n.var.loc11_52: ref %i32 = var n // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %impl.elem0.loc11_66: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11_66: = bound_method %int_2, %impl.elem0.loc11_66 [template = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %Convert.specific_fn.loc11_66: = specific_function %Convert.bound.loc11_66, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc11_66: init %i32 = call %Convert.specific_fn.loc11_66(%int_2) [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc11_66: init %i32 = converted %int_2, %int.convert_checked.loc11_66 [template = constants.%int_2.ef8] -// CHECK:STDOUT: assign %n.var.loc11_56, %.loc11_66 +// CHECK:STDOUT: %impl.elem0.loc11_52: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc11_52: = bound_method %int_2, %impl.elem0.loc11_52 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc11_52: = specific_function %Convert.bound.loc11_52, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc11_52: init %i32 = call %Convert.specific_fn.loc11_52(%int_2) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc11_52.2: init %i32 = converted %int_2, %int.convert_checked.loc11_52 [template = constants.%int_2.ef8] +// CHECK:STDOUT: assign %n.var.loc11_52, %.loc11_52.2 +// CHECK:STDOUT: %.loc11_59: type = splice_block %i32.loc11_59 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc11_59: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_59: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n.loc11_56: ref %i32 = bind_name n, %n.var.loc11_52 // CHECK:STDOUT: br !if.else.loc11_48 // CHECK:STDOUT: // CHECK:STDOUT: !if.else.loc11_48: diff --git a/toolchain/check/testdata/let/compile_time_bindings.carbon b/toolchain/check/testdata/let/compile_time_bindings.carbon index 67a6a45af98d..db90c4062ed6 100644 --- a/toolchain/check/testdata/let/compile_time_bindings.carbon +++ b/toolchain/check/testdata/let/compile_time_bindings.carbon @@ -201,10 +201,17 @@ impl i32 as Empty { // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param0 // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc10_17: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10_17.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_12.1: type = splice_block %.loc10_12.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_12.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_12.3: type = converted %.loc10_12.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc10_18: %empty_tuple.type = converted %.loc10_17, %empty_tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc10_18 +// CHECK:STDOUT: %.loc10_17.2: %empty_tuple.type = converted %.loc10_17.1, %empty_tuple [template = constants.%empty_tuple] +// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc10_17.2 // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -244,10 +251,17 @@ impl i32 as Empty { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc9_17: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9_17.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_12.1: type = splice_block %.loc9_12.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc9_12.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_12.3: type = converted %.loc9_12.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc9_18: %empty_tuple.type = converted %.loc9_17, %empty_tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc9_18 +// CHECK:STDOUT: %.loc9_17.2: %empty_tuple.type = converted %.loc9_17.1, %empty_tuple [template = constants.%empty_tuple] +// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc9_17.2 // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param0 @@ -283,8 +297,9 @@ impl i32 as Empty { // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template] // CHECK:STDOUT: %tuple.type.bcd: type = tuple_type (%empty_tuple.type, %empty_tuple.type) [template] -// CHECK:STDOUT: %tuple.d8f: %tuple.type.bcd = tuple_value (%empty_tuple, %empty_tuple) [template] // CHECK:STDOUT: %c: %tuple.type.bcd = bind_symbolic_name c, 1 [symbolic] +// CHECK:STDOUT: %c.patt: %tuple.type.bcd = symbolic_binding_pattern c, 1 [symbolic] +// CHECK:STDOUT: %tuple.d8f: %tuple.type.bcd = tuple_value (%empty_tuple, %empty_tuple) [template] // CHECK:STDOUT: %tuple.elem0.af8: %empty_tuple.type = tuple_access %b, element0 [symbolic] // CHECK:STDOUT: %tuple.f41: %tuple.type.9fb = tuple_value (%empty_tuple) [template] // CHECK:STDOUT: %tuple.elem0.eaf: %empty_tuple.type = tuple_access %c, element0 [symbolic] @@ -308,10 +323,17 @@ impl i32 as Empty { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc9_17: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc9_17.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_12.1: type = splice_block %.loc9_12.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc9_12.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_12.3: type = converted %.loc9_12.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %empty_tuple.loc9: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc9_18: %empty_tuple.type = converted %.loc9_17, %empty_tuple.loc9 [template = constants.%empty_tuple] -// CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc9_18 +// CHECK:STDOUT: %.loc9_17.2: %empty_tuple.type = converted %.loc9_17.1, %empty_tuple.loc9 [template = constants.%empty_tuple] +// CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc9_17.2 // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %b.patt.loc10_8.2: %tuple.type.9fb = symbolic_binding_pattern b, 0 [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)] // CHECK:STDOUT: %b.param_patt: %tuple.type.9fb = value_param_pattern %b.patt.loc10_8.2, runtime_param [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)] @@ -325,10 +347,23 @@ impl i32 as Empty { // CHECK:STDOUT: } // CHECK:STDOUT: %b.loc10_8.2: %tuple.type.9fb = bind_symbolic_name b, 0, %b.param [symbolic = %b.loc10_8.1 (constants.%b)] // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %tuple.type.2d5 = binding_pattern d +// CHECK:STDOUT: } // CHECK:STDOUT: %.loc22_28: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc22_32: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc22_36: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc22_37.1: %tuple.type.2d5 = tuple_literal (%.loc22_28, %.loc22_32, %.loc22_36) +// CHECK:STDOUT: %.loc22_22.1: type = splice_block %.loc22_22.6 [template = constants.%tuple.type.2d5] { +// CHECK:STDOUT: %.loc22_13: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc22_17: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc22_21: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc22_22.2: %tuple.type.2d5 = tuple_literal (%.loc22_13, %.loc22_17, %.loc22_21) +// CHECK:STDOUT: %.loc22_22.3: type = converted %.loc22_13, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc22_22.4: type = converted %.loc22_17, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc22_22.5: type = converted %.loc22_21, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc22_22.6: type = converted %.loc22_22.2, constants.%tuple.type.2d5 [template = constants.%tuple.type.2d5] +// CHECK:STDOUT: } // CHECK:STDOUT: %empty_tuple.loc22_28: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc22_37.2: %empty_tuple.type = converted %.loc22_28, %empty_tuple.loc22_28 [template = constants.%empty_tuple] // CHECK:STDOUT: %empty_tuple.loc22_32: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] @@ -336,8 +371,8 @@ impl i32 as Empty { // CHECK:STDOUT: %empty_tuple.loc22_36: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc22_37.4: %empty_tuple.type = converted %.loc22_36, %empty_tuple.loc22_36 [template = constants.%empty_tuple] // CHECK:STDOUT: %tuple: %tuple.type.2d5 = tuple_value (%.loc22_37.2, %.loc22_37.3, %.loc22_37.4) [template = constants.%tuple.7e4] -// CHECK:STDOUT: %.loc22_38: %tuple.type.2d5 = converted %.loc22_37.1, %tuple [template = constants.%tuple.7e4] -// CHECK:STDOUT: %d: %tuple.type.2d5 = bind_name d, %.loc22_38 +// CHECK:STDOUT: %.loc22_37.5: %tuple.type.2d5 = converted %.loc22_37.1, %tuple [template = constants.%tuple.7e4] +// CHECK:STDOUT: %d: %tuple.type.2d5 = bind_name d, %.loc22_37.5 // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -348,40 +383,73 @@ impl i32 as Empty { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %c.loc11_9.2: %tuple.type.bcd = bind_symbolic_name c, 1 [symbolic = %c.loc11_9.2 (constants.%c)] +// CHECK:STDOUT: %c.patt.loc11_9.2: %tuple.type.bcd = symbolic_binding_pattern c, 1 [symbolic = %c.patt.loc11_9.2 (constants.%c.patt)] // CHECK:STDOUT: %tuple.elem0.loc14_21.3: %empty_tuple.type = tuple_access %b.loc10_8.1, element0 [symbolic = %tuple.elem0.loc14_21.3 (constants.%tuple.elem0.af8)] // CHECK:STDOUT: %tuple.elem0.loc15_24.3: %empty_tuple.type = tuple_access %c.loc11_9.2, element0 [symbolic = %tuple.elem0.loc15_24.3 (constants.%tuple.elem0.eaf)] // CHECK:STDOUT: %tuple.elem1.loc15_24.3: %empty_tuple.type = tuple_access %c.loc11_9.2, element1 [symbolic = %tuple.elem1.loc15_24.3 (constants.%tuple.elem1)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%b.param_patt: %tuple.type.9fb) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt.loc11_9.1: %tuple.type.bcd = symbolic_binding_pattern c, 1 [symbolic = %c.patt.loc11_9.2 (constants.%c.patt)] +// CHECK:STDOUT: } // CHECK:STDOUT: %.loc11_26: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc11_30: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc11_31.1: %tuple.type.bcd = tuple_literal (%.loc11_26, %.loc11_30) +// CHECK:STDOUT: %.loc11_20.1: type = splice_block %.loc11_20.5 [template = constants.%tuple.type.bcd] { +// CHECK:STDOUT: %.loc11_15: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_19: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_20.2: %tuple.type.bcd = tuple_literal (%.loc11_15, %.loc11_19) +// CHECK:STDOUT: %.loc11_20.3: type = converted %.loc11_15, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc11_20.4: type = converted %.loc11_19, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc11_20.5: type = converted %.loc11_20.2, constants.%tuple.type.bcd [template = constants.%tuple.type.bcd] +// CHECK:STDOUT: } // CHECK:STDOUT: %empty_tuple.loc11_26: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_31.2: %empty_tuple.type = converted %.loc11_26, %empty_tuple.loc11_26 [template = constants.%empty_tuple] // CHECK:STDOUT: %empty_tuple.loc11_30: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_31.3: %empty_tuple.type = converted %.loc11_30, %empty_tuple.loc11_30 [template = constants.%empty_tuple] // CHECK:STDOUT: %tuple: %tuple.type.bcd = tuple_value (%.loc11_31.2, %.loc11_31.3) [template = constants.%tuple.d8f] -// CHECK:STDOUT: %.loc11_32: %tuple.type.bcd = converted %.loc11_31.1, %tuple [template = constants.%tuple.d8f] -// CHECK:STDOUT: %c.loc11_9.1: %tuple.type.bcd = bind_symbolic_name c, 1, %.loc11_32 [symbolic = %c.loc11_9.2 (constants.%c)] +// CHECK:STDOUT: %.loc11_31.4: %tuple.type.bcd = converted %.loc11_31.1, %tuple [template = constants.%tuple.d8f] +// CHECK:STDOUT: %c.loc11_9.1: %tuple.type.bcd = bind_symbolic_name c, 1, %.loc11_31.4 [symbolic = %c.loc11_9.2 (constants.%c)] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a1.patt: %empty_tuple.type = binding_pattern a1 +// CHECK:STDOUT: %.loc13_5.1: %empty_tuple.type = var_pattern %a1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a1.var: ref %empty_tuple.type = var a1 -// CHECK:STDOUT: %a1: ref %empty_tuple.type = bind_name a1, %a1.var // CHECK:STDOUT: %a.ref: %empty_tuple.type = name_ref a, @C.%a // CHECK:STDOUT: %.loc13_18: init %empty_tuple.type = tuple_init () to %a1.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_19: init %empty_tuple.type = converted %a.ref, %.loc13_18 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %a1.var, %.loc13_19 +// CHECK:STDOUT: %.loc13_5.2: init %empty_tuple.type = converted %a.ref, %.loc13_18 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %a1.var, %.loc13_5.2 +// CHECK:STDOUT: %.loc13_14.1: type = splice_block %.loc13_14.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc13_14.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_14.3: type = converted %.loc13_14.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a1: ref %empty_tuple.type = bind_name a1, %a1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b1.patt: %tuple.type.9fb = binding_pattern b1 +// CHECK:STDOUT: %.loc14_5.1: %tuple.type.9fb = var_pattern %b1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b1.var: ref %tuple.type.9fb = var b1 -// CHECK:STDOUT: %b1: ref %tuple.type.9fb = bind_name b1, %b1.var // CHECK:STDOUT: %b.ref: %tuple.type.9fb = name_ref b, %b.loc10_8.2 [symbolic = %b.loc10_8.1 (constants.%b)] // CHECK:STDOUT: %tuple.elem0.loc14_21.1: %empty_tuple.type = tuple_access %b.ref, element0 [symbolic = %tuple.elem0.loc14_21.3 (constants.%tuple.elem0.af8)] // CHECK:STDOUT: %tuple.elem0.loc14_21.2: ref %empty_tuple.type = tuple_access %b1.var, element0 // CHECK:STDOUT: %.loc14_21.1: init %empty_tuple.type = tuple_init () to %tuple.elem0.loc14_21.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc14_21.2: init %empty_tuple.type = converted %tuple.elem0.loc14_21.1, %.loc14_21.1 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc14_21.3: init %tuple.type.9fb = tuple_init (%.loc14_21.2) to %b1.var [template = constants.%tuple.f41] -// CHECK:STDOUT: %.loc14_22: init %tuple.type.9fb = converted %b.ref, %.loc14_21.3 [template = constants.%tuple.f41] -// CHECK:STDOUT: assign %b1.var, %.loc14_22 +// CHECK:STDOUT: %.loc14_5.2: init %tuple.type.9fb = converted %b.ref, %.loc14_21.3 [template = constants.%tuple.f41] +// CHECK:STDOUT: assign %b1.var, %.loc14_5.2 +// CHECK:STDOUT: %.loc14_17.1: type = splice_block %.loc14_17.4 [template = constants.%tuple.type.9fb] { +// CHECK:STDOUT: %.loc14_15: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc14_17.2: %tuple.type.9fb = tuple_literal (%.loc14_15) +// CHECK:STDOUT: %.loc14_17.3: type = converted %.loc14_15, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc14_17.4: type = converted %.loc14_17.2, constants.%tuple.type.9fb [template = constants.%tuple.type.9fb] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b1: ref %tuple.type.9fb = bind_name b1, %b1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c1.patt: %tuple.type.bcd = binding_pattern c1 +// CHECK:STDOUT: %.loc15_5.1: %tuple.type.bcd = var_pattern %c1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c1.var: ref %tuple.type.bcd = var c1 -// CHECK:STDOUT: %c1: ref %tuple.type.bcd = bind_name c1, %c1.var // CHECK:STDOUT: %c.ref: %tuple.type.bcd = name_ref c, %c.loc11_9.1 [symbolic = %c.loc11_9.2 (constants.%c)] // CHECK:STDOUT: %tuple.elem0.loc15_24.1: %empty_tuple.type = tuple_access %c.ref, element0 [symbolic = %tuple.elem0.loc15_24.3 (constants.%tuple.elem0.eaf)] // CHECK:STDOUT: %tuple.elem0.loc15_24.2: ref %empty_tuple.type = tuple_access %c1.var, element0 @@ -392,10 +460,22 @@ impl i32 as Empty { // CHECK:STDOUT: %.loc15_24.3: init %empty_tuple.type = tuple_init () to %tuple.elem1.loc15_24.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc15_24.4: init %empty_tuple.type = converted %tuple.elem1.loc15_24.1, %.loc15_24.3 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc15_24.5: init %tuple.type.bcd = tuple_init (%.loc15_24.2, %.loc15_24.4) to %c1.var [template = constants.%tuple.d8f] -// CHECK:STDOUT: %.loc15_25: init %tuple.type.bcd = converted %c.ref, %.loc15_24.5 [template = constants.%tuple.d8f] -// CHECK:STDOUT: assign %c1.var, %.loc15_25 +// CHECK:STDOUT: %.loc15_5.2: init %tuple.type.bcd = converted %c.ref, %.loc15_24.5 [template = constants.%tuple.d8f] +// CHECK:STDOUT: assign %c1.var, %.loc15_5.2 +// CHECK:STDOUT: %.loc15_20.1: type = splice_block %.loc15_20.5 [template = constants.%tuple.type.bcd] { +// CHECK:STDOUT: %.loc15_15: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_19: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_20.2: %tuple.type.bcd = tuple_literal (%.loc15_15, %.loc15_19) +// CHECK:STDOUT: %.loc15_20.3: type = converted %.loc15_15, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc15_20.4: type = converted %.loc15_19, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc15_20.5: type = converted %.loc15_20.2, constants.%tuple.type.bcd [template = constants.%tuple.type.bcd] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c1: ref %tuple.type.bcd = bind_name c1, %c1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d1.patt: %tuple.type.2d5 = binding_pattern d1 +// CHECK:STDOUT: %.loc16_5.1: %tuple.type.2d5 = var_pattern %d1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d1.var: ref %tuple.type.2d5 = var d1 -// CHECK:STDOUT: %d1: ref %tuple.type.2d5 = bind_name d1, %d1.var // CHECK:STDOUT: %d.ref: %tuple.type.2d5 = name_ref d, @C.%d // CHECK:STDOUT: %tuple.elem0.loc16_28.1: %empty_tuple.type = tuple_access %d.ref, element0 // CHECK:STDOUT: %tuple.elem0.loc16_28.2: ref %empty_tuple.type = tuple_access %d1.var, element0 @@ -410,8 +490,19 @@ impl i32 as Empty { // CHECK:STDOUT: %.loc16_28.5: init %empty_tuple.type = tuple_init () to %tuple.elem2.loc16_28.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc16_28.6: init %empty_tuple.type = converted %tuple.elem2.loc16_28.1, %.loc16_28.5 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc16_28.7: init %tuple.type.2d5 = tuple_init (%.loc16_28.2, %.loc16_28.4, %.loc16_28.6) to %d1.var [template = constants.%tuple.7e4] -// CHECK:STDOUT: %.loc16_29: init %tuple.type.2d5 = converted %d.ref, %.loc16_28.7 [template = constants.%tuple.7e4] -// CHECK:STDOUT: assign %d1.var, %.loc16_29 +// CHECK:STDOUT: %.loc16_5.2: init %tuple.type.2d5 = converted %d.ref, %.loc16_28.7 [template = constants.%tuple.7e4] +// CHECK:STDOUT: assign %d1.var, %.loc16_5.2 +// CHECK:STDOUT: %.loc16_24.1: type = splice_block %.loc16_24.6 [template = constants.%tuple.type.2d5] { +// CHECK:STDOUT: %.loc16_15: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_19: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_23: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_24.2: %tuple.type.2d5 = tuple_literal (%.loc16_15, %.loc16_19, %.loc16_23) +// CHECK:STDOUT: %.loc16_24.3: type = converted %.loc16_15, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc16_24.4: type = converted %.loc16_19, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc16_24.5: type = converted %.loc16_23, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc16_24.6: type = converted %.loc16_24.2, constants.%tuple.type.2d5 [template = constants.%tuple.type.2d5] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d1: ref %tuple.type.2d5 = bind_name d1, %d1.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -430,7 +521,6 @@ impl i32 as Empty { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template] -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -459,17 +549,17 @@ impl i32 as Empty { // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param0 // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: } // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %empty_tuple.type { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.ref: %empty_tuple.type = name_ref x, @C.%x -// CHECK:STDOUT: %tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc5_26: %empty_tuple.type = converted %x.ref, %tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: return %.loc5_26 +// CHECK:STDOUT: %x.ref: %empty_tuple.type = name_ref x, .inst29.loc14_7 +// CHECK:STDOUT: return %x.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- use_in_function.carbon @@ -479,6 +569,8 @@ impl i32 as Empty { // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0 [symbolic] +// CHECK:STDOUT: %Zero.patt: %i32 = symbolic_binding_pattern Zero, 0 [symbolic] // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] @@ -487,7 +579,6 @@ impl i32 as Empty { // CHECK:STDOUT: %Convert.bound: = bound_method %int_0.5c6, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template] -// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -509,8 +600,8 @@ impl i32 as Empty { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -518,14 +609,21 @@ impl i32 as Empty { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %Zero.patt: %i32 = symbolic_binding_pattern Zero, 0 [symbolic = constants.%Zero.patt] +// CHECK:STDOUT: } // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc5_14: type = splice_block %i32.loc5 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc5_21.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc5_21.2: %i32 = converted %int_0, %.loc5_21.1 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0, %.loc5_21.2 [symbolic = constants.%Zero] +// CHECK:STDOUT: %.loc5_20.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc5_20.2: %i32 = converted %int_0, %.loc5_20.1 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0, %.loc5_20.2 [symbolic = constants.%Zero] // CHECK:STDOUT: %Zero.ref: %i32 = name_ref Zero, %Zero [symbolic = constants.%Zero] // CHECK:STDOUT: return %Zero.ref // CHECK:STDOUT: } @@ -538,6 +636,8 @@ impl i32 as Empty { // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %true: bool = bool_literal true [template] +// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0 [symbolic] +// CHECK:STDOUT: %Zero.patt: %i32 = symbolic_binding_pattern Zero, 0 [symbolic] // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] // CHECK:STDOUT: %impl_witness.d39: = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template] @@ -546,7 +646,6 @@ impl i32 as Empty { // CHECK:STDOUT: %Convert.bound.d04: = bound_method %int_0.5c6, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn.d62: = specific_function %Convert.bound.d04, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template] -// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0 [symbolic] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %Convert.bound.ab5: = bound_method %int_1.5b8, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn.70c: = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template] @@ -572,8 +671,8 @@ impl i32 as Empty { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -585,14 +684,21 @@ impl i32 as Empty { // CHECK:STDOUT: if %true br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %Zero.patt: %i32 = symbolic_binding_pattern Zero, 0 [symbolic = constants.%Zero.patt] +// CHECK:STDOUT: } // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc6_16: type = splice_block %i32.loc6 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc6: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc6: = bound_method %int_0, %impl.elem0.loc6 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc6: = specific_function %Convert.bound.loc6, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc6: init %i32 = call %Convert.specific_fn.loc6(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_23.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc6_23.2: %i32 = converted %int_0, %.loc6_23.1 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0, %.loc6_23.2 [symbolic = constants.%Zero] +// CHECK:STDOUT: %.loc6_22.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc6_22.2: %i32 = converted %int_0, %.loc6_22.1 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0, %.loc6_22.2 [symbolic = constants.%Zero] // CHECK:STDOUT: %Zero.ref: %i32 = name_ref Zero, %Zero [symbolic = constants.%Zero] // CHECK:STDOUT: return %Zero.ref // CHECK:STDOUT: @@ -612,10 +718,10 @@ impl i32 as Empty { // CHECK:STDOUT: constants { // CHECK:STDOUT: %I.type: type = facet_type <@I> [template] // CHECK:STDOUT: %Self.826: %I.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template] // CHECK:STDOUT: %assoc0.790: %assoc_type = assoc_entity element0, @I.%T [template] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %I.type, %F.type [template] @@ -642,10 +748,10 @@ impl i32 as Empty { // CHECK:STDOUT: // CHECK:STDOUT: interface @I { // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.826] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %T: type = assoc_const_decl T [template] // CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0.790] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %return.patt: = return_slot_pattern // CHECK:STDOUT: %return.param_patt: = out_param_pattern %return.patt, runtime_param0 @@ -701,6 +807,9 @@ impl i32 as Empty { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @I { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = binding_pattern T +// CHECK:STDOUT: } // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %T: type = bind_name T, %i32 @@ -738,15 +847,19 @@ impl i32 as Empty { // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .T = @__global_init.%T +// CHECK:STDOUT: .T = %T // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = binding_pattern T +// CHECK:STDOUT: } +// CHECK:STDOUT: %T: type = bind_name T, @__global_init.%i32 // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %return.patt: = return_slot_pattern // CHECK:STDOUT: %return.param_patt: = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %T.ref: type = name_ref T, @__global_init.%T +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T // CHECK:STDOUT: %return.param: ref = out_param runtime_param0 // CHECK:STDOUT: %return: ref = return_slot %return.param // CHECK:STDOUT: } @@ -758,7 +871,6 @@ impl i32 as Empty { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] -// CHECK:STDOUT: %T: type = bind_name T, %i32 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -797,8 +909,8 @@ impl i32 as Empty { // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%Empty.type] {} {} // CHECK:STDOUT: impl_decl @impl.1 [template] {} { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, file.%Empty.decl [template = constants.%Empty.type] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness () [template = constants.%impl_witness.1bc] @@ -812,15 +924,22 @@ impl i32 as Empty { // CHECK:STDOUT: witness = () // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl.1: %i32 as %Empty.ref { +// CHECK:STDOUT: impl @impl.1: %i32.loc6 as %Empty.ref { +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %Zero.patt: %i32 = binding_pattern Zero +// CHECK:STDOUT: } // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] +// CHECK:STDOUT: %.loc11_14: type = splice_block %i32.loc11 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc11_21.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc11_21.2: %i32 = converted %int_0, %.loc11_21.1 [template = constants.%int_0.6a9] -// CHECK:STDOUT: %Zero: %i32 = bind_name Zero, %.loc11_21.2 +// CHECK:STDOUT: %.loc11_20.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc11_20.2: %i32 = converted %int_0, %.loc11_20.1 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %Zero: %i32 = bind_name Zero, %.loc11_20.2 // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Zero = %Zero diff --git a/toolchain/check/testdata/let/convert.carbon b/toolchain/check/testdata/let/convert.carbon index 647f64b1b93d..84978d52424a 100644 --- a/toolchain/check/testdata/let/convert.carbon +++ b/toolchain/check/testdata/let/convert.carbon @@ -22,6 +22,7 @@ fn F() -> i32 { // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [template] // CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] @@ -62,8 +63,8 @@ fn F() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -71,8 +72,11 @@ fn F() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %tuple.type.189 = binding_pattern v +// CHECK:STDOUT: %.loc12_3.1: %tuple.type.189 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %tuple.type.189 = var v -// CHECK:STDOUT: %v: ref %tuple.type.189 = bind_name v, %v.var // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] @@ -82,8 +86,8 @@ fn F() -> i32 { // CHECK:STDOUT: %Convert.specific_fn.loc12_36.1: = specific_function %Convert.bound.loc12_36.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc12_36.1: init %i32 = call %Convert.specific_fn.loc12_36.1(%int_1.loc12) [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc12_36.2: init %i32 = converted %int_1.loc12, %int.convert_checked.loc12_36.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %tuple.elem0.loc12: ref %i32 = tuple_access %v.var, element0 -// CHECK:STDOUT: %.loc12_36.3: init %i32 = initialize_from %.loc12_36.2 to %tuple.elem0.loc12 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %v.var, element0 +// CHECK:STDOUT: %.loc12_36.3: init %i32 = initialize_from %.loc12_36.2 to %tuple.elem0 [template = constants.%int_1.5d2] // CHECK:STDOUT: %impl.elem0.loc12_36.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc12_36.2: = bound_method %int_2, %impl.elem0.loc12_36.2 [template = constants.%Convert.bound.ef9] // CHECK:STDOUT: %Convert.specific_fn.loc12_36.2: = specific_function %Convert.bound.loc12_36.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] @@ -96,24 +100,41 @@ fn F() -> i32 { // CHECK:STDOUT: %Convert.specific_fn.loc12_36.3: = specific_function %Convert.bound.loc12_36.3, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] // CHECK:STDOUT: %int.convert_checked.loc12_36.3: init %i32 = call %Convert.specific_fn.loc12_36.3(%int_3) [template = constants.%int_3.822] // CHECK:STDOUT: %.loc12_36.6: init %i32 = converted %int_3, %int.convert_checked.loc12_36.3 [template = constants.%int_3.822] -// CHECK:STDOUT: %tuple.elem2.loc12: ref %i32 = tuple_access %v.var, element2 -// CHECK:STDOUT: %.loc12_36.7: init %i32 = initialize_from %.loc12_36.6 to %tuple.elem2.loc12 [template = constants.%int_3.822] +// CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %v.var, element2 +// CHECK:STDOUT: %.loc12_36.7: init %i32 = initialize_from %.loc12_36.6 to %tuple.elem2 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc12_36.8: init %tuple.type.189 = tuple_init (%.loc12_36.3, %.loc12_36.5, %.loc12_36.7) to %v.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc12_37: init %tuple.type.189 = converted %.loc12_36.1, %.loc12_36.8 [template = constants.%tuple] -// CHECK:STDOUT: assign %v.var, %.loc12_37 +// CHECK:STDOUT: %.loc12_3.2: init %tuple.type.189 = converted %.loc12_36.1, %.loc12_36.8 [template = constants.%tuple] +// CHECK:STDOUT: assign %v.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_24.1: type = splice_block %.loc12_24.3 [template = constants.%tuple.type.189] { +// CHECK:STDOUT: %int_32.loc12_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc12_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc12_21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_24.2: %tuple.type.ff9 = tuple_literal (%i32.loc12_11, %i32.loc12_16, %i32.loc12_21) +// CHECK:STDOUT: %.loc12_24.3: type = converted %.loc12_24.2, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %tuple.type.189 = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %tuple.type.189 = binding_pattern w +// CHECK:STDOUT: } // CHECK:STDOUT: %v.ref: ref %tuple.type.189 = name_ref v, %v -// CHECK:STDOUT: %tuple.elem0.loc14: ref %i32 = tuple_access %v.ref, element0 -// CHECK:STDOUT: %.loc14_28.1: %i32 = bind_value %tuple.elem0.loc14 -// CHECK:STDOUT: %tuple.elem1.loc14: ref %i32 = tuple_access %v.ref, element1 -// CHECK:STDOUT: %.loc14_28.2: %i32 = bind_value %tuple.elem1.loc14 -// CHECK:STDOUT: %tuple.elem2.loc14: ref %i32 = tuple_access %v.ref, element2 -// CHECK:STDOUT: %.loc14_28.3: %i32 = bind_value %tuple.elem2.loc14 -// CHECK:STDOUT: %tuple: %tuple.type.189 = tuple_value (%.loc14_28.1, %.loc14_28.2, %.loc14_28.3) -// CHECK:STDOUT: %.loc14_29: %tuple.type.189 = converted %v.ref, %tuple -// CHECK:STDOUT: %w: %tuple.type.189 = bind_name w, %.loc14_29 -// CHECK:STDOUT: %w.ref: %tuple.type.189 = name_ref w, %w +// CHECK:STDOUT: %.loc14_24.1: type = splice_block %.loc14_24.3 [template = constants.%tuple.type.189] { +// CHECK:STDOUT: %int_32.loc14_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_24.2: %tuple.type.ff9 = tuple_literal (%i32.loc14_11, %i32.loc14_16, %i32.loc14_21) +// CHECK:STDOUT: %.loc14_24.3: type = converted %.loc14_24.2, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: ref %tuple.type.189 = bind_name w, %v.ref +// CHECK:STDOUT: %w.ref: ref %tuple.type.189 = name_ref w, %w // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %tuple.elem1.loc15: %i32 = tuple_access %w.ref, element1 -// CHECK:STDOUT: return %tuple.elem1.loc15 +// CHECK:STDOUT: %tuple.elem1.loc15: ref %i32 = tuple_access %w.ref, element1 +// CHECK:STDOUT: %.loc15: %i32 = bind_value %tuple.elem1.loc15 +// CHECK:STDOUT: return %.loc15 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_duplicate_decl.carbon b/toolchain/check/testdata/let/fail_duplicate_decl.carbon index f0d4b03ea8c1..b3c7d3c4b577 100644 --- a/toolchain/check/testdata/let/fail_duplicate_decl.carbon +++ b/toolchain/check/testdata/let/fail_duplicate_decl.carbon @@ -61,22 +61,36 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt.loc12: %i32 = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc12: = bound_method %int_1, %impl.elem0.loc12 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc12: = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc12_17.1: %i32 = value_of_initializer %int.convert_checked.loc12 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc12_17.2: %i32 = converted %int_1, %.loc12_17.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %a.loc12: %i32 = bind_name a, %.loc12_17.2 +// CHECK:STDOUT: %.loc12_16.1: %i32 = value_of_initializer %int.convert_checked.loc12 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc12_16.2: %i32 = converted %int_1, %.loc12_16.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %a.loc12: %i32 = bind_name a, %.loc12_16.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt.loc20: %i32 = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc20_10: type = splice_block %i32.loc20 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0.loc20: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc20: = bound_method %int_2, %impl.elem0.loc20 [template = constants.%Convert.bound.ef9] // CHECK:STDOUT: %Convert.specific_fn.loc20: = specific_function %Convert.bound.loc20, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] // CHECK:STDOUT: %int.convert_checked.loc20: init %i32 = call %Convert.specific_fn.loc20(%int_2) [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc20_17.1: %i32 = value_of_initializer %int.convert_checked.loc20 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc20_17.2: %i32 = converted %int_2, %.loc20_17.1 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %a.loc20: %i32 = bind_name a, %.loc20_17.2 +// CHECK:STDOUT: %.loc20_16.1: %i32 = value_of_initializer %int.convert_checked.loc20 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc20_16.2: %i32 = converted %int_2, %.loc20_16.1 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %a.loc20: %i32 = bind_name a, %.loc20_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_generic.carbon b/toolchain/check/testdata/let/fail_generic.carbon index d0bb8f253594..82227ee43dfb 100644 --- a/toolchain/check/testdata/let/fail_generic.carbon +++ b/toolchain/check/testdata/let/fail_generic.carbon @@ -11,12 +11,12 @@ // TODO: Should this be valid? fn F(a: i32) -> i32 { let T:! type = i32; - // CHECK:STDERR: fail_generic.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `Core.IntLiteral` to `T` [ImplicitAsConversionFailure] + // CHECK:STDERR: fail_generic.carbon:[[@LINE+7]]:14: error: cannot implicitly convert from `Core.IntLiteral` to `T` [ImplicitAsConversionFailure] // CHECK:STDERR: let x: T = 5; - // CHECK:STDERR: ^~~~~~~~~~~~~ - // CHECK:STDERR: fail_generic.carbon:[[@LINE+4]]:3: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(T)` [MissingImplInMemberAccessNote] + // CHECK:STDERR: ^ + // CHECK:STDERR: fail_generic.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(T)` [MissingImplInMemberAccessNote] // CHECK:STDERR: let x: T = 5; - // CHECK:STDERR: ^~~~~~~~~~~~~ + // CHECK:STDERR: ^ // CHECK:STDERR: let x: T = 5; // CHECK:STDERR: fail_generic.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `T` to `i32` [ImplicitAsConversionFailure] @@ -37,6 +37,7 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -76,10 +77,17 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %i32) -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = constants.%T.patt] +// CHECK:STDOUT: } // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, %i32.loc13 [symbolic = constants.%T] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %T = binding_pattern x +// CHECK:STDOUT: } // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] // CHECK:STDOUT: %.loc21: %T = converted %int_5, [template = ] // CHECK:STDOUT: %x: %T = bind_name x, // CHECK:STDOUT: %x.ref: %T = name_ref x, %x diff --git a/toolchain/check/testdata/let/fail_generic_import.carbon b/toolchain/check/testdata/let/fail_generic_import.carbon index f0fd9233f845..edea8884a068 100644 --- a/toolchain/check/testdata/let/fail_generic_import.carbon +++ b/toolchain/check/testdata/let/fail_generic_import.carbon @@ -47,16 +47,19 @@ let a: T = 0; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .T = @__global_init.%T +// CHECK:STDOUT: .T = %T // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = binding_pattern T +// CHECK:STDOUT: } +// CHECK:STDOUT: %T: type = bind_name T, @__global_init.%i32 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] -// CHECK:STDOUT: %T: type = bind_name T, %i32 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -78,17 +81,21 @@ let a: T = 0; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .T = imports.%import_ref // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .a = @__global_init.%a +// CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %T.ref: type = name_ref T, imports.%import_ref +// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] -// CHECK:STDOUT: %a: = bind_name a, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_missing_value.carbon b/toolchain/check/testdata/let/fail_missing_value.carbon index da14d72cb75a..8ddb27846634 100644 --- a/toolchain/check/testdata/let/fail_missing_value.carbon +++ b/toolchain/check/testdata/let/fail_missing_value.carbon @@ -42,17 +42,21 @@ fn F() { // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .n = %n +// CHECK:STDOUT: .n = .inst43.loc15_5 // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %n: %i32 = bind_name n, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %n: %i32 = bind_name n, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_modifiers.carbon b/toolchain/check/testdata/let/fail_modifiers.carbon index 883617c1010c..373c6a7e34e4 100644 --- a/toolchain/check/testdata/let/fail_modifiers.carbon +++ b/toolchain/check/testdata/let/fail_modifiers.carbon @@ -111,84 +111,140 @@ protected protected let i: i32 = 1; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .b = @__global_init.%b -// CHECK:STDOUT: .c = @__global_init.%c -// CHECK:STDOUT: .d = @__global_init.%d -// CHECK:STDOUT: .e = @__global_init.%e -// CHECK:STDOUT: .f = @__global_init.%f -// CHECK:STDOUT: .g = @__global_init.%g -// CHECK:STDOUT: .h = @__global_init.%h -// CHECK:STDOUT: .i = @__global_init.%i +// CHECK:STDOUT: .b [protected] = %b +// CHECK:STDOUT: .c = %c +// CHECK:STDOUT: .d = %d +// CHECK:STDOUT: .e = %e +// CHECK:STDOUT: .f = %f +// CHECK:STDOUT: .g = %g +// CHECK:STDOUT: .h [protected] = %h +// CHECK:STDOUT: .i [protected] = %i // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15_18: type = splice_block %i32.loc15 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc15: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc15: = bound_method @__global_init.%int_1.loc15, %impl.elem0.loc15 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc15: = specific_function %Convert.bound.loc15, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %Convert.specific_fn.loc15(@__global_init.%int_1.loc15) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc15_24.1: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc15_24.2: %i32 = converted @__global_init.%int_1.loc15, %.loc15_24.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %b: %i32 = bind_name b, %.loc15_24.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc21_16: type = splice_block %i32.loc21 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc21: = bound_method @__global_init.%int_1.loc21, %impl.elem0.loc21 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc21: = specific_function %Convert.bound.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(@__global_init.%int_1.loc21) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc21_22.1: %i32 = value_of_initializer %int.convert_checked.loc21 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc21_22.2: %i32 = converted @__global_init.%int_1.loc21, %.loc21_22.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %c: %i32 = bind_name c, %.loc21_22.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc27_14: type = splice_block %i32.loc27 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc27: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc27: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc27: = bound_method @__global_init.%int_1.loc27, %impl.elem0.loc27 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc27: = specific_function %Convert.bound.loc27, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc27: init %i32 = call %Convert.specific_fn.loc27(@__global_init.%int_1.loc27) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc27_20.1: %i32 = value_of_initializer %int.convert_checked.loc27 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc27_20.2: %i32 = converted @__global_init.%int_1.loc27, %.loc27_20.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %d: %i32 = bind_name d, %.loc27_20.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %i32 = binding_pattern e +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc33_16: type = splice_block %i32.loc33 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc33: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc33: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc33: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc33: = bound_method @__global_init.%int_1.loc33, %impl.elem0.loc33 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc33: = specific_function %Convert.bound.loc33, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc33: init %i32 = call %Convert.specific_fn.loc33(@__global_init.%int_1.loc33) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc33_22.1: %i32 = value_of_initializer %int.convert_checked.loc33 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc33_22.2: %i32 = converted @__global_init.%int_1.loc33, %.loc33_22.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %e: %i32 = bind_name e, %.loc33_22.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %f.patt: %i32 = binding_pattern f +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc46_22: type = splice_block %i32.loc46 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc46: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc46: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc46: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc46: = bound_method @__global_init.%int_1.loc46, %impl.elem0.loc46 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc46: = specific_function %Convert.bound.loc46, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc46: init %i32 = call %Convert.specific_fn.loc46(@__global_init.%int_1.loc46) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc46_28.1: %i32 = value_of_initializer %int.convert_checked.loc46 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc46_28.2: %i32 = converted @__global_init.%int_1.loc46, %.loc46_28.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %f: %i32 = bind_name f, %.loc46_28.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %g.patt: %i32 = binding_pattern g +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc59_24: type = splice_block %i32.loc59 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc59: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc59: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc59: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc59: = bound_method @__global_init.%int_1.loc59, %impl.elem0.loc59 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc59: = specific_function %Convert.bound.loc59, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc59: init %i32 = call %Convert.specific_fn.loc59(@__global_init.%int_1.loc59) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc59_30.1: %i32 = value_of_initializer %int.convert_checked.loc59 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc59_30.2: %i32 = converted @__global_init.%int_1.loc59, %.loc59_30.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %g: %i32 = bind_name g, %.loc59_30.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %h.patt: %i32 = binding_pattern h +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc72_26: type = splice_block %i32.loc72 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc72: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc72: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc72: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc72: = bound_method @__global_init.%int_1.loc72, %impl.elem0.loc72 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc72: = specific_function %Convert.bound.loc72, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc72: init %i32 = call %Convert.specific_fn.loc72(@__global_init.%int_1.loc72) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc72_32.1: %i32 = value_of_initializer %int.convert_checked.loc72 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc72_32.2: %i32 = converted @__global_init.%int_1.loc72, %.loc72_32.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %h: %i32 = bind_name h, %.loc72_32.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %i.patt: %i32 = binding_pattern i +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc85_28: type = splice_block %i32.loc85 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc85: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc85: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc85: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc85: = bound_method @__global_init.%int_1.loc85, %impl.elem0.loc85 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn.loc85: = specific_function %Convert.bound.loc85, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked.loc85: init %i32 = call %Convert.specific_fn.loc85(@__global_init.%int_1.loc85) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc85_34.1: %i32 = value_of_initializer %int.convert_checked.loc85 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc85_34.2: %i32 = converted @__global_init.%int_1.loc85, %.loc85_34.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %i: %i32 = bind_name i, %.loc85_34.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc15: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc15: = bound_method %int_1.loc15, %impl.elem0.loc15 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc15: = specific_function %Convert.bound.loc15, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %Convert.specific_fn.loc15(%int_1.loc15) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc15_25.1: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc15_25.2: %i32 = converted %int_1.loc15, %.loc15_25.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %b: %i32 = bind_name b, %.loc15_25.2 // CHECK:STDOUT: %int_1.loc21: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc21: = bound_method %int_1.loc21, %impl.elem0.loc21 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc21: = specific_function %Convert.bound.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(%int_1.loc21) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc21_23.1: %i32 = value_of_initializer %int.convert_checked.loc21 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc21_23.2: %i32 = converted %int_1.loc21, %.loc21_23.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %c: %i32 = bind_name c, %.loc21_23.2 // CHECK:STDOUT: %int_1.loc27: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc27: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc27: = bound_method %int_1.loc27, %impl.elem0.loc27 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc27: = specific_function %Convert.bound.loc27, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc27: init %i32 = call %Convert.specific_fn.loc27(%int_1.loc27) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc27_21.1: %i32 = value_of_initializer %int.convert_checked.loc27 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc27_21.2: %i32 = converted %int_1.loc27, %.loc27_21.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %d: %i32 = bind_name d, %.loc27_21.2 // CHECK:STDOUT: %int_1.loc33: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc33: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc33: = bound_method %int_1.loc33, %impl.elem0.loc33 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc33: = specific_function %Convert.bound.loc33, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc33: init %i32 = call %Convert.specific_fn.loc33(%int_1.loc33) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc33_23.1: %i32 = value_of_initializer %int.convert_checked.loc33 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc33_23.2: %i32 = converted %int_1.loc33, %.loc33_23.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %e: %i32 = bind_name e, %.loc33_23.2 // CHECK:STDOUT: %int_1.loc46: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc46: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc46: = bound_method %int_1.loc46, %impl.elem0.loc46 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc46: = specific_function %Convert.bound.loc46, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc46: init %i32 = call %Convert.specific_fn.loc46(%int_1.loc46) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc46_29.1: %i32 = value_of_initializer %int.convert_checked.loc46 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc46_29.2: %i32 = converted %int_1.loc46, %.loc46_29.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %f: %i32 = bind_name f, %.loc46_29.2 // CHECK:STDOUT: %int_1.loc59: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc59: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc59: = bound_method %int_1.loc59, %impl.elem0.loc59 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc59: = specific_function %Convert.bound.loc59, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc59: init %i32 = call %Convert.specific_fn.loc59(%int_1.loc59) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc59_31.1: %i32 = value_of_initializer %int.convert_checked.loc59 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc59_31.2: %i32 = converted %int_1.loc59, %.loc59_31.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %g: %i32 = bind_name g, %.loc59_31.2 // CHECK:STDOUT: %int_1.loc72: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc72: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc72: = bound_method %int_1.loc72, %impl.elem0.loc72 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc72: = specific_function %Convert.bound.loc72, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc72: init %i32 = call %Convert.specific_fn.loc72(%int_1.loc72) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc72_33.1: %i32 = value_of_initializer %int.convert_checked.loc72 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc72_33.2: %i32 = converted %int_1.loc72, %.loc72_33.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %h: %i32 = bind_name h, %.loc72_33.2 // CHECK:STDOUT: %int_1.loc85: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc85: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc85: = bound_method %int_1.loc85, %impl.elem0.loc85 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn.loc85: = specific_function %Convert.bound.loc85, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked.loc85: init %i32 = call %Convert.specific_fn.loc85(%int_1.loc85) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc85_35.1: %i32 = value_of_initializer %int.convert_checked.loc85 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc85_35.2: %i32 = converted %int_1.loc85, %.loc85_35.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %i: %i32 = bind_name i, %.loc85_35.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/fail_use_in_init.carbon b/toolchain/check/testdata/let/fail_use_in_init.carbon index d14a037988da..5a40d6e51d4a 100644 --- a/toolchain/check/testdata/let/fail_use_in_init.carbon +++ b/toolchain/check/testdata/let/fail_use_in_init.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/fail_use_in_init.carbon fn F() { - // CHECK:STDERR: fail_use_in_init.carbon:[[@LINE+4]]:16: error: name `a` not found [NameNotFound] + // CHECK:STDERR: fail_use_in_init.carbon:[[@LINE+4]]:16: error: `a` used before initialization [UsedBeforeInitialization] // CHECK:STDERR: let a: i32 = a; // CHECK:STDERR: ^ // CHECK:STDERR: @@ -44,7 +44,14 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %a.ref: = name_ref a, [template = ] +// CHECK:STDOUT: %.loc16: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: %i32 = bind_name a, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/let/generic.carbon b/toolchain/check/testdata/let/generic.carbon index f7d9f59c8a90..af031d113095 100644 --- a/toolchain/check/testdata/let/generic.carbon +++ b/toolchain/check/testdata/let/generic.carbon @@ -19,9 +19,10 @@ fn F() { // CHECK:STDOUT: constants { // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] -// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %ptr: type = ptr_type %T [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -44,18 +45,34 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = constants.%T.patt] +// CHECK:STDOUT: } // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, %i32 [symbolic = constants.%T] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr = binding_pattern p +// CHECK:STDOUT: %.loc13_3: %ptr = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr = var p +// CHECK:STDOUT: %.loc13_11: type = splice_block %ptr [symbolic = constants.%ptr] { +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T [symbolic = constants.%T] +// CHECK:STDOUT: %ptr: type = ptr_type %T [symbolic = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %T = binding_pattern a +// CHECK:STDOUT: %.loc14_3: %T = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %T = var a -// CHECK:STDOUT: %a: ref %T = bind_name a, %a.var // CHECK:STDOUT: %p.ref: ref %ptr = name_ref p, %p // CHECK:STDOUT: %.loc14_15: %ptr = bind_value %p.ref // CHECK:STDOUT: %.loc14_14.1: ref %T = deref %.loc14_15 // CHECK:STDOUT: %.loc14_14.2: %T = bind_value %.loc14_14.1 // CHECK:STDOUT: assign %a.var, %.loc14_14.2 +// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T [symbolic = constants.%T] +// CHECK:STDOUT: %a: ref %T = bind_name a, %a.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/generic_import.carbon b/toolchain/check/testdata/let/generic_import.carbon index dd09f2737821..c495bf709882 100644 --- a/toolchain/check/testdata/let/generic_import.carbon +++ b/toolchain/check/testdata/let/generic_import.carbon @@ -51,16 +51,19 @@ var b: T = *a; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .T = @__global_init.%T +// CHECK:STDOUT: .T = %T // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %T.patt: type = binding_pattern T +// CHECK:STDOUT: } +// CHECK:STDOUT: %T: type = bind_name T, @__global_init.%i32 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] -// CHECK:STDOUT: %T: type = bind_name T, %i32 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -84,15 +87,28 @@ var b: T = *a; // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc8_1: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: %.loc8_9: type = splice_block %ptr [template = ] { +// CHECK:STDOUT: %T.ref.loc8: type = name_ref T, imports.%import_ref +// CHECK:STDOUT: %ptr: type = ptr_type [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: = bind_name a, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: = binding_pattern b +// CHECK:STDOUT: %.loc13: = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref = var b -// CHECK:STDOUT: %b: ref = bind_name b, %b.var +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, imports.%import_ref +// CHECK:STDOUT: %b: = bind_name b, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: ref = name_ref a, file.%a +// CHECK:STDOUT: %a.ref: = name_ref a, file.%a // CHECK:STDOUT: %.loc13: ref = deref // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/let/global.carbon b/toolchain/check/testdata/let/global.carbon index 32929b1d3d1b..85676cd60059 100644 --- a/toolchain/check/testdata/let/global.carbon +++ b/toolchain/check/testdata/let/global.carbon @@ -41,10 +41,24 @@ fn F() -> i32 { return n; } // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .n = @__global_init.%n +// CHECK:STDOUT: .n = %n // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound: = bound_method @__global_init.%int_1, %impl.elem0 [template = constants.%Convert.bound] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(@__global_init.%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_14.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_14.2: %i32 = converted @__global_init.%int_1, %.loc11_14.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %n: %i32 = bind_name n, %.loc11_14.2 // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 @@ -58,20 +72,13 @@ fn F() -> i32 { return n; } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %n.ref: %i32 = name_ref n, @__global_init.%n +// CHECK:STDOUT: %n.ref: %i32 = name_ref n, file.%n // CHECK:STDOUT: return %n.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound: = bound_method %int_1, %impl.elem0 [template = constants.%Convert.bound] -// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] -// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_15.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_15.2: %i32 = converted %int_1, %.loc11_15.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %n: %i32 = bind_name n, %.loc11_15.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/local.carbon b/toolchain/check/testdata/let/local.carbon index 1ae64c020b2b..b15fa0038564 100644 --- a/toolchain/check/testdata/let/local.carbon +++ b/toolchain/check/testdata/let/local.carbon @@ -57,7 +57,14 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %i32) -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: } // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a +// CHECK:STDOUT: %.loc12: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: %i32 = bind_name b, %a.ref // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b // CHECK:STDOUT: return %b.ref diff --git a/toolchain/check/testdata/let/no_prelude/import.carbon b/toolchain/check/testdata/let/no_prelude/import.carbon index ff08684d494c..b2f7cc69d01e 100644 --- a/toolchain/check/testdata/let/no_prelude/import.carbon +++ b/toolchain/check/testdata/let/no_prelude/import.carbon @@ -41,16 +41,23 @@ let b: () = Other.a; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .a = @__global_init.%a +// CHECK:STDOUT: .a = %a // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc4_14: %empty_tuple.type = converted @__global_init.%.loc4, %empty_tuple [template = constants.%empty_tuple] +// CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc4_14 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc4_14: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_15: %empty_tuple.type = converted %.loc4_14, %empty_tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc4_15 +// CHECK:STDOUT: %.loc4: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -67,16 +74,23 @@ let b: () = Other.a; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .a = imports.%import_ref -// CHECK:STDOUT: .b = @__global_init.%b +// CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: %empty_tuple.type = bind_name b, @__global_init.%a.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %empty_tuple.type = name_ref a, imports.%import_ref -// CHECK:STDOUT: %b: %empty_tuple.type = bind_name b, %a.ref // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -89,16 +103,23 @@ let b: () = Other.a; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .a = @__global_init.%a +// CHECK:STDOUT: .a = %a // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc4_14: %empty_tuple.type = converted @__global_init.%.loc4, %empty_tuple [template = constants.%empty_tuple] +// CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc4_14 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc4_14: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_15: %empty_tuple.type = converted %.loc4_14, %empty_tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc4_15 +// CHECK:STDOUT: %.loc4: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -119,16 +140,23 @@ let b: () = Other.a; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Other = imports.%Other -// CHECK:STDOUT: .b = @__global_init.%b +// CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: %empty_tuple.type = bind_name b, @__global_init.%a.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] // CHECK:STDOUT: %a.ref: %empty_tuple.type = name_ref a, imports.%import_ref -// CHECK:STDOUT: %b: %empty_tuple.type = bind_name b, %a.ref // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/no_prelude/import_access.carbon b/toolchain/check/testdata/let/no_prelude/import_access.carbon index 63e6a21ae4b9..d1ce06bda416 100644 --- a/toolchain/check/testdata/let/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/let/no_prelude/import_access.carbon @@ -61,16 +61,23 @@ let v2: () = Test.v; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .v [private] = @__global_init.%v +// CHECK:STDOUT: .v [private] = %v // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %empty_tuple.type = binding_pattern v +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_17.1: type = splice_block %.loc4_17.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_17.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_17.3: type = converted %.loc4_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc4_22: %empty_tuple.type = converted @__global_init.%.loc4, %empty_tuple [template = constants.%empty_tuple] +// CHECK:STDOUT: %v: %empty_tuple.type = bind_name v, %.loc4_22 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc4_22: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_23: %empty_tuple.type = converted %.loc4_22, %empty_tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: %v: %empty_tuple.type = bind_name v, %.loc4_23 +// CHECK:STDOUT: %.loc4: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -87,16 +94,23 @@ let v2: () = Test.v; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .v [private] = imports.%import_ref -// CHECK:STDOUT: .v2 = @__global_init.%v2 +// CHECK:STDOUT: .v2 = %v2 // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v2.patt: %empty_tuple.type = binding_pattern v2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc4_10.1: type = splice_block %.loc4_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_10.3: type = converted %.loc4_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v2: %empty_tuple.type = bind_name v2, @__global_init.%v.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %v.ref: %empty_tuple.type = name_ref v, imports.%import_ref -// CHECK:STDOUT: %v2: %empty_tuple.type = bind_name v2, %v.ref // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -108,15 +122,22 @@ let v2: () = Test.v; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .v2 = @__global_init.%v2 +// CHECK:STDOUT: .v2 = %v2 // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v2.patt: %empty_tuple.type = binding_pattern v2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10_10.1: type = splice_block %.loc10_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_10.3: type = converted %.loc10_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v2: %empty_tuple.type = bind_name v2, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %v.ref: = name_ref v, [template = ] -// CHECK:STDOUT: %v2: %empty_tuple.type = bind_name v2, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -135,16 +156,23 @@ let v2: () = Test.v; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Test = imports.%Test -// CHECK:STDOUT: .v2 = @__global_init.%v2 +// CHECK:STDOUT: .v2 = %v2 // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v2.patt: %empty_tuple.type = binding_pattern v2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10_10.1: type = splice_block %.loc10_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_10.3: type = converted %.loc10_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v2: %empty_tuple.type = bind_name v2, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Test.ref: = name_ref Test, imports.%Test [template = imports.%Test] // CHECK:STDOUT: %v.ref: = name_ref v, [template = ] -// CHECK:STDOUT: %v2: %empty_tuple.type = bind_name v2, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/shadowed_decl.carbon b/toolchain/check/testdata/let/shadowed_decl.carbon index e7e5f185dbc7..1dce299d3c95 100644 --- a/toolchain/check/testdata/let/shadowed_decl.carbon +++ b/toolchain/check/testdata/let/shadowed_decl.carbon @@ -47,8 +47,8 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { -// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a -// CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0 +// CHECK:STDOUT: %a.patt.loc11: %i32 = binding_pattern a +// CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt.loc11, runtime_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { @@ -67,14 +67,21 @@ fn F(a: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a.param_patt: %i32) -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt.loc12: %i32 = binding_pattern a +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_1, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc12_17.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc12_17.2: %i32 = converted %int_1, %.loc12_17.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %a.loc12: %i32 = bind_name a, %.loc12_17.2 +// CHECK:STDOUT: %.loc12_16.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc12_16.2: %i32 = converted %int_1, %.loc12_16.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %a.loc12: %i32 = bind_name a, %.loc12_16.2 // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a.loc12 // CHECK:STDOUT: return %a.ref // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/namespace/add_to_import.carbon b/toolchain/check/testdata/namespace/add_to_import.carbon index 5219578e8899..846c6d89dcdc 100644 --- a/toolchain/check/testdata/namespace/add_to_import.carbon +++ b/toolchain/check/testdata/namespace/add_to_import.carbon @@ -88,7 +88,15 @@ var a: i32 = NS.A(); // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc6_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/imported.carbon b/toolchain/check/testdata/namespace/imported.carbon index 0e0f0ae585c5..b17c955f621c 100644 --- a/toolchain/check/testdata/namespace/imported.carbon +++ b/toolchain/check/testdata/namespace/imported.carbon @@ -105,13 +105,45 @@ var package_b: () = package.NS.ChildNS.B(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc5_1: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b +// CHECK:STDOUT: %.loc5_9.1: type = splice_block %.loc5_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc5_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_9.3: type = converted %.loc5_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %package_a.patt: %empty_tuple.type = binding_pattern package_a +// CHECK:STDOUT: %.loc7_1: %empty_tuple.type = var_pattern %package_a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %package_a.var: ref %empty_tuple.type = var package_a +// CHECK:STDOUT: %.loc7_17.1: type = splice_block %.loc7_17.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc7_17.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc7_17.3: type = converted %.loc7_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %package_a: ref %empty_tuple.type = bind_name package_a, %package_a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %package_b.patt: %empty_tuple.type = binding_pattern package_b +// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %package_b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %package_b.var: ref %empty_tuple.type = var package_b +// CHECK:STDOUT: %.loc8_17.1: type = splice_block %.loc8_17.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc8_17.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_17.3: type = converted %.loc8_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %package_b: ref %empty_tuple.type = bind_name package_b, %package_b.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/imported_indirect.carbon b/toolchain/check/testdata/namespace/imported_indirect.carbon index 631333523661..4ffe6a07daf9 100644 --- a/toolchain/check/testdata/namespace/imported_indirect.carbon +++ b/toolchain/check/testdata/namespace/imported_indirect.carbon @@ -254,7 +254,15 @@ fn G() { Same.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc5_1: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc5_9.1: type = splice_block %.loc5_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc5_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_9.3: type = converted %.loc5_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/merging_with_indirections.carbon b/toolchain/check/testdata/namespace/merging_with_indirections.carbon index 3cf0074fbc7d..a40e1eb9c319 100644 --- a/toolchain/check/testdata/namespace/merging_with_indirections.carbon +++ b/toolchain/check/testdata/namespace/merging_with_indirections.carbon @@ -164,6 +164,13 @@ fn Run() { // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.f04: %F.type = import_ref Other//b, F, loaded [template = constants.%F] // CHECK:STDOUT: %import_ref.8db: = import_ref Other//b, inst28 [indirect], loaded [template = constants.%complete_type] +// CHECK:STDOUT: %import_ref.a85: = import_ref Other//b, NS1, loaded +// CHECK:STDOUT: %NS1: = namespace %import_ref.a85, [template] { +// CHECK:STDOUT: .A = %import_ref.257 +// CHECK:STDOUT: import Other//b +// CHECK:STDOUT: import Other//a +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.257: type = import_ref Other//a, A, loaded [template = constants.%A] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -188,7 +195,16 @@ fn Run() { // CHECK:STDOUT: %.loc7_11.1: ref %A = temporary_storage // CHECK:STDOUT: %F.call.loc7: init %A = call %F.ref.loc7() to %.loc7_11.1 // CHECK:STDOUT: %.loc7_11.2: ref %A = temporary %.loc7_11.1, %F.call.loc7 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %A = binding_pattern a +// CHECK:STDOUT: %.loc10_3: %A = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %A = var a +// CHECK:STDOUT: %.loc10_19: type = splice_block %A.ref [template = constants.%A] { +// CHECK:STDOUT: %Other.ref.loc10: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %NS1.ref: = name_ref NS1, imports.%NS1 [template = imports.%NS1] +// CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.257 [template = constants.%A] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %A = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %A = name_ref a, %a // CHECK:STDOUT: %Other.ref.loc13: = name_ref Other, imports.%Other [template = imports.%Other] diff --git a/toolchain/check/testdata/namespace/shadow.carbon b/toolchain/check/testdata/namespace/shadow.carbon index 87d9383a7a70..06b3ddb8d27f 100644 --- a/toolchain/check/testdata/namespace/shadow.carbon +++ b/toolchain/check/testdata/namespace/shadow.carbon @@ -79,8 +79,8 @@ fn N.M.B() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -98,15 +98,23 @@ fn N.M.B() -> i32 { // CHECK:STDOUT: if %true br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %A.patt: %i32 = binding_pattern A +// CHECK:STDOUT: %.loc22_5.1: %i32 = var_pattern %A.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %A.var: ref %i32 = var A -// CHECK:STDOUT: %A: ref %i32 = bind_name A, %A.var // CHECK:STDOUT: %int_0.loc22: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc22: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc22: = bound_method %int_0.loc22, %impl.elem0.loc22 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn.loc22: = specific_function %Convert.bound.loc22, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked.loc22: init %i32 = call %Convert.specific_fn.loc22(%int_0.loc22) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc22: init %i32 = converted %int_0.loc22, %int.convert_checked.loc22 [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %A.var, %.loc22 +// CHECK:STDOUT: %.loc22_5.2: init %i32 = converted %int_0.loc22, %int.convert_checked.loc22 [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %A.var, %.loc22_5.2 +// CHECK:STDOUT: %.loc22_12: type = splice_block %i32.loc22 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %A: ref %i32 = bind_name A, %A.var // CHECK:STDOUT: %A.ref.loc25: ref %i32 = name_ref A, %A // CHECK:STDOUT: %.loc25: %i32 = bind_value %A.ref.loc25 // CHECK:STDOUT: return %.loc25 diff --git a/toolchain/check/testdata/operators/builtin/and.carbon b/toolchain/check/testdata/operators/builtin/and.carbon index 1b5c70fdaaa0..03569c5002bc 100644 --- a/toolchain/check/testdata/operators/builtin/and.carbon +++ b/toolchain/check/testdata/operators/builtin/and.carbon @@ -102,9 +102,9 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: } { // CHECK:STDOUT: %x.param: bool = value_param runtime_param0 // CHECK:STDOUT: %.loc25_23.1: type = splice_block %.loc25_23.3 [template = bool] { -// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc25_23.2: type = value_of_initializer %bool.make_type [template = bool] -// CHECK:STDOUT: %.loc25_23.3: type = converted %bool.make_type, %.loc25_23.2 [template = bool] +// CHECK:STDOUT: %bool.make_type.loc25: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc25_23.2: type = value_of_initializer %bool.make_type.loc25 [template = bool] +// CHECK:STDOUT: %.loc25_23.3: type = converted %bool.make_type.loc25, %.loc25_23.2 [template = bool] // CHECK:STDOUT: } // CHECK:STDOUT: %x: bool = bind_name x, %x.param // CHECK:STDOUT: } @@ -145,39 +145,214 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Constant() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: bool = binding_pattern a +// CHECK:STDOUT: %.loc19_3: bool = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref bool = var a +// CHECK:STDOUT: %true.loc19_47: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: assign %a.var, %true.loc19_47 +// CHECK:STDOUT: br !.loc19_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc19_13: +// CHECK:STDOUT: %true.loc19_13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %true.loc19_13 br !and.rhs.loc19 else br !and.result.loc19(%false.loc19) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs.loc19: +// CHECK:STDOUT: %true.loc19_22: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: br !and.result.loc19(%true.loc19_22) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result.loc19: +// CHECK:STDOUT: %.loc19_18: bool = block_arg !and.result.loc19 [template = constants.%true] +// CHECK:STDOUT: if %.loc19_18 br !if.expr.then.loc19 else br !if.expr.else.loc19 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc19: +// CHECK:STDOUT: %bool.make_type.loc19: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc19_32.1: type = value_of_initializer %bool.make_type.loc19 [template = bool] +// CHECK:STDOUT: %.loc19_32.2: type = converted %bool.make_type.loc19, %.loc19_32.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_32.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc19: +// CHECK:STDOUT: %.loc19_43: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_37: type = converted %.loc19_43, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_37) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc19: +// CHECK:STDOUT: %.loc19_10: type = block_arg !if.expr.result.loc19 [template = bool] +// CHECK:STDOUT: br !.loc19_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc19_7: // CHECK:STDOUT: %a: ref bool = bind_name a, %a.var -// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] -// CHECK:STDOUT: assign %a.var, %true +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc20_3.1: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b -// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var // CHECK:STDOUT: %.loc20_49.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc20_49.2: init %empty_tuple.type = tuple_init () to %b.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc20_50: init %empty_tuple.type = converted %.loc20_49.1, %.loc20_49.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %b.var, %.loc20_50 +// CHECK:STDOUT: %.loc20_3.2: init %empty_tuple.type = converted %.loc20_49.1, %.loc20_49.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %b.var, %.loc20_3.2 +// CHECK:STDOUT: br !.loc20_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc20_13: +// CHECK:STDOUT: %true.loc20: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc20_18: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %true.loc20 br !and.rhs.loc20 else br !and.result.loc20(%false.loc20_18) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs.loc20: +// CHECK:STDOUT: %false.loc20_22: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: br !and.result.loc20(%false.loc20_22) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result.loc20: +// CHECK:STDOUT: %.loc20_18: bool = block_arg !and.result.loc20 [template = constants.%false] +// CHECK:STDOUT: if %.loc20_18 br !if.expr.then.loc20 else br !if.expr.else.loc20 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc20: +// CHECK:STDOUT: %bool.make_type.loc20: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc20_33.1: type = value_of_initializer %bool.make_type.loc20 [template = bool] +// CHECK:STDOUT: %.loc20_33.2: type = converted %bool.make_type.loc20, %.loc20_33.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_33.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc20: +// CHECK:STDOUT: %.loc20_44: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc20_38: type = converted %.loc20_44, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_38) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc20: +// CHECK:STDOUT: %.loc20_10: type = block_arg !if.expr.result.loc20 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !.loc20_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc20_7: +// CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %empty_tuple.type = binding_pattern c +// CHECK:STDOUT: %.loc21_3.1: %empty_tuple.type = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %empty_tuple.type = var c -// CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var // CHECK:STDOUT: %.loc21_49.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc21_49.2: init %empty_tuple.type = tuple_init () to %c.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc21_50: init %empty_tuple.type = converted %.loc21_49.1, %.loc21_49.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %c.var, %.loc21_50 +// CHECK:STDOUT: %.loc21_3.2: init %empty_tuple.type = converted %.loc21_49.1, %.loc21_49.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %c.var, %.loc21_3.2 +// CHECK:STDOUT: br !.loc21_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc21_13: +// CHECK:STDOUT: %false.loc21_13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc21_19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %false.loc21_13 br !and.rhs.loc21 else br !and.result.loc21(%false.loc21_19) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs.loc21: +// CHECK:STDOUT: %true.loc21: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: br !and.result.loc21(%true.loc21) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result.loc21: +// CHECK:STDOUT: %.loc21_19: bool = block_arg !and.result.loc21 [template = constants.%false] +// CHECK:STDOUT: if %.loc21_19 br !if.expr.then.loc21 else br !if.expr.else.loc21 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc21: +// CHECK:STDOUT: %bool.make_type.loc21: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc21_33.1: type = value_of_initializer %bool.make_type.loc21 [template = bool] +// CHECK:STDOUT: %.loc21_33.2: type = converted %bool.make_type.loc21, %.loc21_33.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc21(%.loc21_33.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc21: +// CHECK:STDOUT: %.loc21_44: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc21_38: type = converted %.loc21_44, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc21(%.loc21_38) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc21: +// CHECK:STDOUT: %.loc21_10: type = block_arg !if.expr.result.loc21 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !.loc21_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc21_7: +// CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc22_3.1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d -// CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var // CHECK:STDOUT: %.loc22_50.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc22_50.2: init %empty_tuple.type = tuple_init () to %d.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc22_51: init %empty_tuple.type = converted %.loc22_50.1, %.loc22_50.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %d.var, %.loc22_51 +// CHECK:STDOUT: %.loc22_3.2: init %empty_tuple.type = converted %.loc22_50.1, %.loc22_50.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %d.var, %.loc22_3.2 +// CHECK:STDOUT: br !.loc22_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc22_13: +// CHECK:STDOUT: %false.loc22_13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc22_19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %false.loc22_13 br !and.rhs.loc22 else br !and.result.loc22(%false.loc22_19) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs.loc22: +// CHECK:STDOUT: %false.loc22_23: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: br !and.result.loc22(%false.loc22_23) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result.loc22: +// CHECK:STDOUT: %.loc22_19: bool = block_arg !and.result.loc22 [template = constants.%false] +// CHECK:STDOUT: if %.loc22_19 br !if.expr.then.loc22 else br !if.expr.else.loc22 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc22: +// CHECK:STDOUT: %bool.make_type.loc22: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc22_34.1: type = value_of_initializer %bool.make_type.loc22 [template = bool] +// CHECK:STDOUT: %.loc22_34.2: type = converted %bool.make_type.loc22, %.loc22_34.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc22(%.loc22_34.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc22: +// CHECK:STDOUT: %.loc22_45: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc22_39: type = converted %.loc22_45, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc22(%.loc22_39) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc22: +// CHECK:STDOUT: %.loc22_10: type = block_arg !if.expr.result.loc22 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !.loc22_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc22_7: +// CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @PartialConstant(%x.param_patt: bool) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc26_3.1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a -// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: %.loc26_46.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc26_46.2: init %empty_tuple.type = tuple_init () to %a.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc26_47: init %empty_tuple.type = converted %.loc26_46.1, %.loc26_46.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %a.var, %.loc26_47 +// CHECK:STDOUT: %.loc26_3.2: init %empty_tuple.type = converted %.loc26_46.1, %.loc26_46.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %a.var, %.loc26_3.2 +// CHECK:STDOUT: br !.loc26_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc26_13: +// CHECK:STDOUT: %false.loc26_13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %false.loc26_19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %false.loc26_13 br !and.rhs else br !and.result(%false.loc26_19) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs: +// CHECK:STDOUT: %x.ref: bool = name_ref x, %x +// CHECK:STDOUT: br !and.result(%x.ref) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result: +// CHECK:STDOUT: %.loc26_19: bool = block_arg !and.result [template = constants.%false] +// CHECK:STDOUT: if %.loc26_19 br !if.expr.then else br !if.expr.else +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then: +// CHECK:STDOUT: %bool.make_type.loc26: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc26_30.1: type = value_of_initializer %bool.make_type.loc26 [template = bool] +// CHECK:STDOUT: %.loc26_30.2: type = converted %bool.make_type.loc26, %.loc26_30.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result(%.loc26_30.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else: +// CHECK:STDOUT: %.loc26_41: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc26_35: type = converted %.loc26_41, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result(%.loc26_35) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result: +// CHECK:STDOUT: %.loc26_10: type = block_arg !if.expr.result [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !.loc26_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc26_7: +// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/assignment.carbon b/toolchain/check/testdata/operators/builtin/assignment.carbon index 8c60635474e5..78b52f9d6d54 100644 --- a/toolchain/check/testdata/operators/builtin/assignment.carbon +++ b/toolchain/check/testdata/operators/builtin/assignment.carbon @@ -45,6 +45,7 @@ fn Main() { // CHECK:STDOUT: %Convert.bound.9e2: = bound_method %int_9.988, %Convert.956 [template] // CHECK:STDOUT: %Convert.specific_fn.b02: = specific_function %Convert.bound.9e2, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_9.f88: %i32 = int_value 9 [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] @@ -100,15 +101,23 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a -// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [template = constants.%int_12.6a3] // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc12: = bound_method %int_12, %impl.elem0.loc12 [template = constants.%Convert.bound.221] // CHECK:STDOUT: %Convert.specific_fn.loc12: = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.9a9] // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_12) [template = constants.%int_12.1e1] -// CHECK:STDOUT: %.loc12: init %i32 = converted %int_12, %int.convert_checked.loc12 [template = constants.%int_12.1e1] -// CHECK:STDOUT: assign %a.var, %.loc12 +// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_12, %int.convert_checked.loc12 [template = constants.%int_12.1e1] +// CHECK:STDOUT: assign %a.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %a.ref.loc13: ref %i32 = name_ref a, %a // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [template = constants.%int_9.988] // CHECK:STDOUT: %impl.elem0.loc13: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] @@ -117,8 +126,11 @@ fn Main() { // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %Convert.specific_fn.loc13(%int_9) [template = constants.%int_9.f88] // CHECK:STDOUT: %.loc13: init %i32 = converted %int_9, %int.convert_checked.loc13 [template = constants.%int_9.f88] // CHECK:STDOUT: assign %a.ref.loc13, %.loc13 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %tuple.type.d07 = binding_pattern b +// CHECK:STDOUT: %.loc15_3.1: %tuple.type.d07 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %tuple.type.d07 = var b -// CHECK:STDOUT: %b: ref %tuple.type.d07 = bind_name b, %b.var // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc15: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc15_28.1: %tuple.type.f94 = tuple_literal (%int_1.loc15, %int_2.loc15) @@ -137,8 +149,17 @@ fn Main() { // CHECK:STDOUT: %tuple.elem1.loc15: ref %i32 = tuple_access %b.var, element1 // CHECK:STDOUT: %.loc15_28.5: init %i32 = initialize_from %.loc15_28.4 to %tuple.elem1.loc15 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc15_28.6: init %tuple.type.d07 = tuple_init (%.loc15_28.3, %.loc15_28.5) to %b.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc15_29: init %tuple.type.d07 = converted %.loc15_28.1, %.loc15_28.6 [template = constants.%tuple] -// CHECK:STDOUT: assign %b.var, %.loc15_29 +// CHECK:STDOUT: %.loc15_3.2: init %tuple.type.d07 = converted %.loc15_28.1, %.loc15_28.6 [template = constants.%tuple] +// CHECK:STDOUT: assign %b.var, %.loc15_3.2 +// CHECK:STDOUT: %.loc15_19.1: type = splice_block %.loc15_19.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc15_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_19.2: %tuple.type.24b = tuple_literal (%i32.loc15_11, %i32.loc15_16) +// CHECK:STDOUT: %.loc15_19.3: type = converted %.loc15_19.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %b: ref %tuple.type.d07 = bind_name b, %b.var // CHECK:STDOUT: %b.ref.loc16: ref %tuple.type.d07 = name_ref b, %b // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: %tuple.elem0.loc16: ref %i32 = tuple_access %b.ref.loc16, element0 @@ -159,8 +180,11 @@ fn Main() { // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %Convert.specific_fn.loc17(%int_4.loc17) [template = constants.%int_4.940] // CHECK:STDOUT: %.loc17: init %i32 = converted %int_4.loc17, %int.convert_checked.loc17 [template = constants.%int_4.940] // CHECK:STDOUT: assign %tuple.elem1.loc17, %.loc17 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %struct_type.a.b.501 = binding_pattern c +// CHECK:STDOUT: %.loc19_3.1: %struct_type.a.b.501 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.a.b.501 = var c -// CHECK:STDOUT: %c: ref %struct_type.a.b.501 = bind_name c, %c.var // CHECK:STDOUT: %int_1.loc19: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc19: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc19_46.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc19, %int_2.loc19) @@ -179,8 +203,16 @@ fn Main() { // CHECK:STDOUT: %.loc19_46.6: ref %i32 = struct_access %c.var, element1 // CHECK:STDOUT: %.loc19_46.7: init %i32 = initialize_from %.loc19_46.5 to %.loc19_46.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc19_46.8: init %struct_type.a.b.501 = struct_init (%.loc19_46.4, %.loc19_46.7) to %c.var [template = constants.%struct] -// CHECK:STDOUT: %.loc19_47: init %struct_type.a.b.501 = converted %.loc19_46.1, %.loc19_46.8 [template = constants.%struct] -// CHECK:STDOUT: assign %c.var, %.loc19_47 +// CHECK:STDOUT: %.loc19_3.2: init %struct_type.a.b.501 = converted %.loc19_46.1, %.loc19_46.8 [template = constants.%struct] +// CHECK:STDOUT: assign %c.var, %.loc19_3.2 +// CHECK:STDOUT: %.loc19_27: type = splice_block %struct_type.a.b [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc19_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc19_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } +// CHECK:STDOUT: %c: ref %struct_type.a.b.501 = bind_name c, %c.var // CHECK:STDOUT: %c.ref.loc20: ref %struct_type.a.b.501 = name_ref c, %c // CHECK:STDOUT: %.loc20_4: ref %i32 = struct_access %c.ref.loc20, element0 // CHECK:STDOUT: %int_3.loc20: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] @@ -199,11 +231,20 @@ fn Main() { // CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(%int_4.loc21) [template = constants.%int_4.940] // CHECK:STDOUT: %.loc21_7: init %i32 = converted %int_4.loc21, %int.convert_checked.loc21 [template = constants.%int_4.940] // CHECK:STDOUT: assign %.loc21_4, %.loc21_7 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr.235 = binding_pattern p +// CHECK:STDOUT: %.loc23_3: %ptr.235 = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr.235 = var p -// CHECK:STDOUT: %p: ref %ptr.235 = bind_name p, %p.var // CHECK:STDOUT: %a.ref.loc23: ref %i32 = name_ref a, %a // CHECK:STDOUT: %addr.loc23: %ptr.235 = addr_of %a.ref.loc23 // CHECK:STDOUT: assign %p.var, %addr.loc23 +// CHECK:STDOUT: %.loc23_13: type = splice_block %ptr [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: ref %ptr.235 = bind_name p, %p.var // CHECK:STDOUT: %p.ref.loc24: ref %ptr.235 = name_ref p, %p // CHECK:STDOUT: %.loc24_4: %ptr.235 = bind_value %p.ref.loc24 // CHECK:STDOUT: %.loc24_3: ref %i32 = deref %.loc24_4 diff --git a/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon b/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon index dc15e8c0adb2..bb502a7adaca 100644 --- a/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_and_or_not_in_function.carbon @@ -14,14 +14,16 @@ fn F(b: bool) -> type { } // TODO: Short-circuit operators should be permitted outside functions. -// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+8]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] +// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+10]]:13: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] // CHECK:STDERR: var and_: F(true and true); // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: -// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+4]]:11: error: cannot evaluate type expression [TypeExprEvaluationFailure] +// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+6]]:11: error: cannot evaluate type expression [TypeExprEvaluationFailure] // CHECK:STDERR: var and_: F(true and true); // CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: +// CHECK:STDERR: fail_and_or_not_in_function.carbon: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] +// CHECK:STDERR: var and_: F(true and true); // CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+12]]:21: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] @@ -38,14 +40,16 @@ var and_: F(true and true); // CHECK:STDERR: var and_val: bool = true and true; -// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+8]]:12: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] +// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+10]]:12: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] // CHECK:STDERR: var or_: F(true or true); // CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: -// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+4]]:10: error: cannot evaluate type expression [TypeExprEvaluationFailure] +// CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+6]]:10: error: cannot evaluate type expression [TypeExprEvaluationFailure] // CHECK:STDERR: var or_: F(true or true); // CHECK:STDERR: ^~~~~~~~~~~~~~~ // CHECK:STDERR: +// CHECK:STDERR: fail_and_or_not_in_function.carbon: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] +// CHECK:STDERR: var or_: F(true or true); // CHECK:STDERR: fail_and_or_not_in_function.carbon:[[@LINE+12]]:20: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo] @@ -114,13 +118,39 @@ var or_val: bool = true or true; // CHECK:STDOUT: %return.param: ref type = out_param runtime_param1 // CHECK:STDOUT: %return: ref type = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %and_.patt: = binding_pattern and_ +// CHECK:STDOUT: %.loc27: = var_pattern %and_.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %and_.var: ref = var and_ -// CHECK:STDOUT: %and_: ref = bind_name and_, %and_.var +// CHECK:STDOUT: %and_: = bind_name and_, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %and_val.patt: bool = binding_pattern and_val +// CHECK:STDOUT: %.loc41_1: bool = var_pattern %and_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %and_val.var: ref bool = var and_val +// CHECK:STDOUT: %.loc41_14.1: type = splice_block %.loc41_14.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc41: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc41_14.2: type = value_of_initializer %bool.make_type.loc41 [template = bool] +// CHECK:STDOUT: %.loc41_14.3: type = converted %bool.make_type.loc41, %.loc41_14.2 [template = bool] +// CHECK:STDOUT: } // CHECK:STDOUT: %and_val: ref bool = bind_name and_val, %and_val.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %or_.patt: = binding_pattern or_ +// CHECK:STDOUT: %.loc53: = var_pattern %or_.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %or_.var: ref = var or_ -// CHECK:STDOUT: %or_: ref = bind_name or_, %or_.var +// CHECK:STDOUT: %or_: = bind_name or_, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %or_val.patt: bool = binding_pattern or_val +// CHECK:STDOUT: %.loc67_1: bool = var_pattern %or_val.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %or_val.var: ref bool = var or_val +// CHECK:STDOUT: %.loc67_13.1: type = splice_block %.loc67_13.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc67: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc67_13.2: type = value_of_initializer %bool.make_type.loc67 [template = bool] +// CHECK:STDOUT: %.loc67_13.3: type = converted %bool.make_type.loc67, %.loc67_13.2 [template = bool] +// CHECK:STDOUT: } // CHECK:STDOUT: %or_val: ref bool = bind_name or_val, %or_val.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon b/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon index 044768c4b675..4600adead174 100644 --- a/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_and_or_partial_constant.carbon @@ -48,9 +48,12 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: %PartialConstant.type: type = fn_type @PartialConstant [template] // CHECK:STDOUT: %PartialConstant: %PartialConstant.type = struct_value () [template] +// CHECK:STDOUT: %true: bool = bool_literal true [template] +// CHECK:STDOUT: %false: bool = bool_literal false [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -73,9 +76,9 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: } { // CHECK:STDOUT: %x.param: bool = value_param runtime_param0 // CHECK:STDOUT: %.loc4_23.1: type = splice_block %.loc4_23.3 [template = bool] { -// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc4_23.2: type = value_of_initializer %bool.make_type [template = bool] -// CHECK:STDOUT: %.loc4_23.3: type = converted %bool.make_type, %.loc4_23.2 [template = bool] +// CHECK:STDOUT: %bool.make_type.loc4: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc4_23.2: type = value_of_initializer %bool.make_type.loc4 [template = bool] +// CHECK:STDOUT: %.loc4_23.3: type = converted %bool.make_type.loc4, %.loc4_23.2 [template = bool] // CHECK:STDOUT: } // CHECK:STDOUT: %x: bool = bind_name x, %x.param // CHECK:STDOUT: } @@ -83,10 +86,81 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @PartialConstant(%x.param_patt: bool) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: = binding_pattern a +// CHECK:STDOUT: %.loc9_3: = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref = var a -// CHECK:STDOUT: %a: ref = bind_name a, %a.var +// CHECK:STDOUT: br !.loc9_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc9_13: +// CHECK:STDOUT: %true.loc9: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %false.loc9: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %true.loc9 br !and.rhs else br !and.result(%false.loc9) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs: +// CHECK:STDOUT: %x.ref.loc9: bool = name_ref x, %x +// CHECK:STDOUT: br !and.result(%x.ref.loc9) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result: +// CHECK:STDOUT: %.loc9_18: bool = block_arg !and.result +// CHECK:STDOUT: if %.loc9_18 br !if.expr.then.loc9 else br !if.expr.else.loc9 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc9: +// CHECK:STDOUT: %bool.make_type.loc9: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc9_29.1: type = value_of_initializer %bool.make_type.loc9 [template = bool] +// CHECK:STDOUT: %.loc9_29.2: type = converted %bool.make_type.loc9, %.loc9_29.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc9(%.loc9_29.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc9: +// CHECK:STDOUT: %.loc9_40: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc9_34: type = converted %.loc9_40, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc9(%.loc9_34) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc9: +// CHECK:STDOUT: %.loc9_10: type = block_arg !if.expr.result.loc9 +// CHECK:STDOUT: br !.loc9_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc9_7: +// CHECK:STDOUT: %a: = bind_name a, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: = binding_pattern b +// CHECK:STDOUT: %.loc14_3: = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref = var b -// CHECK:STDOUT: %b: ref = bind_name b, %b.var +// CHECK:STDOUT: br !.loc14_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc14_13: +// CHECK:STDOUT: %false.loc14: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %.loc14_19.1: bool = not %false.loc14 [template = constants.%true] +// CHECK:STDOUT: %true.loc14: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc14_19.1 br !or.rhs else br !or.result(%true.loc14) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs: +// CHECK:STDOUT: %x.ref.loc14: bool = name_ref x, %x +// CHECK:STDOUT: br !or.result(%x.ref.loc14) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result: +// CHECK:STDOUT: %.loc14_19.2: bool = block_arg !or.result +// CHECK:STDOUT: if %.loc14_19.2 br !if.expr.then.loc14 else br !if.expr.else.loc14 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc14: +// CHECK:STDOUT: %bool.make_type.loc14: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc14_29.1: type = value_of_initializer %bool.make_type.loc14 [template = bool] +// CHECK:STDOUT: %.loc14_29.2: type = converted %bool.make_type.loc14, %.loc14_29.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc14(%.loc14_29.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc14: +// CHECK:STDOUT: %.loc14_40: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc14_34: type = converted %.loc14_40, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc14(%.loc14_34) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc14: +// CHECK:STDOUT: %.loc14_10: type = block_arg !if.expr.result.loc14 +// CHECK:STDOUT: br !.loc14_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc14_7: +// CHECK:STDOUT: %b: = bind_name b, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -94,9 +168,12 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: %KnownValueButNonConstantCondition.type: type = fn_type @KnownValueButNonConstantCondition [template] // CHECK:STDOUT: %KnownValueButNonConstantCondition: %KnownValueButNonConstantCondition.type = struct_value () [template] +// CHECK:STDOUT: %false: bool = bool_literal false [template] +// CHECK:STDOUT: %true: bool = bool_literal true [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -119,9 +196,9 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: } { // CHECK:STDOUT: %x.param: bool = value_param runtime_param0 // CHECK:STDOUT: %.loc4_41.1: type = splice_block %.loc4_41.3 [template = bool] { -// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc4_41.2: type = value_of_initializer %bool.make_type [template = bool] -// CHECK:STDOUT: %.loc4_41.3: type = converted %bool.make_type, %.loc4_41.2 [template = bool] +// CHECK:STDOUT: %bool.make_type.loc4: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc4_41.2: type = value_of_initializer %bool.make_type.loc4 [template = bool] +// CHECK:STDOUT: %.loc4_41.3: type = converted %bool.make_type.loc4, %.loc4_41.2 [template = bool] // CHECK:STDOUT: } // CHECK:STDOUT: %x: bool = bind_name x, %x.param // CHECK:STDOUT: } @@ -129,10 +206,81 @@ fn KnownValueButNonConstantCondition(x: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @KnownValueButNonConstantCondition(%x.param_patt: bool) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: = binding_pattern c +// CHECK:STDOUT: %.loc11_3: = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref = var c -// CHECK:STDOUT: %c: ref = bind_name c, %c.var +// CHECK:STDOUT: br !.loc11_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc11_13: +// CHECK:STDOUT: %x.ref.loc11: bool = name_ref x, %x +// CHECK:STDOUT: %false.loc11_15: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: if %x.ref.loc11 br !and.rhs else br !and.result(%false.loc11_15) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.rhs: +// CHECK:STDOUT: %false.loc11_19: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: br !and.result(%false.loc11_19) +// CHECK:STDOUT: +// CHECK:STDOUT: !and.result: +// CHECK:STDOUT: %.loc11_15: bool = block_arg !and.result +// CHECK:STDOUT: if %.loc11_15 br !if.expr.then.loc11 else br !if.expr.else.loc11 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc11: +// CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc11_30.1: type = value_of_initializer %bool.make_type.loc11 [template = bool] +// CHECK:STDOUT: %.loc11_30.2: type = converted %bool.make_type.loc11, %.loc11_30.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc11(%.loc11_30.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc11: +// CHECK:STDOUT: %.loc11_41: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_35: type = converted %.loc11_41, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc11(%.loc11_35) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc11: +// CHECK:STDOUT: %.loc11_10: type = block_arg !if.expr.result.loc11 +// CHECK:STDOUT: br !.loc11_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc11_7: +// CHECK:STDOUT: %c: = bind_name c, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: = binding_pattern d +// CHECK:STDOUT: %.loc16_3: = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref = var d -// CHECK:STDOUT: %d: ref = bind_name d, %d.var +// CHECK:STDOUT: br !.loc16_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc16_13: +// CHECK:STDOUT: %x.ref.loc16: bool = name_ref x, %x +// CHECK:STDOUT: %.loc16_15.1: bool = not %x.ref.loc16 +// CHECK:STDOUT: %true.loc16_15: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc16_15.1 br !or.rhs else br !or.result(%true.loc16_15) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs: +// CHECK:STDOUT: %true.loc16_18: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: br !or.result(%true.loc16_18) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result: +// CHECK:STDOUT: %.loc16_15.2: bool = block_arg !or.result +// CHECK:STDOUT: if %.loc16_15.2 br !if.expr.then.loc16 else br !if.expr.else.loc16 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc16: +// CHECK:STDOUT: %bool.make_type.loc16: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc16_28.1: type = value_of_initializer %bool.make_type.loc16 [template = bool] +// CHECK:STDOUT: %.loc16_28.2: type = converted %bool.make_type.loc16, %.loc16_28.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc16(%.loc16_28.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc16: +// CHECK:STDOUT: %.loc16_39: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_33: type = converted %.loc16_39, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc16(%.loc16_33) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc16: +// CHECK:STDOUT: %.loc16_10: type = block_arg !if.expr.result.loc16 +// CHECK:STDOUT: br !.loc16_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc16_7: +// CHECK:STDOUT: %d: = bind_name d, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon b/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon index aa0bd2fcad92..bcfc901a037f 100644 --- a/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_assignment_to_non_assignable.carbon @@ -162,15 +162,23 @@ fn Main() { // CHECK:STDOUT: assign %.loc28_8.1, %.loc28_10 // CHECK:STDOUT: %tuple.loc28: %tuple.type.f94 = tuple_value (%int_1.loc28, %int_2.loc28) [template = constants.%tuple.ad8] // CHECK:STDOUT: %.loc28_8.2: %tuple.type.f94 = converted %.loc28_8.1, %tuple.loc28 [template = constants.%tuple.ad8] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: %.loc29_3.1: %i32 = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %i32 = var n -// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc29: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc29: = bound_method %int_0, %impl.elem0.loc29 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc29: = specific_function %Convert.bound.loc29, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc29: init %i32 = call %Convert.specific_fn.loc29(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc29: init %i32 = converted %int_0, %int.convert_checked.loc29 [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %n.var, %.loc29 +// CHECK:STDOUT: %.loc29_3.2: init %i32 = converted %int_0, %int.convert_checked.loc29 [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %n.var, %.loc29_3.2 +// CHECK:STDOUT: %.loc29_10: type = splice_block %i32.loc29 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %n.ref.loc34_4: ref %i32 = name_ref n, %n // CHECK:STDOUT: %n.ref.loc34_7: ref %i32 = name_ref n, %n // CHECK:STDOUT: %.loc34_8.1: %tuple.type.d07 = tuple_literal (%n.ref.loc34_4, %n.ref.loc34_7) @@ -253,7 +261,15 @@ fn Main() { // CHECK:STDOUT: %int.convert_checked.loc49_27: init %i32 = call %Convert.specific_fn.loc49_27(%int_3.loc49) [template = constants.%int_3.822] // CHECK:STDOUT: %.loc49_27: init %i32 = converted %int_3.loc49, %int.convert_checked.loc49_27 [template = constants.%int_3.822] // CHECK:STDOUT: assign %.loc49_4, %.loc49_27 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc52_3: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc52_10: type = splice_block %i32.loc52 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc52: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc52: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %true.loc57: bool = bool_literal true [template = constants.%true] // CHECK:STDOUT: if %true.loc57 br !if.expr.then.loc57 else br !if.expr.else.loc57 diff --git a/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon b/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon index 04850f00cb64..84cfaa0c2461 100644 --- a/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_redundant_compound_access.carbon @@ -89,15 +89,23 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc14_3.1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a -// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_3, %impl.elem0 [template = constants.%Convert.bound.b30] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_3) [template = constants.%int_3.822] -// CHECK:STDOUT: %.loc14: init %i32 = converted %int_3, %int.convert_checked [template = constants.%int_3.822] -// CHECK:STDOUT: assign %a.var, %.loc14 +// CHECK:STDOUT: %.loc14_3.2: init %i32 = converted %int_3, %int.convert_checked [template = constants.%int_3.822] +// CHECK:STDOUT: assign %a.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %a.ref.loc19_3: ref %i32 = name_ref a, %a // CHECK:STDOUT: %a.ref.loc19_7: ref %i32 = name_ref a, %a // CHECK:STDOUT: %a.ref.loc19_10: ref %i32 = name_ref a, %a diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon index 905e10b379d2..22f01816007d 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch.carbon @@ -24,6 +24,8 @@ fn Main() { // CHECK:STDOUT: constants { // CHECK:STDOUT: %Main.type: type = fn_type @Main [template] // CHECK:STDOUT: %Main: %Main.type = struct_value () [template] +// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -47,12 +49,21 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: bool = binding_pattern x +// CHECK:STDOUT: %.loc19_3: bool = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref bool = var x -// CHECK:STDOUT: %x: ref bool = bind_name x, %x.var // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [template = constants.%int_12] // CHECK:STDOUT: %.loc19_17.1: bool = converted %int_12, [template = ] // CHECK:STDOUT: %.loc19_17.2: = not [template = ] // CHECK:STDOUT: assign %x.var, +// CHECK:STDOUT: %.loc19_10.1: type = splice_block %.loc19_10.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc19_10.2: type = value_of_initializer %bool.make_type [template = bool] +// CHECK:STDOUT: %.loc19_10.3: type = converted %bool.make_type, %.loc19_10.2 [template = bool] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref bool = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon index 851bed87236a..afb8f98a31dc 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_assignment.carbon @@ -58,15 +58,23 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a -// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_3, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_3) [template = constants.%int_3.822] -// CHECK:STDOUT: %.loc12: init %i32 = converted %int_3, %int.convert_checked [template = constants.%int_3.822] -// CHECK:STDOUT: assign %a.var, %.loc12 +// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_3, %int.convert_checked [template = constants.%int_3.822] +// CHECK:STDOUT: assign %a.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %i32 = name_ref a, %a // CHECK:STDOUT: %float: f64 = float_literal 5.6000000000000005 [template = constants.%float] // CHECK:STDOUT: %.loc20: %i32 = converted %float, [template = ] diff --git a/toolchain/check/testdata/operators/builtin/or.carbon b/toolchain/check/testdata/operators/builtin/or.carbon index b0d8a8ab6bd3..79299b89cb15 100644 --- a/toolchain/check/testdata/operators/builtin/or.carbon +++ b/toolchain/check/testdata/operators/builtin/or.carbon @@ -41,6 +41,7 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: %Or: %Or.type = struct_value () [template] // CHECK:STDOUT: %Constant.type: type = fn_type @Constant [template] // CHECK:STDOUT: %Constant: %Constant.type = struct_value () [template] +// CHECK:STDOUT: %false: bool = bool_literal false [template] // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template] // CHECK:STDOUT: %PartialConstant.type: type = fn_type @PartialConstant [template] // CHECK:STDOUT: %PartialConstant: %PartialConstant.type = struct_value () [template] @@ -101,9 +102,9 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: } { // CHECK:STDOUT: %x.param: bool = value_param runtime_param0 // CHECK:STDOUT: %.loc25_23.1: type = splice_block %.loc25_23.3 [template = bool] { -// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc25_23.2: type = value_of_initializer %bool.make_type [template = bool] -// CHECK:STDOUT: %.loc25_23.3: type = converted %bool.make_type, %.loc25_23.2 [template = bool] +// CHECK:STDOUT: %bool.make_type.loc25: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc25_23.2: type = value_of_initializer %bool.make_type.loc25 [template = bool] +// CHECK:STDOUT: %.loc25_23.3: type = converted %bool.make_type.loc25, %.loc25_23.2 [template = bool] // CHECK:STDOUT: } // CHECK:STDOUT: %x: bool = bind_name x, %x.param // CHECK:STDOUT: } @@ -145,33 +146,213 @@ fn PartialConstant(x: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Constant() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: bool = binding_pattern a +// CHECK:STDOUT: %.loc19_3: bool = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref bool = var a +// CHECK:STDOUT: %true.loc19_46: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: assign %a.var, %true.loc19_46 +// CHECK:STDOUT: br !.loc19_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc19_13: +// CHECK:STDOUT: %true.loc19_13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %.loc19_18.1: bool = not %true.loc19_13 [template = constants.%false] +// CHECK:STDOUT: %true.loc19_18: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc19_18.1 br !or.rhs.loc19 else br !or.result.loc19(%true.loc19_18) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs.loc19: +// CHECK:STDOUT: %true.loc19_21: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: br !or.result.loc19(%true.loc19_21) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result.loc19: +// CHECK:STDOUT: %.loc19_18.2: bool = block_arg !or.result.loc19 [template = constants.%true] +// CHECK:STDOUT: if %.loc19_18.2 br !if.expr.then.loc19 else br !if.expr.else.loc19 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc19: +// CHECK:STDOUT: %bool.make_type.loc19: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc19_31.1: type = value_of_initializer %bool.make_type.loc19 [template = bool] +// CHECK:STDOUT: %.loc19_31.2: type = converted %bool.make_type.loc19, %.loc19_31.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_31.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc19: +// CHECK:STDOUT: %.loc19_42: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_36: type = converted %.loc19_42, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_36) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc19: +// CHECK:STDOUT: %.loc19_10: type = block_arg !if.expr.result.loc19 [template = bool] +// CHECK:STDOUT: br !.loc19_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc19_7: // CHECK:STDOUT: %a: ref bool = bind_name a, %a.var -// CHECK:STDOUT: %true.loc19: bool = bool_literal true [template = constants.%true] -// CHECK:STDOUT: assign %a.var, %true.loc19 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: bool = binding_pattern b +// CHECK:STDOUT: %.loc20_3: bool = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref bool = var b +// CHECK:STDOUT: %true.loc20_47: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: assign %b.var, %true.loc20_47 +// CHECK:STDOUT: br !.loc20_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc20_13: +// CHECK:STDOUT: %true.loc20_13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %.loc20_18.1: bool = not %true.loc20_13 [template = constants.%false] +// CHECK:STDOUT: %true.loc20_18: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc20_18.1 br !or.rhs.loc20 else br !or.result.loc20(%true.loc20_18) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs.loc20: +// CHECK:STDOUT: %false.loc20: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: br !or.result.loc20(%false.loc20) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result.loc20: +// CHECK:STDOUT: %.loc20_18.2: bool = block_arg !or.result.loc20 [template = constants.%true] +// CHECK:STDOUT: if %.loc20_18.2 br !if.expr.then.loc20 else br !if.expr.else.loc20 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc20: +// CHECK:STDOUT: %bool.make_type.loc20: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc20_32.1: type = value_of_initializer %bool.make_type.loc20 [template = bool] +// CHECK:STDOUT: %.loc20_32.2: type = converted %bool.make_type.loc20, %.loc20_32.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_32.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc20: +// CHECK:STDOUT: %.loc20_43: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc20_37: type = converted %.loc20_43, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_37) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc20: +// CHECK:STDOUT: %.loc20_10: type = block_arg !if.expr.result.loc20 [template = bool] +// CHECK:STDOUT: br !.loc20_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc20_7: // CHECK:STDOUT: %b: ref bool = bind_name b, %b.var -// CHECK:STDOUT: %true.loc20: bool = bool_literal true [template = constants.%true] -// CHECK:STDOUT: assign %b.var, %true.loc20 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: bool = binding_pattern c +// CHECK:STDOUT: %.loc21_3: bool = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref bool = var c +// CHECK:STDOUT: %true.loc21_47: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: assign %c.var, %true.loc21_47 +// CHECK:STDOUT: br !.loc21_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc21_13: +// CHECK:STDOUT: %false.loc21: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %.loc21_19.1: bool = not %false.loc21 [template = constants.%true] +// CHECK:STDOUT: %true.loc21_19: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc21_19.1 br !or.rhs.loc21 else br !or.result.loc21(%true.loc21_19) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs.loc21: +// CHECK:STDOUT: %true.loc21_22: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: br !or.result.loc21(%true.loc21_22) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result.loc21: +// CHECK:STDOUT: %.loc21_19.2: bool = block_arg !or.result.loc21 [template = constants.%true] +// CHECK:STDOUT: if %.loc21_19.2 br !if.expr.then.loc21 else br !if.expr.else.loc21 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc21: +// CHECK:STDOUT: %bool.make_type.loc21: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc21_32.1: type = value_of_initializer %bool.make_type.loc21 [template = bool] +// CHECK:STDOUT: %.loc21_32.2: type = converted %bool.make_type.loc21, %.loc21_32.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc21(%.loc21_32.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc21: +// CHECK:STDOUT: %.loc21_43: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc21_37: type = converted %.loc21_43, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc21(%.loc21_37) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc21: +// CHECK:STDOUT: %.loc21_10: type = block_arg !if.expr.result.loc21 [template = bool] +// CHECK:STDOUT: br !.loc21_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc21_7: // CHECK:STDOUT: %c: ref bool = bind_name c, %c.var -// CHECK:STDOUT: %true.loc21: bool = bool_literal true [template = constants.%true] -// CHECK:STDOUT: assign %c.var, %true.loc21 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc22_3.1: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d -// CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var // CHECK:STDOUT: %.loc22_49.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc22_49.2: init %empty_tuple.type = tuple_init () to %d.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc22_50: init %empty_tuple.type = converted %.loc22_49.1, %.loc22_49.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %d.var, %.loc22_50 +// CHECK:STDOUT: %.loc22_3.2: init %empty_tuple.type = converted %.loc22_49.1, %.loc22_49.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %d.var, %.loc22_3.2 +// CHECK:STDOUT: br !.loc22_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc22_13: +// CHECK:STDOUT: %false.loc22_13: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %.loc22_19.1: bool = not %false.loc22_13 [template = constants.%true] +// CHECK:STDOUT: %true.loc22: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc22_19.1 br !or.rhs.loc22 else br !or.result.loc22(%true.loc22) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs.loc22: +// CHECK:STDOUT: %false.loc22_22: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: br !or.result.loc22(%false.loc22_22) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result.loc22: +// CHECK:STDOUT: %.loc22_19.2: bool = block_arg !or.result.loc22 [template = constants.%false] +// CHECK:STDOUT: if %.loc22_19.2 br !if.expr.then.loc22 else br !if.expr.else.loc22 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc22: +// CHECK:STDOUT: %bool.make_type.loc22: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc22_33.1: type = value_of_initializer %bool.make_type.loc22 [template = bool] +// CHECK:STDOUT: %.loc22_33.2: type = converted %bool.make_type.loc22, %.loc22_33.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc22(%.loc22_33.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc22: +// CHECK:STDOUT: %.loc22_44: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc22_38: type = converted %.loc22_44, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc22(%.loc22_38) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc22: +// CHECK:STDOUT: %.loc22_10: type = block_arg !if.expr.result.loc22 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !.loc22_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc22_7: +// CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @PartialConstant(%x.param_patt: bool) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: bool = binding_pattern a +// CHECK:STDOUT: %.loc26_3: bool = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref bool = var a +// CHECK:STDOUT: %true.loc26_43: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: assign %a.var, %true.loc26_43 +// CHECK:STDOUT: br !.loc26_13 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc26_13: +// CHECK:STDOUT: %true.loc26_13: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %.loc26_18.1: bool = not %true.loc26_13 [template = constants.%false] +// CHECK:STDOUT: %true.loc26_18: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: if %.loc26_18.1 br !or.rhs else br !or.result(%true.loc26_18) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.rhs: +// CHECK:STDOUT: %x.ref: bool = name_ref x, %x +// CHECK:STDOUT: br !or.result(%x.ref) +// CHECK:STDOUT: +// CHECK:STDOUT: !or.result: +// CHECK:STDOUT: %.loc26_18.2: bool = block_arg !or.result [template = constants.%true] +// CHECK:STDOUT: if %.loc26_18.2 br !if.expr.then else br !if.expr.else +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then: +// CHECK:STDOUT: %bool.make_type.loc26: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc26_28.1: type = value_of_initializer %bool.make_type.loc26 [template = bool] +// CHECK:STDOUT: %.loc26_28.2: type = converted %bool.make_type.loc26, %.loc26_28.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result(%.loc26_28.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else: +// CHECK:STDOUT: %.loc26_39: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc26_33: type = converted %.loc26_39, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result(%.loc26_33) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result: +// CHECK:STDOUT: %.loc26_10: type = block_arg !if.expr.result [template = bool] +// CHECK:STDOUT: br !.loc26_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc26_7: // CHECK:STDOUT: %a: ref bool = bind_name a, %a.var -// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] -// CHECK:STDOUT: assign %a.var, %true // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/builtin/unary_op.carbon b/toolchain/check/testdata/operators/builtin/unary_op.carbon index a472840949a2..16f6af713b72 100644 --- a/toolchain/check/testdata/operators/builtin/unary_op.carbon +++ b/toolchain/check/testdata/operators/builtin/unary_op.carbon @@ -47,8 +47,8 @@ fn Constant() { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Not = %Not.decl -// CHECK:STDOUT: .not_true = @__global_init.%not_true -// CHECK:STDOUT: .not_false = @__global_init.%not_false +// CHECK:STDOUT: .not_true = %not_true +// CHECK:STDOUT: .not_false = %not_false // CHECK:STDOUT: .Constant = %Constant.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core @@ -71,6 +71,24 @@ fn Constant() { // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param1 // CHECK:STDOUT: %return: ref bool = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %not_true.patt: bool = binding_pattern not_true +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15_15.1: type = splice_block %.loc15_15.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc15: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc15_15.2: type = value_of_initializer %bool.make_type.loc15 [template = bool] +// CHECK:STDOUT: %.loc15_15.3: type = converted %bool.make_type.loc15, %.loc15_15.2 [template = bool] +// CHECK:STDOUT: } +// CHECK:STDOUT: %not_true: bool = bind_name not_true, @__global_init.%.loc15 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %not_false.patt: bool = binding_pattern not_false +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc16_16.1: type = splice_block %.loc16_16.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc16: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc16_16.2: type = value_of_initializer %bool.make_type.loc16 [template = bool] +// CHECK:STDOUT: %.loc16_16.3: type = converted %bool.make_type.loc16, %.loc16_16.2 [template = bool] +// CHECK:STDOUT: } +// CHECK:STDOUT: %not_false: bool = bind_name not_false, @__global_init.%.loc16 // CHECK:STDOUT: %Constant.decl: %Constant.type = fn_decl @Constant [template = constants.%Constant] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -83,16 +101,70 @@ fn Constant() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Constant() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc19_3.1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a -// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: %.loc19_43.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc19_43.2: init %empty_tuple.type = tuple_init () to %a.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc19_44: init %empty_tuple.type = converted %.loc19_43.1, %.loc19_43.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %a.var, %.loc19_44 +// CHECK:STDOUT: %.loc19_3.2: init %empty_tuple.type = converted %.loc19_43.1, %.loc19_43.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %a.var, %.loc19_3.2 +// CHECK:STDOUT: br !.loc19_17 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc19_17: +// CHECK:STDOUT: %true.loc19: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: %.loc19_13: bool = not %true.loc19 [template = constants.%false] +// CHECK:STDOUT: if %.loc19_13 br !if.expr.then.loc19 else br !if.expr.else.loc19 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc19: +// CHECK:STDOUT: %bool.make_type.loc19: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc19_27.1: type = value_of_initializer %bool.make_type.loc19 [template = bool] +// CHECK:STDOUT: %.loc19_27.2: type = converted %bool.make_type.loc19, %.loc19_27.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_27.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc19: +// CHECK:STDOUT: %.loc19_38: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_32: type = converted %.loc19_38, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_32) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc19: +// CHECK:STDOUT: %.loc19_10: type = block_arg !if.expr.result.loc19 [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !.loc19_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc19_7: +// CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: bool = binding_pattern b +// CHECK:STDOUT: %.loc20_3: bool = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref bool = var b +// CHECK:STDOUT: %true.loc20: bool = bool_literal true [template = constants.%true] +// CHECK:STDOUT: assign %b.var, %true.loc20 +// CHECK:STDOUT: br !.loc20_17 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc20_17: +// CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] +// CHECK:STDOUT: %.loc20_13: bool = not %false [template = constants.%true] +// CHECK:STDOUT: if %.loc20_13 br !if.expr.then.loc20 else br !if.expr.else.loc20 +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.then.loc20: +// CHECK:STDOUT: %bool.make_type.loc20: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc20_28.1: type = value_of_initializer %bool.make_type.loc20 [template = bool] +// CHECK:STDOUT: %.loc20_28.2: type = converted %bool.make_type.loc20, %.loc20_28.1 [template = bool] +// CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_28.2) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.else.loc20: +// CHECK:STDOUT: %.loc20_39: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc20_33: type = converted %.loc20_39, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_33) +// CHECK:STDOUT: +// CHECK:STDOUT: !if.expr.result.loc20: +// CHECK:STDOUT: %.loc20_10: type = block_arg !if.expr.result.loc20 [template = bool] +// CHECK:STDOUT: br !.loc20_7 +// CHECK:STDOUT: +// CHECK:STDOUT: !.loc20_7: // CHECK:STDOUT: %b: ref bool = bind_name b, %b.var -// CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] -// CHECK:STDOUT: assign %b.var, %true // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -100,10 +172,8 @@ fn Constant() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] // CHECK:STDOUT: %.loc15: bool = not %true [template = constants.%false] -// CHECK:STDOUT: %not_true: bool = bind_name not_true, %.loc15 // CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false] // CHECK:STDOUT: %.loc16: bool = not %false [template = constants.%true] -// CHECK:STDOUT: %not_false: bool = bind_name not_false, %.loc16 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/dec.carbon b/toolchain/check/testdata/operators/overloaded/dec.carbon index 57b150c862a8..81f31f640da4 100644 --- a/toolchain/check/testdata/operators/overloaded/dec.carbon +++ b/toolchain/check/testdata/operators/overloaded/dec.carbon @@ -95,12 +95,17 @@ fn TestOp() { // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc22_3.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %.loc22_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc22_15.2: init %C = class_init (), %c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc22_16: init %C = converted %.loc22_15.1, %.loc22_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign %c.var, %.loc22_16 +// CHECK:STDOUT: %.loc22_3.2: init %C = converted %.loc22_15.1, %.loc22_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign %c.var, %.loc22_3.2 +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c // CHECK:STDOUT: %impl.elem0: %Op.type.633 = impl_witness_access constants.%impl_witness, element0 [template = constants.%Op.cf9] // CHECK:STDOUT: %Op.bound: = bound_method %c.ref, %impl.elem0 diff --git a/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon b/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon index d79cb154b5f5..f4e6084620b2 100644 --- a/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon +++ b/toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon @@ -114,7 +114,7 @@ fn TestRef(b: C) { // CHECK:STDOUT: %b.param_patt: %C = value_param_pattern %b.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %b.param: %C = value_param runtime_param0 -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc31: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %b: %C = bind_name b, %b.param // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -139,12 +139,17 @@ fn TestRef(b: C) { // CHECK:STDOUT: // CHECK:STDOUT: fn @TestRef(%b.param_patt: %C) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C = binding_pattern a +// CHECK:STDOUT: %.loc32_3.1: %C = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C = var a -// CHECK:STDOUT: %a: ref %C = bind_name a, %a.var // CHECK:STDOUT: %.loc32_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc32_15.2: init %C = class_init (), %a.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc32_16: init %C = converted %.loc32_15.1, %.loc32_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign %a.var, %.loc32_16 +// CHECK:STDOUT: %.loc32_3.2: init %C = converted %.loc32_15.1, %.loc32_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign %a.var, %.loc32_3.2 +// CHECK:STDOUT: %C.ref.loc32: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %a: ref %C = bind_name a, %a.var // CHECK:STDOUT: %a.ref.loc37: ref %C = name_ref a, %a // CHECK:STDOUT: %b.ref: %C = name_ref b, %b // CHECK:STDOUT: %a.ref.loc42: ref %C = name_ref a, %a diff --git a/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon b/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon index 828f0c4710e0..1b754b53c7a1 100644 --- a/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon +++ b/toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon @@ -215,12 +215,17 @@ fn TestAssign(b: D) { // CHECK:STDOUT: // CHECK:STDOUT: fn @TestAssign(%b.param_patt: %D) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %C = binding_pattern a +// CHECK:STDOUT: %.loc38_3.1: %C = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %C = var a -// CHECK:STDOUT: %a: ref %C = bind_name a, %a.var // CHECK:STDOUT: %.loc38_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc38_15.2: init %C = class_init (), %a.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc38_16: init %C = converted %.loc38_15.1, %.loc38_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign %a.var, %.loc38_16 +// CHECK:STDOUT: %.loc38_3.2: init %C = converted %.loc38_15.1, %.loc38_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign %a.var, %.loc38_3.2 +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %a: ref %C = bind_name a, %a.var // CHECK:STDOUT: %a.ref: ref %C = name_ref a, %a // CHECK:STDOUT: %b.ref: %D = name_ref b, %b // CHECK:STDOUT: %impl.elem0: %Op.type.421 = impl_witness_access constants.%impl_witness.95d, element0 [template = constants.%Op.d8e] diff --git a/toolchain/check/testdata/operators/overloaded/implicit_as.carbon b/toolchain/check/testdata/operators/overloaded/implicit_as.carbon index 3fd4404f46ab..bddc7555a707 100644 --- a/toolchain/check/testdata/operators/overloaded/implicit_as.carbon +++ b/toolchain/check/testdata/operators/overloaded/implicit_as.carbon @@ -189,7 +189,11 @@ fn Test() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @X { -// CHECK:STDOUT: %.loc12: %X.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc12_8: %X.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %X.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %X.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type.54b] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -208,7 +212,7 @@ fn Test() { // CHECK:STDOUT: fn @Convert.3[%self.param_patt: %X]() -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %X = name_ref self, %self -// CHECK:STDOUT: %n.ref: %X.elem = name_ref n, @X.%.loc12 [template = @X.%.loc12] +// CHECK:STDOUT: %n.ref: %X.elem = name_ref n, @X.%.loc12_8 [template = @X.%.loc12_8] // CHECK:STDOUT: %.loc20_45.1: ref %i32 = class_element_access %self.ref, element0 // CHECK:STDOUT: %.loc20_45.2: %i32 = bind_value %.loc20_45.1 // CHECK:STDOUT: return %.loc20_45.2 diff --git a/toolchain/check/testdata/operators/overloaded/inc.carbon b/toolchain/check/testdata/operators/overloaded/inc.carbon index 3373b4920660..3c77ca730168 100644 --- a/toolchain/check/testdata/operators/overloaded/inc.carbon +++ b/toolchain/check/testdata/operators/overloaded/inc.carbon @@ -95,12 +95,17 @@ fn TestOp() { // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc22_3.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c -// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %.loc22_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc22_15.2: init %C = class_init (), %c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc22_16: init %C = converted %.loc22_15.1, %.loc22_15.2 [template = constants.%C.val] -// CHECK:STDOUT: assign %c.var, %.loc22_16 +// CHECK:STDOUT: %.loc22_3.2: init %C = converted %.loc22_15.1, %.loc22_15.2 [template = constants.%C.val] +// CHECK:STDOUT: assign %c.var, %.loc22_3.2 +// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c // CHECK:STDOUT: %impl.elem0: %Op.type.e3a = impl_witness_access constants.%impl_witness, element0 [template = constants.%Op.0c9] // CHECK:STDOUT: %Op.bound: = bound_method %c.ref, %impl.elem0 diff --git a/toolchain/check/testdata/operators/overloaded/index.carbon b/toolchain/check/testdata/operators/overloaded/index.carbon index 573c14bf639f..8a2acc484e7a 100644 --- a/toolchain/check/testdata/operators/overloaded/index.carbon +++ b/toolchain/check/testdata/operators/overloaded/index.carbon @@ -112,9 +112,9 @@ let x: i32 = c[0]; // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .ElementType = %ElementType.decl // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl -// CHECK:STDOUT: .s = @__global_init.%s -// CHECK:STDOUT: .c = @__global_init.%c -// CHECK:STDOUT: .x = @__global_init.%x +// CHECK:STDOUT: .s = %s +// CHECK:STDOUT: .c = %c +// CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} @@ -129,6 +129,30 @@ let x: i32 = c[0]; // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [template = constants.%IndexWith.type.e80] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness (@impl.%At.decl) [template = constants.%impl_witness] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %SubscriptType.8ee = binding_pattern s +// CHECK:STDOUT: } +// CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, %SubscriptType.decl [template = constants.%SubscriptType.8ee] +// CHECK:STDOUT: %.loc14_25.1: ref %SubscriptType.8ee = temporary_storage +// CHECK:STDOUT: %.loc14_25.2: init %SubscriptType.8ee = class_init (), %.loc14_25.1 [template = constants.%SubscriptType.val] +// CHECK:STDOUT: %.loc14_25.3: ref %SubscriptType.8ee = temporary %.loc14_25.1, %.loc14_25.2 +// CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.8ee = converted @__global_init.%.loc14, %.loc14_25.3 +// CHECK:STDOUT: %s: ref %SubscriptType.8ee = bind_name s, %.loc14_25.4 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc15_13.1: ref %C = temporary_storage +// CHECK:STDOUT: %.loc15_13.2: init %C = class_init (), %.loc15_13.1 [template = constants.%C.val] +// CHECK:STDOUT: %.loc15_13.3: ref %C = temporary %.loc15_13.1, %.loc15_13.2 +// CHECK:STDOUT: %.loc15_13.4: ref %C = converted @__global_init.%.loc15, %.loc15_13.3 +// CHECK:STDOUT: %c: ref %C = bind_name c, %.loc15_13.4 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %ElementType.e6b = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.e6b] +// CHECK:STDOUT: %.loc16: ref %ElementType.e6b = temporary @__global_init.%.loc16_25, @__global_init.%At.call +// CHECK:STDOUT: %x: ref %ElementType.e6b = bind_name x, %.loc16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type { @@ -181,29 +205,16 @@ let x: i32 = c[0]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc14_25.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc14_25.2: ref %SubscriptType.8ee = temporary_storage -// CHECK:STDOUT: %.loc14_25.3: init %SubscriptType.8ee = class_init (), %.loc14_25.2 [template = constants.%SubscriptType.val] -// CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.8ee = temporary %.loc14_25.2, %.loc14_25.3 -// CHECK:STDOUT: %.loc14_26.1: ref %SubscriptType.8ee = converted %.loc14_25.1, %.loc14_25.4 -// CHECK:STDOUT: %.loc14_26.2: %SubscriptType.8ee = bind_value %.loc14_26.1 -// CHECK:STDOUT: %s: %SubscriptType.8ee = bind_name s, %.loc14_26.2 -// CHECK:STDOUT: %.loc15_13.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc15_13.2: ref %C = temporary_storage -// CHECK:STDOUT: %.loc15_13.3: init %C = class_init (), %.loc15_13.2 [template = constants.%C.val] -// CHECK:STDOUT: %.loc15_13.4: ref %C = temporary %.loc15_13.2, %.loc15_13.3 -// CHECK:STDOUT: %.loc15_14.1: ref %C = converted %.loc15_13.1, %.loc15_13.4 -// CHECK:STDOUT: %.loc15_14.2: %C = bind_value %.loc15_14.1 -// CHECK:STDOUT: %c: %C = bind_name c, %.loc15_14.2 -// CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %s.ref: %SubscriptType.8ee = name_ref s, %s +// CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc15: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c +// CHECK:STDOUT: %s.ref: ref %SubscriptType.8ee = name_ref s, file.%s +// CHECK:STDOUT: %.loc16_24: %SubscriptType.8ee = bind_value %s.ref // CHECK:STDOUT: %impl.elem0: %At.type.b3f = impl_witness_access constants.%impl_witness, element0 [template = constants.%At.d43] // CHECK:STDOUT: %At.bound: = bound_method %c.ref, %impl.elem0 -// CHECK:STDOUT: %.loc16_25.1: ref %ElementType.e6b = temporary_storage -// CHECK:STDOUT: %At.call: init %ElementType.e6b = call %At.bound(%c.ref, %s.ref) to %.loc16_25.1 -// CHECK:STDOUT: %.loc16_25.2: ref %ElementType.e6b = temporary %.loc16_25.1, %At.call -// CHECK:STDOUT: %.loc16_25.3: %ElementType.e6b = bind_value %.loc16_25.2 -// CHECK:STDOUT: %x: %ElementType.e6b = bind_name x, %.loc16_25.3 +// CHECK:STDOUT: %.loc16_25: ref %ElementType.e6b = temporary_storage +// CHECK:STDOUT: %.loc16_22: %C = bind_value %c.ref +// CHECK:STDOUT: %At.call: init %ElementType.e6b = call %At.bound(%.loc16_22, %.loc16_24) to %.loc16_25 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -255,8 +266,8 @@ let x: i32 = c[0]; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .s = @__global_init.%s -// CHECK:STDOUT: .e = @__global_init.%e +// CHECK:STDOUT: .s = %s +// CHECK:STDOUT: .e = %e // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: impl_decl @impl.1 [template] {} { @@ -275,6 +286,42 @@ let x: i32 = c[0]; // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%i32, constants.%i32)> [template = constants.%IndexWith.type.917] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness (@impl.1.%At.decl) [template = constants.%impl_witness.123] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %tuple.type.d07 = binding_pattern s +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc10_17.1: type = splice_block %.loc10_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc10_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc10_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc10_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc10_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc10_17.2: %tuple.type.24b = tuple_literal (%i32.loc10_9, %i32.loc10_14) +// CHECK:STDOUT: %.loc10_17.3: type = converted %.loc10_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc10_26.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc10_26.1: = bound_method @__global_init.%int_1, %impl.elem0.loc10_26.1 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc10_26.1: = specific_function %Convert.bound.loc10_26.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc10_26.1: init %i32 = call %Convert.specific_fn.loc10_26.1(@__global_init.%int_1) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc10_26.1: %i32 = value_of_initializer %int.convert_checked.loc10_26.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc10_26.2: %i32 = converted @__global_init.%int_1, %.loc10_26.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc10_26.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc10_26.2: = bound_method @__global_init.%int_5, %impl.elem0.loc10_26.2 [template = constants.%Convert.bound.4e6] +// CHECK:STDOUT: %Convert.specific_fn.loc10_26.2: = specific_function %Convert.bound.loc10_26.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9] +// CHECK:STDOUT: %int.convert_checked.loc10_26.2: init %i32 = call %Convert.specific_fn.loc10_26.2(@__global_init.%int_5) [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc10_26.3: %i32 = value_of_initializer %int.convert_checked.loc10_26.2 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %.loc10_26.4: %i32 = converted @__global_init.%int_5, %.loc10_26.3 [template = constants.%int_5.0f6] +// CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%.loc10_26.2, %.loc10_26.4) [template = constants.%tuple] +// CHECK:STDOUT: %.loc10_26.5: %tuple.type.d07 = converted @__global_init.%.loc10, %tuple [template = constants.%tuple] +// CHECK:STDOUT: %s: %tuple.type.d07 = bind_name s, %.loc10_26.5 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %i32 = binding_pattern e +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11_8: type = splice_block %i32.loc11 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11_17.1: ref %i32 = temporary_storage +// CHECK:STDOUT: %.loc11_17.2: ref %i32 = temporary %.loc11_17.1, @__global_init.%At.call +// CHECK:STDOUT: %e: ref %i32 = bind_name e, %.loc11_17.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.1: %.loc4_15.2 as %IndexWith.type { @@ -318,36 +365,18 @@ let x: i32 = c[0]; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] -// CHECK:STDOUT: %.loc10_26.1: %tuple.type.f94 = tuple_literal (%int_1, %int_5) -// CHECK:STDOUT: %impl.elem0.loc10_26.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc10_26.1: = bound_method %int_1, %impl.elem0.loc10_26.1 [template = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %Convert.specific_fn.loc10_26.1: = specific_function %Convert.bound.loc10_26.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc10_26.1: init %i32 = call %Convert.specific_fn.loc10_26.1(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc10_26.2: %i32 = value_of_initializer %int.convert_checked.loc10_26.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc10_26.3: %i32 = converted %int_1, %.loc10_26.2 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc10_26.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc10_26.2: = bound_method %int_5, %impl.elem0.loc10_26.2 [template = constants.%Convert.bound.4e6] -// CHECK:STDOUT: %Convert.specific_fn.loc10_26.2: = specific_function %Convert.bound.loc10_26.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9] -// CHECK:STDOUT: %int.convert_checked.loc10_26.2: init %i32 = call %Convert.specific_fn.loc10_26.2(%int_5) [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc10_26.4: %i32 = value_of_initializer %int.convert_checked.loc10_26.2 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %.loc10_26.5: %i32 = converted %int_5, %.loc10_26.4 [template = constants.%int_5.0f6] -// CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%.loc10_26.3, %.loc10_26.5) [template = constants.%tuple] -// CHECK:STDOUT: %.loc10_27: %tuple.type.d07 = converted %.loc10_26.1, %tuple [template = constants.%tuple] -// CHECK:STDOUT: %s: %tuple.type.d07 = bind_name s, %.loc10_27 -// CHECK:STDOUT: %s.ref: %tuple.type.d07 = name_ref s, %s +// CHECK:STDOUT: %.loc10: %tuple.type.f94 = tuple_literal (%int_1, %int_5) +// CHECK:STDOUT: %s.ref: %tuple.type.d07 = name_ref s, file.%s // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc11_17.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11: = bound_method %int_0, %impl.elem0.loc11_17.1 [template = constants.%Convert.bound.d04] -// CHECK:STDOUT: %Convert.specific_fn.loc11: = specific_function %Convert.bound.loc11, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] -// CHECK:STDOUT: %int.convert_checked.loc11: init %i32 = call %Convert.specific_fn.loc11(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc11_17.1: %i32 = value_of_initializer %int.convert_checked.loc11 [template = constants.%int_0.6a9] +// CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0.loc11_17.1 [template = constants.%Convert.bound.d04] +// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] +// CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] +// CHECK:STDOUT: %.loc11_17.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc11_17.2: %i32 = converted %int_0, %.loc11_17.1 [template = constants.%int_0.6a9] // CHECK:STDOUT: %impl.elem0.loc11_17.2: %At.type.d77 = impl_witness_access constants.%impl_witness.123, element0 [template = constants.%At.642] // CHECK:STDOUT: %At.bound: = bound_method %s.ref, %impl.elem0.loc11_17.2 // CHECK:STDOUT: %At.call: init %i32 = call %At.bound(%s.ref, %.loc11_17.2) -// CHECK:STDOUT: %.loc11_18.1: %i32 = value_of_initializer %At.call -// CHECK:STDOUT: %.loc11_18.2: %i32 = converted %At.call, %.loc11_18.1 -// CHECK:STDOUT: %e: %i32 = bind_name e, %.loc11_18.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -387,8 +416,8 @@ let x: i32 = c[0]; // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .ElementType = %ElementType.decl // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl -// CHECK:STDOUT: .c = @__global_init.%c -// CHECK:STDOUT: .x = @__global_init.%x +// CHECK:STDOUT: .c = %c +// CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} @@ -403,6 +432,21 @@ let x: i32 = c[0]; // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [template = constants.%IndexWith.type.e80] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness (@impl.%At.decl) [template = constants.%impl_witness] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc14_13.1: ref %C = temporary_storage +// CHECK:STDOUT: %.loc14_13.2: init %C = class_init (), %.loc14_13.1 [template = constants.%C.val] +// CHECK:STDOUT: %.loc14_13.3: ref %C = temporary %.loc14_13.1, %.loc14_13.2 +// CHECK:STDOUT: %.loc14_13.4: ref %C = converted @__global_init.%.loc14, %.loc14_13.3 +// CHECK:STDOUT: %c: ref %C = bind_name c, %.loc14_13.4 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %ElementType.e6b = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.e6b] +// CHECK:STDOUT: %.loc22: ref %ElementType.e6b = temporary @__global_init.%.loc22_25.2, @__global_init.%At.call +// CHECK:STDOUT: %x: ref %ElementType.e6b = bind_name x, %.loc22 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type { @@ -455,23 +499,15 @@ let x: i32 = c[0]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc14_13.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc14_13.2: ref %C = temporary_storage -// CHECK:STDOUT: %.loc14_13.3: init %C = class_init (), %.loc14_13.2 [template = constants.%C.val] -// CHECK:STDOUT: %.loc14_13.4: ref %C = temporary %.loc14_13.2, %.loc14_13.3 -// CHECK:STDOUT: %.loc14_14.1: ref %C = converted %.loc14_13.1, %.loc14_13.4 -// CHECK:STDOUT: %.loc14_14.2: %C = bind_value %.loc14_14.1 -// CHECK:STDOUT: %c: %C = bind_name c, %.loc14_14.2 -// CHECK:STDOUT: %c.ref: %C = name_ref c, %c +// CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: %.loc22_25.1: %SubscriptType.8ee = converted %int_0, [template = ] // CHECK:STDOUT: %impl.elem0: %At.type.b3f = impl_witness_access constants.%impl_witness, element0 [template = constants.%At.d43] // CHECK:STDOUT: %At.bound: = bound_method %c.ref, %impl.elem0 // CHECK:STDOUT: %.loc22_25.2: ref %ElementType.e6b = temporary_storage -// CHECK:STDOUT: %At.call: init %ElementType.e6b = call %At.bound(%c.ref, ) to %.loc22_25.2 -// CHECK:STDOUT: %.loc22_25.3: ref %ElementType.e6b = temporary %.loc22_25.2, %At.call -// CHECK:STDOUT: %.loc22_25.4: %ElementType.e6b = bind_value %.loc22_25.3 -// CHECK:STDOUT: %x: %ElementType.e6b = bind_name x, %.loc22_25.4 +// CHECK:STDOUT: %.loc22_22: %C = bind_value %c.ref +// CHECK:STDOUT: %At.call: init %ElementType.e6b = call %At.bound(%.loc22_22, ) to %.loc22_25.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -500,11 +536,28 @@ let x: i32 = c[0]; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .c = @__global_init.%c -// CHECK:STDOUT: .x = @__global_init.%x +// CHECK:STDOUT: .c = %c +// CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C] +// CHECK:STDOUT: %.loc6_13.1: ref %C = temporary_storage +// CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), %.loc6_13.1 [template = constants.%C.val] +// CHECK:STDOUT: %.loc6_13.3: ref %C = temporary %.loc6_13.1, %.loc6_13.2 +// CHECK:STDOUT: %.loc6_13.4: ref %C = converted @__global_init.%.loc6, %.loc6_13.3 +// CHECK:STDOUT: %c: ref %C = bind_name c, %.loc6_13.4 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: %i32 = bind_name x, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { @@ -514,16 +567,9 @@ let x: i32 = c[0]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc6_13.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc6_13.2: ref %C = temporary_storage -// CHECK:STDOUT: %.loc6_13.3: init %C = class_init (), %.loc6_13.2 [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_13.4: ref %C = temporary %.loc6_13.2, %.loc6_13.3 -// CHECK:STDOUT: %.loc6_14.1: ref %C = converted %.loc6_13.1, %.loc6_13.4 -// CHECK:STDOUT: %.loc6_14.2: %C = bind_value %.loc6_14.1 -// CHECK:STDOUT: %c: %C = bind_name c, %.loc6_14.2 -// CHECK:STDOUT: %c.ref: %C = name_ref c, %c +// CHECK:STDOUT: %.loc6: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] -// CHECK:STDOUT: %x: %i32 = bind_name x, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/package_expr/fail_not_found.carbon b/toolchain/check/testdata/package_expr/fail_not_found.carbon index 4a0edc8bd503..320c4b76f136 100644 --- a/toolchain/check/testdata/package_expr/fail_not_found.carbon +++ b/toolchain/check/testdata/package_expr/fail_not_found.carbon @@ -44,11 +44,19 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc16_3: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y -// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: %package.ref: = name_ref package, package [template = package] // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] // CHECK:STDOUT: assign %y.var, +// CHECK:STDOUT: %.loc16_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/package_expr/syntax.carbon b/toolchain/check/testdata/package_expr/syntax.carbon index 8ed474000df7..f958b06e7c56 100644 --- a/toolchain/check/testdata/package_expr/syntax.carbon +++ b/toolchain/check/testdata/package_expr/syntax.carbon @@ -72,9 +72,25 @@ fn Main() { // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %i32 = var x +// CHECK:STDOUT: %.loc4_8: type = splice_block %i32.loc4 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc5_1: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y +// CHECK:STDOUT: %.loc5_8: type = splice_block %i32.loc5 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -131,28 +147,52 @@ fn Main() { // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %i32 = var x +// CHECK:STDOUT: %.loc4_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %i32 = binding_pattern x +// CHECK:STDOUT: %.loc7_3.1: %i32 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %i32 = var x -// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_1, %impl.elem0 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc7: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %x.var, %.loc7 +// CHECK:STDOUT: %.loc7_3.2: init %i32 = converted %int_1, %int.convert_checked [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %x.var, %.loc7_3.2 +// CHECK:STDOUT: %.loc7_10: type = splice_block %i32.loc7 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %i32 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc9_3: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y -// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: %package.ref: = name_ref package, package [template = package] // CHECK:STDOUT: %x.ref: ref %i32 = name_ref x, file.%x -// CHECK:STDOUT: %.loc9: %i32 = bind_value %x.ref -// CHECK:STDOUT: assign %y.var, %.loc9 +// CHECK:STDOUT: %.loc9_23: %i32 = bind_value %x.ref +// CHECK:STDOUT: assign %y.var, %.loc9_23 +// CHECK:STDOUT: %.loc9_10: type = splice_block %i32.loc9 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon b/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon index 9d2f37ae46b5..5fc149064139 100644 --- a/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon +++ b/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon @@ -82,7 +82,15 @@ import library "var"; // CHECK:STDOUT: .Foo = %Foo // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %Foo.patt: %i32 = binding_pattern Foo +// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %Foo.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %Foo.var: ref %i32 = var Foo +// CHECK:STDOUT: %.loc4_10: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %Foo: ref %i32 = bind_name Foo, %Foo.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/fail_import_type_error.carbon b/toolchain/check/testdata/packages/fail_import_type_error.carbon index 152f3dffa70f..9999dcdb478d 100644 --- a/toolchain/check/testdata/packages/fail_import_type_error.carbon +++ b/toolchain/check/testdata/packages/fail_import_type_error.carbon @@ -62,14 +62,43 @@ var d: i32 = d_ref; // CHECK:STDOUT: .d_ref = %d_ref // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: = binding_pattern a_ref +// CHECK:STDOUT: %.loc8: = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref = var a_ref -// CHECK:STDOUT: %a_ref: ref = bind_name a_ref, %a_ref.var +// CHECK:STDOUT: %x.ref.loc8: = name_ref x, [template = ] +// CHECK:STDOUT: %a_ref: = bind_name a_ref, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_ref.patt: = binding_pattern b_ref +// CHECK:STDOUT: %.loc13_1: = var_pattern %b_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ref.var: ref = var b_ref -// CHECK:STDOUT: %b_ref: ref = bind_name b_ref, %b_ref.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %x.ref.loc13: = name_ref x, [template = ] +// CHECK:STDOUT: %.loc13_19: = struct_literal (%x.ref.loc13) +// CHECK:STDOUT: } +// CHECK:STDOUT: %b_ref: = bind_name b_ref, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_ref.patt: = binding_pattern c_ref +// CHECK:STDOUT: %.loc18_1: = var_pattern %c_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_ref.var: ref = var c_ref -// CHECK:STDOUT: %c_ref: ref = bind_name c_ref, %c_ref.var +// CHECK:STDOUT: %.2: = splice_block [template = ] { +// CHECK:STDOUT: %x.ref.loc18: = name_ref x, [template = ] +// CHECK:STDOUT: %.loc18_15: = tuple_literal (%x.ref.loc18) +// CHECK:STDOUT: } +// CHECK:STDOUT: %c_ref: = bind_name c_ref, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d_ref.patt: = binding_pattern d_ref +// CHECK:STDOUT: %.loc23_1: = var_pattern %d_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d_ref.var: ref = var d_ref -// CHECK:STDOUT: %d_ref: ref = bind_name d_ref, %d_ref.var +// CHECK:STDOUT: %.loc23_13: type = splice_block %ptr [template = ] { +// CHECK:STDOUT: %x.ref.loc23: = name_ref x, [template = ] +// CHECK:STDOUT: %ptr: type = ptr_type [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %d_ref: = bind_name d_ref, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- implicit.impl.carbon @@ -80,10 +109,10 @@ var d: i32 = d_ref; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %import_ref.663: ref = import_ref Implicit//default, a_ref, loaded -// CHECK:STDOUT: %import_ref.621: ref = import_ref Implicit//default, b_ref, loaded -// CHECK:STDOUT: %import_ref.a99: ref = import_ref Implicit//default, c_ref, loaded -// CHECK:STDOUT: %import_ref.9a8: ref = import_ref Implicit//default, d_ref, loaded +// CHECK:STDOUT: %import_ref.6d1: = import_ref Implicit//default, a_ref, loaded +// CHECK:STDOUT: %import_ref.6de: = import_ref Implicit//default, b_ref, loaded +// CHECK:STDOUT: %import_ref.6cd: = import_ref Implicit//default, c_ref, loaded +// CHECK:STDOUT: %import_ref.a1f: = import_ref Implicit//default, d_ref, loaded // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .Int = %import_ref.485 // CHECK:STDOUT: import Core//prelude @@ -93,10 +122,10 @@ var d: i32 = d_ref; // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .a_ref = imports.%import_ref.663 -// CHECK:STDOUT: .b_ref = imports.%import_ref.621 -// CHECK:STDOUT: .c_ref = imports.%import_ref.a99 -// CHECK:STDOUT: .d_ref = imports.%import_ref.9a8 +// CHECK:STDOUT: .a_ref = imports.%import_ref.6d1 +// CHECK:STDOUT: .b_ref = imports.%import_ref.6de +// CHECK:STDOUT: .c_ref = imports.%import_ref.6cd +// CHECK:STDOUT: .d_ref = imports.%import_ref.a1f // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .a = %a // CHECK:STDOUT: .b = %b @@ -106,25 +135,57 @@ var d: i32 = d_ref; // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc6_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc6_8: type = splice_block %i32.loc6 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc7_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc7_8: type = splice_block %i32.loc7 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc8_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc8_8: type = splice_block %i32.loc8 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: %.loc9_1: %i32 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %i32 = var d +// CHECK:STDOUT: %.loc9_8: type = splice_block %i32.loc9 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %i32 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a_ref.ref: ref = name_ref a_ref, imports.%import_ref.663 +// CHECK:STDOUT: %a_ref.ref: = name_ref a_ref, imports.%import_ref.6d1 // CHECK:STDOUT: assign file.%a.var, -// CHECK:STDOUT: %b_ref.ref: ref = name_ref b_ref, imports.%import_ref.621 +// CHECK:STDOUT: %b_ref.ref: = name_ref b_ref, imports.%import_ref.6de // CHECK:STDOUT: assign file.%b.var, -// CHECK:STDOUT: %c_ref.ref: ref = name_ref c_ref, imports.%import_ref.a99 +// CHECK:STDOUT: %c_ref.ref: = name_ref c_ref, imports.%import_ref.6cd // CHECK:STDOUT: assign file.%c.var, -// CHECK:STDOUT: %d_ref.ref: ref = name_ref d_ref, imports.%import_ref.9a8 +// CHECK:STDOUT: %d_ref.ref: = name_ref d_ref, imports.%import_ref.a1f // CHECK:STDOUT: assign file.%d.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon b/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon index 7b0eba2e4466..a801f66d7370 100644 --- a/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon +++ b/toolchain/check/testdata/packages/fail_name_with_import_failure.carbon @@ -39,7 +39,15 @@ var a: () = A(); // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc8_9.1: type = splice_block %.loc8_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc8_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_9.3: type = converted %.loc8_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/implicit_imports_prelude.carbon b/toolchain/check/testdata/packages/implicit_imports_prelude.carbon index 91e7d6dab675..a4ba30e930ee 100644 --- a/toolchain/check/testdata/packages/implicit_imports_prelude.carbon +++ b/toolchain/check/testdata/packages/implicit_imports_prelude.carbon @@ -52,7 +52,15 @@ var b: i32 = a; // CHECK:STDOUT: .a = %a // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %i32 = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %i32 = var a +// CHECK:STDOUT: %.loc4_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -93,7 +101,15 @@ var b: i32 = a; // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc4_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/loaded_global.carbon b/toolchain/check/testdata/packages/loaded_global.carbon index 15a6302ed4f0..05e8aebcdb8e 100644 --- a/toolchain/check/testdata/packages/loaded_global.carbon +++ b/toolchain/check/testdata/packages/loaded_global.carbon @@ -89,9 +89,25 @@ var package_b: () = package.B(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %package_a.patt: %empty_tuple.type = binding_pattern package_a +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %package_a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %package_a.var: ref %empty_tuple.type = var package_a +// CHECK:STDOUT: %.loc6_17.1: type = splice_block %.loc6_17.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_17.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_17.3: type = converted %.loc6_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %package_a: ref %empty_tuple.type = bind_name package_a, %package_a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -159,9 +175,25 @@ var package_b: () = package.B(); // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %package_b.patt: %empty_tuple.type = binding_pattern package_b +// CHECK:STDOUT: %.loc8_1: %empty_tuple.type = var_pattern %package_b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %package_b.var: ref %empty_tuple.type = var package_b +// CHECK:STDOUT: %.loc8_17.1: type = splice_block %.loc8_17.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc8_17.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_17.3: type = converted %.loc8_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %package_b: ref %empty_tuple.type = bind_name package_b, %package_b.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon b/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon index 19b4169f7a9d..3594bd8c76b5 100644 --- a/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon +++ b/toolchain/check/testdata/packages/no_prelude/cross_package_export.carbon @@ -210,7 +210,11 @@ alias C = Other.C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -368,6 +372,7 @@ alias C = Other.C; // CHECK:STDOUT: import Other//export_import // CHECK:STDOUT: import Other//base // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3b0: type = import_ref Other//base, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.56d: = import_ref Other//base, loc6_1, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -377,7 +382,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc6_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -393,8 +406,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_27: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_27 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -416,6 +429,7 @@ alias C = Other.C; // CHECK:STDOUT: import Other//export_import_copy // CHECK:STDOUT: import Other//base // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3b0: type = import_ref Other//base, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.56d: = import_ref Other//base, loc6_1, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -425,7 +439,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc7_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -441,8 +463,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc7_25.2: init %empty_tuple.type = tuple_init () to %.loc7_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_26.3: init %empty_tuple.type = converted %.loc7_25.1, %.loc7_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_26.4: init %C = class_init (%.loc7_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_27: init %C = converted %.loc7_26.1, %.loc7_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_27 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_26.1, %.loc7_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -464,6 +486,7 @@ alias C = Other.C; // CHECK:STDOUT: import Other//export_import // CHECK:STDOUT: import Other//base // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.3b0: type = import_ref Other//base, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.56d: = import_ref Other//base, loc6_1, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -473,7 +496,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc6_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -489,8 +520,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_27: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_27 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -510,6 +541,7 @@ alias C = Other.C; // CHECK:STDOUT: .C = %import_ref.06e // CHECK:STDOUT: import Other//export_name // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.06e: type = import_ref Other//export_name, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.ad3: = import_ref Other//export_name, inst20 [indirect], loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -519,7 +551,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc6_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -535,8 +575,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_27: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_27 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -557,6 +597,7 @@ alias C = Other.C; // CHECK:STDOUT: import Other//export_name // CHECK:STDOUT: import Other//export_name_copy // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.06e: type = import_ref Other//export_name, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.ad3: = import_ref Other//export_name, inst20 [indirect], loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -566,7 +607,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc7_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -582,8 +631,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc7_25.2: init %empty_tuple.type = tuple_init () to %.loc7_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_26.3: init %empty_tuple.type = converted %.loc7_25.1, %.loc7_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_26.4: init %C = class_init (%.loc7_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_27: init %C = converted %.loc7_26.1, %.loc7_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_27 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_26.1, %.loc7_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -603,6 +652,7 @@ alias C = Other.C; // CHECK:STDOUT: .C = %import_ref.f43 // CHECK:STDOUT: import Other//export_name_indirect // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.f43: type = import_ref Other//export_name_indirect, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.328: = import_ref Other//export_name_indirect, inst20 [indirect], loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -612,7 +662,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc6_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.f43 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -628,8 +686,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_27: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_27 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -655,6 +713,7 @@ alias C = Other.C; // CHECK:STDOUT: import Other//export_name_indirect // CHECK:STDOUT: import Other//base // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.06e: type = import_ref Other//export_name, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.ad3: = import_ref Other//export_name, inst20 [indirect], loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -664,7 +723,15 @@ alias C = Other.C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc11_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc11_13: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -680,8 +747,8 @@ alias C = Other.C; // CHECK:STDOUT: %.loc11_25.2: init %empty_tuple.type = tuple_init () to %.loc11_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_26.3: init %empty_tuple.type = converted %.loc11_25.1, %.loc11_25.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_26.4: init %C = class_init (%.loc11_26.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc11_27: init %C = converted %.loc11_26.1, %.loc11_26.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc11_27 +// CHECK:STDOUT: %.loc11_1: init %C = converted %.loc11_26.1, %.loc11_26.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/export_import.carbon b/toolchain/check/testdata/packages/no_prelude/export_import.carbon index 1acf11e46796..3b41f8453368 100644 --- a/toolchain/check/testdata/packages/no_prelude/export_import.carbon +++ b/toolchain/check/testdata/packages/no_prelude/export_import.carbon @@ -189,7 +189,11 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -287,7 +291,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -303,8 +312,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -335,7 +344,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc4: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.f68 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -351,8 +365,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc4_19.2: init %empty_tuple.type = tuple_init () to %.loc4_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc4_20.3: init %empty_tuple.type = converted %.loc4_19.1, %.loc4_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc4_20.4: init %C = class_init (%.loc4_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc4_21: init %C = converted %.loc4_20.1, %.loc4_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc4_21 +// CHECK:STDOUT: %.loc4_1: init %C = converted %.loc4_20.1, %.loc4_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -378,7 +392,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -394,8 +413,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -421,7 +440,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -437,8 +461,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -464,7 +488,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -480,8 +509,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -507,7 +536,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -523,8 +557,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -550,7 +584,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -566,8 +605,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -593,7 +632,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -609,8 +653,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -647,7 +691,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -663,8 +712,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -692,7 +741,12 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: .indirect_c = %indirect_c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %indirect_c.patt: %C = binding_pattern indirect_c +// CHECK:STDOUT: %.loc6: %C = var_pattern %indirect_c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %indirect_c.var: ref %C = var indirect_c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %indirect_c: ref %C = bind_name indirect_c, %indirect_c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -708,8 +762,8 @@ var indirect_c: C = {.x = ()}; // CHECK:STDOUT: %.loc6_28.2: init %empty_tuple.type = tuple_init () to %.loc6_29.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_29.3: init %empty_tuple.type = converted %.loc6_28.1, %.loc6_28.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_29.4: init %C = class_init (%.loc6_29.3), file.%indirect_c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_30: init %C = converted %.loc6_29.1, %.loc6_29.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%indirect_c.var, %.loc6_30 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_29.1, %.loc6_29.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%indirect_c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon b/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon index 795cfe4f3ba4..892f9add93f9 100644 --- a/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon +++ b/toolchain/check/testdata/packages/no_prelude/export_mixed.carbon @@ -138,13 +138,21 @@ var d: D = {.y = ()}; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type.9be] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @D { -// CHECK:STDOUT: %.loc9: %D.elem = field_decl y, element0 [template] +// CHECK:STDOUT: %.loc9_8: %D.elem = field_decl y, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc9_3: %D.elem = var_pattern %.loc9_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %D.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.y [template = constants.%complete_type.9f4] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -255,7 +263,12 @@ var d: D = {.y = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -271,8 +284,8 @@ var d: D = {.y = ()}; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -298,7 +311,12 @@ var d: D = {.y = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -314,8 +332,8 @@ var d: D = {.y = ()}; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -341,7 +359,12 @@ var d: D = {.y = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -357,8 +380,8 @@ var d: D = {.y = ()}; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -379,8 +402,13 @@ var d: D = {.y = ()}; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: = binding_pattern d +// CHECK:STDOUT: %.loc11: = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref = var d -// CHECK:STDOUT: %d: ref = bind_name d, %d.var +// CHECK:STDOUT: %D.ref: = name_ref D, [template = ] +// CHECK:STDOUT: %d: = bind_name d, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { @@ -413,7 +441,12 @@ var d: D = {.y = ()}; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -429,8 +462,8 @@ var d: D = {.y = ()}; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -464,9 +497,19 @@ var d: D = {.y = ()}; // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc8: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %D = binding_pattern d +// CHECK:STDOUT: %.loc9: %D = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %D = var d +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.b0a [template = constants.%D] // CHECK:STDOUT: %d: ref %D = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -486,16 +529,16 @@ var d: D = {.y = ()}; // CHECK:STDOUT: %.loc8_19.2: init %empty_tuple.type = tuple_init () to %.loc8_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_20.3: init %empty_tuple.type = converted %.loc8_19.1, %.loc8_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_20.4: init %C = class_init (%.loc8_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc8_21: init %C = converted %.loc8_20.1, %.loc8_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc8_21 +// CHECK:STDOUT: %.loc8_1: init %C = converted %.loc8_20.1, %.loc8_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc8_1 // CHECK:STDOUT: %.loc9_19.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc9_20.1: %struct_type.y = struct_literal (%.loc9_19.1) // CHECK:STDOUT: %.loc9_20.2: ref %empty_tuple.type = class_element_access file.%d.var, element0 // CHECK:STDOUT: %.loc9_19.2: init %empty_tuple.type = tuple_init () to %.loc9_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc9_20.3: init %empty_tuple.type = converted %.loc9_19.1, %.loc9_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc9_20.4: init %D = class_init (%.loc9_20.3), file.%d.var [template = constants.%D.val] -// CHECK:STDOUT: %.loc9_21: init %D = converted %.loc9_20.1, %.loc9_20.4 [template = constants.%D.val] -// CHECK:STDOUT: assign file.%d.var, %.loc9_21 +// CHECK:STDOUT: %.loc9_1: init %D = converted %.loc9_20.1, %.loc9_20.4 [template = constants.%D.val] +// CHECK:STDOUT: assign file.%d.var, %.loc9_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/export_name.carbon b/toolchain/check/testdata/packages/no_prelude/export_name.carbon index 1eeb733a4812..8be5f65af369 100644 --- a/toolchain/check/testdata/packages/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/packages/no_prelude/export_name.carbon @@ -228,13 +228,21 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl x, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.x [template = constants.%complete_type.9be] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @NSC { -// CHECK:STDOUT: %.loc10: %NSC.elem = field_decl y, element0 [template] +// CHECK:STDOUT: %.loc10_8: %NSC.elem = field_decl y, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc10_3: %NSC.elem = var_pattern %.loc10_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %NSC.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.y [template = constants.%complete_type.9f4] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -366,6 +374,7 @@ private export C; // CHECK:STDOUT: %NS: = namespace %import_ref.0f6, [template] { // CHECK:STDOUT: .NSC = %import_ref.231 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.231: type = import_ref Main//export, NSC, loaded [template = constants.%NSC] // CHECK:STDOUT: %import_ref.ad3: = import_ref Main//export, inst23 [indirect], loaded [template = constants.%complete_type.9be] // CHECK:STDOUT: %import_ref.63c: = import_ref Main//export, inst31 [indirect], loaded [template = constants.%complete_type.9f4] // CHECK:STDOUT: } @@ -378,9 +387,22 @@ private export C; // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %nsc.patt: %NSC = binding_pattern nsc +// CHECK:STDOUT: %.loc7_1: %NSC = var_pattern %nsc.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc +// CHECK:STDOUT: %.loc7_12: type = splice_block %NSC.ref [template = constants.%NSC] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.231 [template = constants.%NSC] +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -400,16 +422,16 @@ private export C; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: %.loc7_26.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc7_27.1: %struct_type.y = struct_literal (%.loc7_26.1) // CHECK:STDOUT: %.loc7_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0 // CHECK:STDOUT: %.loc7_26.2: init %empty_tuple.type = tuple_init () to %.loc7_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_27.3: init %empty_tuple.type = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_27.4: init %NSC = class_init (%.loc7_27.3), file.%nsc.var [template = constants.%NSC.val] -// CHECK:STDOUT: %.loc7_28: init %NSC = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%NSC.val] -// CHECK:STDOUT: assign file.%nsc.var, %.loc7_28 +// CHECK:STDOUT: %.loc7_1: init %NSC = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%NSC.val] +// CHECK:STDOUT: assign file.%nsc.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -434,6 +456,7 @@ private export C; // CHECK:STDOUT: %NS: = namespace %import_ref.06f, [template] { // CHECK:STDOUT: .NSC = %import_ref.bb8 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.bb8: type = import_ref Main//export_export, NSC, loaded [template = constants.%NSC] // CHECK:STDOUT: %import_ref.328: = import_ref Main//export_export, inst23 [indirect], loaded [template = constants.%complete_type.9be] // CHECK:STDOUT: %import_ref.c12: = import_ref Main//export_export, inst31 [indirect], loaded [template = constants.%complete_type.9f4] // CHECK:STDOUT: } @@ -447,9 +470,22 @@ private export C; // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc4: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.f43 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %nsc.patt: %NSC = binding_pattern nsc +// CHECK:STDOUT: %.loc5_1: %NSC = var_pattern %nsc.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc +// CHECK:STDOUT: %.loc5_12: type = splice_block %NSC.ref [template = constants.%NSC] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.bb8 [template = constants.%NSC] +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -469,16 +505,16 @@ private export C; // CHECK:STDOUT: %.loc4_19.2: init %empty_tuple.type = tuple_init () to %.loc4_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc4_20.3: init %empty_tuple.type = converted %.loc4_19.1, %.loc4_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc4_20.4: init %C = class_init (%.loc4_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc4_21: init %C = converted %.loc4_20.1, %.loc4_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc4_21 +// CHECK:STDOUT: %.loc4_1: init %C = converted %.loc4_20.1, %.loc4_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc4_1 // CHECK:STDOUT: %.loc5_26.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc5_27.1: %struct_type.y = struct_literal (%.loc5_26.1) // CHECK:STDOUT: %.loc5_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0 // CHECK:STDOUT: %.loc5_26.2: init %empty_tuple.type = tuple_init () to %.loc5_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc5_27.3: init %empty_tuple.type = converted %.loc5_26.1, %.loc5_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc5_27.4: init %NSC = class_init (%.loc5_27.3), file.%nsc.var [template = constants.%NSC.val] -// CHECK:STDOUT: %.loc5_28: init %NSC = converted %.loc5_27.1, %.loc5_27.4 [template = constants.%NSC.val] -// CHECK:STDOUT: assign file.%nsc.var, %.loc5_28 +// CHECK:STDOUT: %.loc5_1: init %NSC = converted %.loc5_27.1, %.loc5_27.4 [template = constants.%NSC.val] +// CHECK:STDOUT: assign file.%nsc.var, %.loc5_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -503,6 +539,7 @@ private export C; // CHECK:STDOUT: %NS: = namespace %import_ref.06f, [template] { // CHECK:STDOUT: .NSC = %import_ref.bb8 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.bb8: type = import_ref Main//export_export, NSC, loaded [template = constants.%NSC] // CHECK:STDOUT: %import_ref.328: = import_ref Main//export_export, inst23 [indirect], loaded [template = constants.%complete_type.9be] // CHECK:STDOUT: %import_ref.c12: = import_ref Main//export_export, inst31 [indirect], loaded [template = constants.%complete_type.9f4] // CHECK:STDOUT: } @@ -515,9 +552,22 @@ private export C; // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.f43 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %nsc.patt: %NSC = binding_pattern nsc +// CHECK:STDOUT: %.loc7_1: %NSC = var_pattern %nsc.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc +// CHECK:STDOUT: %.loc7_12: type = splice_block %NSC.ref [template = constants.%NSC] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.bb8 [template = constants.%NSC] +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -537,16 +587,16 @@ private export C; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: %.loc7_26.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc7_27.1: %struct_type.y = struct_literal (%.loc7_26.1) // CHECK:STDOUT: %.loc7_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0 // CHECK:STDOUT: %.loc7_26.2: init %empty_tuple.type = tuple_init () to %.loc7_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_27.3: init %empty_tuple.type = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_27.4: init %NSC = class_init (%.loc7_27.3), file.%nsc.var [template = constants.%NSC.val] -// CHECK:STDOUT: %.loc7_28: init %NSC = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%NSC.val] -// CHECK:STDOUT: assign file.%nsc.var, %.loc7_28 +// CHECK:STDOUT: %.loc7_1: init %NSC = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%NSC.val] +// CHECK:STDOUT: assign file.%nsc.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -639,6 +689,7 @@ private export C; // CHECK:STDOUT: %NS: = namespace %import_ref.d58, [template] { // CHECK:STDOUT: .NSC = %import_ref.1a1 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1a1: type = import_ref Main//base, NSC, loaded [template = constants.%NSC] // CHECK:STDOUT: %import_ref.56d: = import_ref Main//base, loc6_1, loaded [template = constants.%complete_type.9be] // CHECK:STDOUT: %import_ref.5ab: = import_ref Main//base, loc11_1, loaded [template = constants.%complete_type.9f4] // CHECK:STDOUT: } @@ -651,9 +702,22 @@ private export C; // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.3b0 [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %nsc.patt: %NSC = binding_pattern nsc +// CHECK:STDOUT: %.loc8_1: %NSC = var_pattern %nsc.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc +// CHECK:STDOUT: %.loc8_12: type = splice_block %NSC.ref [template = constants.%NSC] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.1a1 [template = constants.%NSC] +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -673,16 +737,16 @@ private export C; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: %.loc8_26.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc8_27.1: %struct_type.y = struct_literal (%.loc8_26.1) // CHECK:STDOUT: %.loc8_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0 // CHECK:STDOUT: %.loc8_26.2: init %empty_tuple.type = tuple_init () to %.loc8_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_27.3: init %empty_tuple.type = converted %.loc8_26.1, %.loc8_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_27.4: init %NSC = class_init (%.loc8_27.3), file.%nsc.var [template = constants.%NSC.val] -// CHECK:STDOUT: %.loc8_28: init %NSC = converted %.loc8_27.1, %.loc8_27.4 [template = constants.%NSC.val] -// CHECK:STDOUT: assign file.%nsc.var, %.loc8_28 +// CHECK:STDOUT: %.loc8_1: init %NSC = converted %.loc8_27.1, %.loc8_27.4 [template = constants.%NSC.val] +// CHECK:STDOUT: assign file.%nsc.var, %.loc8_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -707,6 +771,7 @@ private export C; // CHECK:STDOUT: %NS: = namespace %import_ref.0f6, [template] { // CHECK:STDOUT: .NSC = %import_ref.231 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.231: type = import_ref Main//export, NSC, loaded [template = constants.%NSC] // CHECK:STDOUT: %import_ref.ad3: = import_ref Main//export, inst23 [indirect], loaded [template = constants.%complete_type.9be] // CHECK:STDOUT: %import_ref.63c: = import_ref Main//export, inst31 [indirect], loaded [template = constants.%complete_type.9f4] // CHECK:STDOUT: } @@ -719,9 +784,22 @@ private export C; // CHECK:STDOUT: .nsc = %nsc // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc7: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %nsc.patt: %NSC = binding_pattern nsc +// CHECK:STDOUT: %.loc8_1: %NSC = var_pattern %nsc.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc +// CHECK:STDOUT: %.loc8_12: type = splice_block %NSC.ref [template = constants.%NSC] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %NSC.ref: type = name_ref NSC, imports.%import_ref.231 [template = constants.%NSC] +// CHECK:STDOUT: } // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -741,16 +819,16 @@ private export C; // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc7_21 +// CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc7_1 // CHECK:STDOUT: %.loc8_26.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc8_27.1: %struct_type.y = struct_literal (%.loc8_26.1) // CHECK:STDOUT: %.loc8_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0 // CHECK:STDOUT: %.loc8_26.2: init %empty_tuple.type = tuple_init () to %.loc8_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_27.3: init %empty_tuple.type = converted %.loc8_26.1, %.loc8_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc8_27.4: init %NSC = class_init (%.loc8_27.3), file.%nsc.var [template = constants.%NSC.val] -// CHECK:STDOUT: %.loc8_28: init %NSC = converted %.loc8_27.1, %.loc8_27.4 [template = constants.%NSC.val] -// CHECK:STDOUT: assign file.%nsc.var, %.loc8_28 +// CHECK:STDOUT: %.loc8_1: init %NSC = converted %.loc8_27.1, %.loc8_27.4 [template = constants.%NSC.val] +// CHECK:STDOUT: assign file.%nsc.var, %.loc8_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -822,7 +900,12 @@ private export C; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.06e [template = constants.%C] // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -838,8 +921,8 @@ private export C; // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc6_21 +// CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon b/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon index 7061dfb2467d..9c7dbe9e0d8e 100644 --- a/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon +++ b/toolchain/check/testdata/packages/no_prelude/fail_export_name_member.carbon @@ -52,7 +52,11 @@ export C.n; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc5: %C.elem = field_decl n, element0 [template] +// CHECK:STDOUT: %.loc5_8: %C.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc5_3: %C.elem = var_pattern %.loc5_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon b/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon index 2d6fe65f8872..b0cd9ef45567 100644 --- a/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon +++ b/toolchain/check/testdata/packages/no_prelude/implicit_imports_entities.carbon @@ -328,9 +328,19 @@ import Other library "o1"; // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c1.patt: %C1 = binding_pattern c1 +// CHECK:STDOUT: %.loc6: %C1 = var_pattern %c1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c1.var: ref %C1 = var c1 +// CHECK:STDOUT: %C1.ref: type = name_ref C1, imports.%import_ref.0d9 [template = constants.%C1] // CHECK:STDOUT: %c1: ref %C1 = bind_name c1, %c1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c2.patt: %C2 = binding_pattern c2 +// CHECK:STDOUT: %.loc7: %C2 = var_pattern %c2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c2.var: ref %C2 = var c2 +// CHECK:STDOUT: %C2.ref: type = name_ref C2, imports.%import_ref.09c [template = constants.%C2] // CHECK:STDOUT: %c2: ref %C2 = bind_name c2, %c2.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -346,12 +356,12 @@ import Other library "o1"; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_15.2: init %C1 = class_init (), file.%c1.var [template = constants.%C1.val] -// CHECK:STDOUT: %.loc6_16: init %C1 = converted %.loc6_15.1, %.loc6_15.2 [template = constants.%C1.val] -// CHECK:STDOUT: assign file.%c1.var, %.loc6_16 +// CHECK:STDOUT: %.loc6_1: init %C1 = converted %.loc6_15.1, %.loc6_15.2 [template = constants.%C1.val] +// CHECK:STDOUT: assign file.%c1.var, %.loc6_1 // CHECK:STDOUT: %.loc7_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_15.2: init %C2 = class_init (), file.%c2.var [template = constants.%C2.val] -// CHECK:STDOUT: %.loc7_16: init %C2 = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C2.val] -// CHECK:STDOUT: assign file.%c2.var, %.loc7_16 +// CHECK:STDOUT: %.loc7_1: init %C2 = converted %.loc7_15.1, %.loc7_15.2 [template = constants.%C2.val] +// CHECK:STDOUT: assign file.%c2.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -389,7 +399,12 @@ import Other library "o1"; // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c1.patt: %C1 = binding_pattern c1 +// CHECK:STDOUT: %.loc6: %C1 = var_pattern %c1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c1.var: ref %C1 = var c1 +// CHECK:STDOUT: %C1.ref: type = name_ref C1, imports.%import_ref.0d9 [template = constants.%C1] // CHECK:STDOUT: %c1: ref %C1 = bind_name c1, %c1.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -401,8 +416,8 @@ import Other library "o1"; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_15.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_15.2: init %C1 = class_init (), file.%c1.var [template = constants.%C1.val] -// CHECK:STDOUT: %.loc6_16: init %C1 = converted %.loc6_15.1, %.loc6_15.2 [template = constants.%C1.val] -// CHECK:STDOUT: assign file.%c1.var, %.loc6_16 +// CHECK:STDOUT: %.loc6_1: init %C1 = converted %.loc6_15.1, %.loc6_15.2 [template = constants.%C1.val] +// CHECK:STDOUT: assign file.%c1.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -436,6 +451,7 @@ import Other library "o1"; // CHECK:STDOUT: %NS: = namespace %import_ref.0f6, [template] { // CHECK:STDOUT: .C = %import_ref.1c4 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1c4: type = import_ref Main//use_ns, C, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.8f2: = import_ref Main//ns, loc5_13, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -446,7 +462,15 @@ import Other library "o1"; // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc4_1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C = var c +// CHECK:STDOUT: %.loc4_10: type = splice_block %C.ref [template = constants.%C] { +// CHECK:STDOUT: %NS.ref: = name_ref NS, imports.%NS [template = imports.%NS] +// CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1c4 [template = constants.%C] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -458,8 +482,8 @@ import Other library "o1"; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_16.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc4_16.2: init %C = class_init (), file.%c.var [template = constants.%C.val] -// CHECK:STDOUT: %.loc4_17: init %C = converted %.loc4_16.1, %.loc4_16.2 [template = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc4_17 +// CHECK:STDOUT: %.loc4_1: init %C = converted %.loc4_16.1, %.loc4_16.2 [template = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -496,7 +520,9 @@ import Other library "o1"; // CHECK:STDOUT: import Other//o2 // CHECK:STDOUT: import Other//o1 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.880: type = import_ref Other//o1, O1, loaded [template = constants.%O1] // CHECK:STDOUT: %import_ref.8f24d3.1: = import_ref Other//o1, loc4_11, loaded [template = constants.%complete_type] +// CHECK:STDOUT: %import_ref.328: type = import_ref Other//o2, O2, loaded [template = constants.%O2] // CHECK:STDOUT: %import_ref.8f24d3.2: = import_ref Other//o2, loc4_11, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -509,9 +535,25 @@ import Other library "o1"; // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %o1.patt: %O1 = binding_pattern o1 +// CHECK:STDOUT: %.loc6_1: %O1 = var_pattern %o1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %o1.var: ref %O1 = var o1 +// CHECK:STDOUT: %.loc6_14: type = splice_block %O1.ref [template = constants.%O1] { +// CHECK:STDOUT: %Other.ref.loc6: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %O1.ref: type = name_ref O1, imports.%import_ref.880 [template = constants.%O1] +// CHECK:STDOUT: } // CHECK:STDOUT: %o1: ref %O1 = bind_name o1, %o1.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %o2.patt: %O2 = binding_pattern o2 +// CHECK:STDOUT: %.loc7_1: %O2 = var_pattern %o2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %o2.var: ref %O2 = var o2 +// CHECK:STDOUT: %.loc7_14: type = splice_block %O2.ref [template = constants.%O2] { +// CHECK:STDOUT: %Other.ref.loc7: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %O2.ref: type = name_ref O2, imports.%import_ref.328 [template = constants.%O2] +// CHECK:STDOUT: } // CHECK:STDOUT: %o2: ref %O2 = bind_name o2, %o2.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -527,12 +569,12 @@ import Other library "o1"; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_21.2: init %O1 = class_init (), file.%o1.var [template = constants.%O1.val] -// CHECK:STDOUT: %.loc6_22: init %O1 = converted %.loc6_21.1, %.loc6_21.2 [template = constants.%O1.val] -// CHECK:STDOUT: assign file.%o1.var, %.loc6_22 +// CHECK:STDOUT: %.loc6_1: init %O1 = converted %.loc6_21.1, %.loc6_21.2 [template = constants.%O1.val] +// CHECK:STDOUT: assign file.%o1.var, %.loc6_1 // CHECK:STDOUT: %.loc7_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc7_21.2: init %O2 = class_init (), file.%o2.var [template = constants.%O2.val] -// CHECK:STDOUT: %.loc7_22: init %O2 = converted %.loc7_21.1, %.loc7_21.2 [template = constants.%O2.val] -// CHECK:STDOUT: assign file.%o2.var, %.loc7_22 +// CHECK:STDOUT: %.loc7_1: init %O2 = converted %.loc7_21.1, %.loc7_21.2 [template = constants.%O2.val] +// CHECK:STDOUT: assign file.%o2.var, %.loc7_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -565,6 +607,7 @@ import Other library "o1"; // CHECK:STDOUT: .O1 = %import_ref.880 // CHECK:STDOUT: import Other//o1 // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.880: type = import_ref Other//o1, O1, loaded [template = constants.%O1] // CHECK:STDOUT: %import_ref.8f2: = import_ref Other//o1, loc4_11, loaded [template = constants.%complete_type] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -576,7 +619,15 @@ import Other library "o1"; // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Other.import = import Other +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %o1.patt: %O1 = binding_pattern o1 +// CHECK:STDOUT: %.loc6_1: %O1 = var_pattern %o1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %o1.var: ref %O1 = var o1 +// CHECK:STDOUT: %.loc6_14: type = splice_block %O1.ref [template = constants.%O1] { +// CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [template = imports.%Other] +// CHECK:STDOUT: %O1.ref: type = name_ref O1, imports.%import_ref.880 [template = constants.%O1] +// CHECK:STDOUT: } // CHECK:STDOUT: %o1: ref %O1 = bind_name o1, %o1.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -588,8 +639,8 @@ import Other library "o1"; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc6_21.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc6_21.2: init %O1 = class_init (), file.%o1.var [template = constants.%O1.val] -// CHECK:STDOUT: %.loc6_22: init %O1 = converted %.loc6_21.1, %.loc6_21.2 [template = constants.%O1.val] -// CHECK:STDOUT: assign file.%o1.var, %.loc6_22 +// CHECK:STDOUT: %.loc6_1: init %O1 = converted %.loc6_21.1, %.loc6_21.2 [template = constants.%O1.val] +// CHECK:STDOUT: assign file.%o1.var, %.loc6_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/packages/no_prelude/missing_prelude.carbon b/toolchain/check/testdata/packages/no_prelude/missing_prelude.carbon index e63233937b79..42e955b4af8f 100644 --- a/toolchain/check/testdata/packages/no_prelude/missing_prelude.carbon +++ b/toolchain/check/testdata/packages/no_prelude/missing_prelude.carbon @@ -89,14 +89,20 @@ var n: {} = i32; // CHECK:STDOUT: --- fail_missing_prelude.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: = binding_pattern n +// CHECK:STDOUT: %.loc8: = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref = var n -// CHECK:STDOUT: %n: ref = bind_name n, %n.var +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %n: = bind_name n, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- prelude_empty.carbon @@ -108,6 +114,7 @@ var n: {} = i32; // CHECK:STDOUT: --- fail_missing_prelude_member.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -122,8 +129,13 @@ var n: {} = i32; // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: = binding_pattern n +// CHECK:STDOUT: %.loc10: = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref = var n -// CHECK:STDOUT: %n: ref = bind_name n, %n.var +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %n: = bind_name n, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- prelude_fake_int.carbon @@ -214,7 +226,15 @@ var n: {} = i32; // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %empty_struct_type = binding_pattern n +// CHECK:STDOUT: %.loc6_1: %empty_struct_type = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %empty_struct_type = var n +// CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc6_9.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %n: ref %empty_struct_type = bind_name n, %n.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -292,7 +312,15 @@ var n: {} = i32; // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param0 // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %empty_tuple.type = binding_pattern n +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %empty_tuple.type = var n +// CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %n: ref %empty_tuple.type = bind_name n, %n.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -379,7 +407,15 @@ var n: {} = i32; // CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param runtime_param0 // CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %empty_struct_type = binding_pattern n +// CHECK:STDOUT: %.loc9_1: %empty_struct_type = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %empty_struct_type = var n +// CHECK:STDOUT: %.loc9_9.1: type = splice_block %.loc9_9.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc9_9.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc9_9.3: type = converted %.loc9_9.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %n: ref %empty_struct_type = bind_name n, %n.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -447,7 +483,15 @@ var n: {} = i32; // CHECK:STDOUT: .n = %n // CHECK:STDOUT: } // CHECK:STDOUT: %Core.decl: type = class_decl @Core [template = constants.%Core] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %empty_struct_type = binding_pattern n +// CHECK:STDOUT: %.loc13_1: %empty_struct_type = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %empty_struct_type = var n +// CHECK:STDOUT: %.loc13_9.1: type = splice_block %.loc13_9.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc13_9.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc13_9.3: type = converted %.loc13_9.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %n: ref %empty_struct_type = bind_name n, %n.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/address_of_deref.carbon b/toolchain/check/testdata/pointer/address_of_deref.carbon index 636eee152e22..291a4f7ddeca 100644 --- a/toolchain/check/testdata/pointer/address_of_deref.carbon +++ b/toolchain/check/testdata/pointer/address_of_deref.carbon @@ -50,8 +50,8 @@ fn F() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -59,15 +59,23 @@ fn F() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %i32 = var n -// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %n.var, %.loc12 +// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %n.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %n.ref: ref %i32 = name_ref n, %n // CHECK:STDOUT: %addr.loc13_13: %ptr = addr_of %n.ref // CHECK:STDOUT: %.loc13_12: ref %i32 = deref %addr.loc13_13 diff --git a/toolchain/check/testdata/pointer/address_of_lvalue.carbon b/toolchain/check/testdata/pointer/address_of_lvalue.carbon index 349a9a75e828..c44d5e5a1005 100644 --- a/toolchain/check/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/check/testdata/pointer/address_of_lvalue.carbon @@ -44,6 +44,7 @@ fn F() { // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template] // CHECK:STDOUT: %struct: %struct_type.a.b.501 = struct_value (%int_1.5d2, %int_2.ef8) [template] // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template] // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_2.ef8) [template] @@ -70,8 +71,11 @@ fn F() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: %struct_type.a.b.501 = binding_pattern s +// CHECK:STDOUT: %.loc12_3.1: %struct_type.a.b.501 = var_pattern %s.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %s.var: ref %struct_type.a.b.501 = var s -// CHECK:STDOUT: %s: ref %struct_type.a.b.501 = bind_name s, %s.var // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc12_46.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc12, %int_2.loc12) @@ -90,27 +94,68 @@ fn F() { // CHECK:STDOUT: %.loc12_46.6: ref %i32 = struct_access %s.var, element1 // CHECK:STDOUT: %.loc12_46.7: init %i32 = initialize_from %.loc12_46.5 to %.loc12_46.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc12_46.8: init %struct_type.a.b.501 = struct_init (%.loc12_46.4, %.loc12_46.7) to %s.var [template = constants.%struct] -// CHECK:STDOUT: %.loc12_47: init %struct_type.a.b.501 = converted %.loc12_46.1, %.loc12_46.8 [template = constants.%struct] -// CHECK:STDOUT: assign %s.var, %.loc12_47 +// CHECK:STDOUT: %.loc12_3.2: init %struct_type.a.b.501 = converted %.loc12_46.1, %.loc12_46.8 [template = constants.%struct] +// CHECK:STDOUT: assign %s.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_27: type = splice_block %struct_type.a.b.loc12 [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc12_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc12_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.loc12: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: ref %struct_type.a.b.501 = bind_name s, %s.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr.3ee = binding_pattern p +// CHECK:STDOUT: %.loc14_3: %ptr.3ee = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr.3ee = var p -// CHECK:STDOUT: %p: ref %ptr.3ee = bind_name p, %p.var // CHECK:STDOUT: %s.ref.loc14: ref %struct_type.a.b.501 = name_ref s, %s // CHECK:STDOUT: %addr.loc14: %ptr.3ee = addr_of %s.ref.loc14 // CHECK:STDOUT: assign %p.var, %addr.loc14 +// CHECK:STDOUT: %.loc14_28: type = splice_block %ptr.loc14 [template = constants.%ptr.3ee] { +// CHECK:STDOUT: %int_32.loc14_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_24: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.loc14: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: %ptr.loc14: type = ptr_type %struct_type.a.b.501 [template = constants.%ptr.3ee] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: ref %ptr.3ee = bind_name p, %p.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %q.patt: %ptr.235 = binding_pattern q +// CHECK:STDOUT: %.loc15_3: %ptr.235 = var_pattern %q.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %q.var: ref %ptr.235 = var q -// CHECK:STDOUT: %q: ref %ptr.235 = bind_name q, %q.var // CHECK:STDOUT: %s.ref.loc15: ref %struct_type.a.b.501 = name_ref s, %s -// CHECK:STDOUT: %.loc15: ref %i32 = struct_access %s.ref.loc15, element0 -// CHECK:STDOUT: %addr.loc15: %ptr.235 = addr_of %.loc15 +// CHECK:STDOUT: %.loc15_19: ref %i32 = struct_access %s.ref.loc15, element0 +// CHECK:STDOUT: %addr.loc15: %ptr.235 = addr_of %.loc15_19 // CHECK:STDOUT: assign %q.var, %addr.loc15 +// CHECK:STDOUT: %.loc15_13: type = splice_block %ptr.loc15 [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc15: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %q: ref %ptr.235 = bind_name q, %q.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %r.patt: %ptr.235 = binding_pattern r +// CHECK:STDOUT: %.loc16_3: %ptr.235 = var_pattern %r.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %r.var: ref %ptr.235 = var r -// CHECK:STDOUT: %r: ref %ptr.235 = bind_name r, %r.var // CHECK:STDOUT: %s.ref.loc16: ref %struct_type.a.b.501 = name_ref s, %s -// CHECK:STDOUT: %.loc16: ref %i32 = struct_access %s.ref.loc16, element1 -// CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %.loc16 +// CHECK:STDOUT: %.loc16_19: ref %i32 = struct_access %s.ref.loc16, element1 +// CHECK:STDOUT: %addr.loc16: %ptr.235 = addr_of %.loc16_19 // CHECK:STDOUT: assign %r.var, %addr.loc16 +// CHECK:STDOUT: %.loc16_13: type = splice_block %ptr.loc16 [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc16: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %r: ref %ptr.235 = bind_name r, %r.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t.patt: %tuple.type.d07 = binding_pattern t +// CHECK:STDOUT: %.loc18_3.1: %tuple.type.d07 = var_pattern %t.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t.var: ref %tuple.type.d07 = var t -// CHECK:STDOUT: %t: ref %tuple.type.d07 = bind_name t, %t.var // CHECK:STDOUT: %int_1.loc18: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc18: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc18_28.1: %tuple.type.f94 = tuple_literal (%int_1.loc18, %int_2.loc18) @@ -129,22 +174,49 @@ fn F() { // CHECK:STDOUT: %tuple.elem1.loc18: ref %i32 = tuple_access %t.var, element1 // CHECK:STDOUT: %.loc18_28.5: init %i32 = initialize_from %.loc18_28.4 to %tuple.elem1.loc18 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc18_28.6: init %tuple.type.d07 = tuple_init (%.loc18_28.3, %.loc18_28.5) to %t.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc18_29: init %tuple.type.d07 = converted %.loc18_28.1, %.loc18_28.6 [template = constants.%tuple] -// CHECK:STDOUT: assign %t.var, %.loc18_29 +// CHECK:STDOUT: %.loc18_3.2: init %tuple.type.d07 = converted %.loc18_28.1, %.loc18_28.6 [template = constants.%tuple] +// CHECK:STDOUT: assign %t.var, %.loc18_3.2 +// CHECK:STDOUT: %.loc18_19.1: type = splice_block %.loc18_19.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc18_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_19.2: %tuple.type.24b = tuple_literal (%i32.loc18_11, %i32.loc18_16) +// CHECK:STDOUT: %.loc18_19.3: type = converted %.loc18_19.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %t: ref %tuple.type.d07 = bind_name t, %t.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t0.patt: %ptr.235 = binding_pattern t0 +// CHECK:STDOUT: %.loc19_3: %ptr.235 = var_pattern %t0.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t0.var: ref %ptr.235 = var t0 -// CHECK:STDOUT: %t0: ref %ptr.235 = bind_name t0, %t0.var // CHECK:STDOUT: %t.ref.loc19: ref %tuple.type.d07 = name_ref t, %t // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: %tuple.elem0.loc19: ref %i32 = tuple_access %t.ref.loc19, element0 // CHECK:STDOUT: %addr.loc19: %ptr.235 = addr_of %tuple.elem0.loc19 // CHECK:STDOUT: assign %t0.var, %addr.loc19 +// CHECK:STDOUT: %.loc19_14: type = splice_block %ptr.loc19 [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc19: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %t0: ref %ptr.235 = bind_name t0, %t0.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t1.patt: %ptr.235 = binding_pattern t1 +// CHECK:STDOUT: %.loc20_3: %ptr.235 = var_pattern %t1.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t1.var: ref %ptr.235 = var t1 -// CHECK:STDOUT: %t1: ref %ptr.235 = bind_name t1, %t1.var // CHECK:STDOUT: %t.ref.loc20: ref %tuple.type.d07 = name_ref t, %t // CHECK:STDOUT: %int_1.loc20: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %tuple.elem1.loc20: ref %i32 = tuple_access %t.ref.loc20, element1 // CHECK:STDOUT: %addr.loc20: %ptr.235 = addr_of %tuple.elem1.loc20 // CHECK:STDOUT: assign %t1.var, %addr.loc20 +// CHECK:STDOUT: %.loc20_14: type = splice_block %ptr.loc20 [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr.loc20: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %t1: ref %ptr.235 = bind_name t1, %t1.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/arrow.carbon b/toolchain/check/testdata/pointer/arrow.carbon index 1b7e22c27395..20357db04e16 100644 --- a/toolchain/check/testdata/pointer/arrow.carbon +++ b/toolchain/check/testdata/pointer/arrow.carbon @@ -75,7 +75,11 @@ fn Foo(ptr: C*) { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [template = constants.%C] // CHECK:STDOUT: %self: %C = bind_name self, %self.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc13: %C.elem = field_decl field, element0 [template] +// CHECK:STDOUT: %.loc13_12: %C.elem = field_decl field, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %C.elem = var_pattern %.loc13_12 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.field [template = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } @@ -98,19 +102,19 @@ fn Foo(ptr: C*) { // CHECK:STDOUT: %Member.call.loc18: init %empty_tuple.type = call %Member.bound.loc18(%.loc18_6.2) // CHECK:STDOUT: %ptr.ref.loc20: %ptr.019 = name_ref ptr, %ptr.loc16_8 // CHECK:STDOUT: %.loc20_4: ref %C = deref %ptr.ref.loc20 -// CHECK:STDOUT: %field.ref.loc20: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13] +// CHECK:STDOUT: %field.ref.loc20: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12] // CHECK:STDOUT: %.loc20_9: ref %ptr.019 = class_element_access %.loc20_4, element0 // CHECK:STDOUT: %ptr.ref.loc21: %ptr.019 = name_ref ptr, %ptr.loc16_8 // CHECK:STDOUT: %.loc21_6.1: ref %C = deref %ptr.ref.loc21 -// CHECK:STDOUT: %field.ref.loc21: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13] +// CHECK:STDOUT: %field.ref.loc21: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12] // CHECK:STDOUT: %.loc21_6.2: ref %ptr.019 = class_element_access %.loc21_6.1, element0 // CHECK:STDOUT: %ptr.ref.loc23: %ptr.019 = name_ref ptr, %ptr.loc16_8 // CHECK:STDOUT: %.loc23_6.1: ref %C = deref %ptr.ref.loc23 -// CHECK:STDOUT: %field.ref.loc23_6: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13] +// CHECK:STDOUT: %field.ref.loc23_6: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12] // CHECK:STDOUT: %.loc23_6.2: ref %ptr.019 = class_element_access %.loc23_6.1, element0 // CHECK:STDOUT: %.loc23_6.3: %ptr.019 = bind_value %.loc23_6.2 // CHECK:STDOUT: %.loc23_13.1: ref %C = deref %.loc23_6.3 -// CHECK:STDOUT: %field.ref.loc23_13: %C.elem = name_ref field, @C.%.loc13 [template = @C.%.loc13] +// CHECK:STDOUT: %field.ref.loc23_13: %C.elem = name_ref field, @C.%.loc13_12 [template = @C.%.loc13_12] // CHECK:STDOUT: %.loc23_13.2: ref %ptr.019 = class_element_access %.loc23_13.1, element0 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/basic.carbon b/toolchain/check/testdata/pointer/basic.carbon index 4308e7db9e9c..45195537ff31 100644 --- a/toolchain/check/testdata/pointer/basic.carbon +++ b/toolchain/check/testdata/pointer/basic.carbon @@ -52,8 +52,8 @@ fn F() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -61,20 +61,37 @@ fn F() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %n.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %n.var: ref %i32 = var n -// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %n.var, %.loc12 +// CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %n.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: ref %i32 = bind_name n, %n.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr = binding_pattern p +// CHECK:STDOUT: %.loc13_3: %ptr = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr = var p -// CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var // CHECK:STDOUT: %n.ref: ref %i32 = name_ref n, %n // CHECK:STDOUT: %addr: %ptr = addr_of %n.ref // CHECK:STDOUT: assign %p.var, %addr +// CHECK:STDOUT: %.loc13_13: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var // CHECK:STDOUT: %p.ref: ref %ptr = name_ref p, %p // CHECK:STDOUT: %.loc15_11: %ptr = bind_value %p.ref // CHECK:STDOUT: %.loc15_10.1: ref %i32 = deref %.loc15_11 diff --git a/toolchain/check/testdata/pointer/fail_address_of_value.carbon b/toolchain/check/testdata/pointer/fail_address_of_value.carbon index 003f7764dcb1..7f0c853b4c81 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_value.carbon @@ -195,9 +195,9 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: %param.param_patt: %i32 = value_param_pattern %param.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %param.param: %i32 = value_param runtime_param0 -// CHECK:STDOUT: %.loc95: type = splice_block %i32 [template = constants.%i32] { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc95: type = splice_block %i32.loc95 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc95: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc95: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: } // CHECK:STDOUT: %param: %i32 = bind_name param, %param.param // CHECK:STDOUT: } @@ -288,11 +288,20 @@ fn AddressOfParam(param: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfParam(%param.param_patt: %i32) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %param_addr.patt: %ptr.235 = binding_pattern param_addr +// CHECK:STDOUT: %.loc100_3: %ptr.235 = var_pattern %param_addr.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %param_addr.var: ref %ptr.235 = var param_addr -// CHECK:STDOUT: %param_addr: ref %ptr.235 = bind_name param_addr, %param_addr.var // CHECK:STDOUT: %param.ref: %i32 = name_ref param, %param // CHECK:STDOUT: %addr: %ptr.235 = addr_of [template = ] // CHECK:STDOUT: assign %param_addr.var, %addr +// CHECK:STDOUT: %.loc100_22: type = splice_block %ptr [template = constants.%ptr.235] { +// CHECK:STDOUT: %int_32.loc100: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc100: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.235] +// CHECK:STDOUT: } +// CHECK:STDOUT: %param_addr: ref %ptr.235 = bind_name param_addr, %param_addr.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/fail_deref_error.carbon b/toolchain/check/testdata/pointer/fail_deref_error.carbon index eb729017bd1f..e4802ce67c0c 100644 --- a/toolchain/check/testdata/pointer/fail_deref_error.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_error.carbon @@ -37,21 +37,35 @@ let n2: i32 = undeclared->foo; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .n = @__global_init.%n -// CHECK:STDOUT: .n2 = @__global_init.%n2 +// CHECK:STDOUT: .n = %n +// CHECK:STDOUT: .n2 = %n2 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n.patt: %i32 = binding_pattern n +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15: type = splice_block %i32.loc15 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n: %i32 = bind_name n, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %n2.patt: %i32 = binding_pattern n2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc20: type = splice_block %i32.loc20 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %n2: %i32 = bind_name n2, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %undeclared.ref.loc15: = name_ref undeclared, [template = ] // CHECK:STDOUT: %.loc15: ref = deref -// CHECK:STDOUT: %n: %i32 = bind_name n, // CHECK:STDOUT: %undeclared.ref.loc20: = name_ref undeclared, [template = ] // CHECK:STDOUT: %.loc20: ref = deref // CHECK:STDOUT: %foo.ref: = name_ref foo, [template = ] -// CHECK:STDOUT: %n2: %i32 = bind_name n2, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/fail_deref_type.carbon b/toolchain/check/testdata/pointer/fail_deref_type.carbon index 4eed4031172d..6f8c86e27457 100644 --- a/toolchain/check/testdata/pointer/fail_deref_type.carbon +++ b/toolchain/check/testdata/pointer/fail_deref_type.carbon @@ -25,6 +25,8 @@ var p2: i32->foo; // CHECK:STDOUT: --- fail_deref_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -42,9 +44,28 @@ var p2: i32->foo; // CHECK:STDOUT: .p2 = %p2 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: = binding_pattern p +// CHECK:STDOUT: %.loc18_1: = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref = var p -// CHECK:STDOUT: %p: ref = bind_name p, %p.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_8: ref = deref %i32.loc18 +// CHECK:STDOUT: } +// CHECK:STDOUT: %p: = bind_name p, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p2.patt: = binding_pattern p2 +// CHECK:STDOUT: %.loc23_1: = var_pattern %p2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p2.var: ref = var p2 -// CHECK:STDOUT: %p2: ref = bind_name p2, %p2.var +// CHECK:STDOUT: %.2: = splice_block [template = ] { +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc23_12: ref = deref %i32.loc23 +// CHECK:STDOUT: %foo.ref: = name_ref foo, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %p2: = bind_name p2, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/pointer/import.carbon b/toolchain/check/testdata/pointer/import.carbon index 05a2d9eb9483..4dfb567715b9 100644 --- a/toolchain/check/testdata/pointer/import.carbon +++ b/toolchain/check/testdata/pointer/import.carbon @@ -53,9 +53,26 @@ var a: i32* = a_ref; // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_orig.patt: %i32 = binding_pattern a_orig +// CHECK:STDOUT: %.loc4_1: %i32 = var_pattern %a_orig.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_orig.var: ref %i32 = var a_orig +// CHECK:STDOUT: %.loc4_13: type = splice_block %i32.loc4 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_orig: ref %i32 = bind_name a_orig, %a_orig.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: %ptr = binding_pattern a_ref +// CHECK:STDOUT: %.loc5_1: %ptr = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref %ptr = var a_ref +// CHECK:STDOUT: %.loc5_15: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref: ref %ptr = bind_name a_ref, %a_ref.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -102,7 +119,16 @@ var a: i32* = a_ref; // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %ptr = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %ptr = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %ptr = var a +// CHECK:STDOUT: %.loc4_11: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %ptr = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/fail_return_with_returned_var.carbon b/toolchain/check/testdata/return/fail_return_with_returned_var.carbon index 408147c55ef4..034613765e76 100644 --- a/toolchain/check/testdata/return/fail_return_with_returned_var.carbon +++ b/toolchain/check/testdata/return/fail_return_with_returned_var.carbon @@ -87,8 +87,8 @@ fn G() -> C { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -97,7 +97,7 @@ fn G() -> C { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc24: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C = return_slot %return.param // CHECK:STDOUT: } @@ -105,29 +105,48 @@ fn G() -> C { // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: %.loc23_16: %C.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc23_11: %C.elem = var_pattern %.loc23_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc23_11: ref %C.elem = var // CHECK:STDOUT: %.loc23_28: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc23_23: %C.elem = var_pattern %.loc23_28 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc23_23: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc12_12.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc12: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %v.var, %.loc12 +// CHECK:STDOUT: %.loc12_12.2: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %v.var, %.loc12_12.2 +// CHECK:STDOUT: %.loc12_19: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return.param_patt: %C { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %c: ref %C = bind_name c, %return +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C = binding_pattern c +// CHECK:STDOUT: %.loc25_12.1: %C = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc25_38.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) @@ -146,8 +165,10 @@ fn G() -> C { // CHECK:STDOUT: %.loc25_38.6: ref %i32 = class_element_access %return, element1 // CHECK:STDOUT: %.loc25_38.7: init %i32 = initialize_from %.loc25_38.5 to %.loc25_38.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc25_38.8: init %C = class_init (%.loc25_38.4, %.loc25_38.7), %return [template = constants.%C.val] -// CHECK:STDOUT: %.loc25_39: init %C = converted %.loc25_38.1, %.loc25_38.8 [template = constants.%C.val] -// CHECK:STDOUT: assign %return, %.loc25_39 +// CHECK:STDOUT: %.loc25_12.2: init %C = converted %.loc25_38.1, %.loc25_38.8 [template = constants.%C.val] +// CHECK:STDOUT: assign %return, %.loc25_12.2 +// CHECK:STDOUT: %C.ref.loc25: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %c: ref %C = bind_name c, %return // CHECK:STDOUT: %c.ref: ref %C = name_ref c, %c // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon b/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon index f6895e57a92a..a332cd585419 100644 --- a/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_no_return_type.carbon @@ -37,6 +37,10 @@ fn ForgotReturnType() { // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: returned var v: () = (); + // CHECK:STDERR: fail_forgot_return_type.carbon:[[@LINE+4]]:3: error: `return var;` with no `returned var` in scope [ReturnVarWithNoReturnedVar] + // CHECK:STDERR: return var; + // CHECK:STDERR: ^~~~~~~~~~~ + // CHECK:STDERR: return var; } @@ -46,6 +50,7 @@ fn ForgotReturnType() { // CHECK:STDOUT: %Procedure.type: type = fn_type @Procedure [template] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %Procedure: %Procedure.type = struct_value () [template] +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -66,9 +71,20 @@ fn ForgotReturnType() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Procedure() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %v: %empty_tuple.type = bind_name v, -// CHECK:STDOUT: %.loc12: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: assign , +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %empty_tuple.type = binding_pattern v +// CHECK:STDOUT: %.loc12_12.1: %empty_tuple.type = var_pattern %v.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %v.var: ref %empty_tuple.type = var v +// CHECK:STDOUT: %.loc12_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_25.2: init %empty_tuple.type = tuple_init () to %v.var [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc12_12.2: init %empty_tuple.type = converted %.loc12_25.1, %.loc12_25.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %v.var, %.loc12_12.2 +// CHECK:STDOUT: %.loc12_20.1: type = splice_block %.loc12_20.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_20.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_20.3: type = converted %.loc12_20.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %empty_tuple.type = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -99,11 +115,20 @@ fn ForgotReturnType() { // CHECK:STDOUT: // CHECK:STDOUT: fn @ForgotReturnType() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %v: %empty_tuple.type = bind_name v, -// CHECK:STDOUT: %.loc12_25: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: assign , -// CHECK:STDOUT: %tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_16: %empty_tuple.type = converted %v, %tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: return %.loc12_16 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %empty_tuple.type = binding_pattern v +// CHECK:STDOUT: %.loc12_12.1: %empty_tuple.type = var_pattern %v.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %v.var: ref %empty_tuple.type = var v +// CHECK:STDOUT: %.loc12_25.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_25.2: init %empty_tuple.type = tuple_init () to %v.var [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc12_12.2: init %empty_tuple.type = converted %.loc12_25.1, %.loc12_25.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %v.var, %.loc12_12.2 +// CHECK:STDOUT: %.loc12_20.1: type = splice_block %.loc12_20.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_20.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_20.3: type = converted %.loc12_20.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %empty_tuple.type = bind_name v, %v.var +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/fail_returned_var_shadow.carbon b/toolchain/check/testdata/return/fail_returned_var_shadow.carbon index 8fad920ffb07..9d84141aeff0 100644 --- a/toolchain/check/testdata/return/fail_returned_var_shadow.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_shadow.carbon @@ -84,8 +84,8 @@ fn DifferentScopes() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -93,8 +93,8 @@ fn DifferentScopes() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc26: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -106,24 +106,40 @@ fn DifferentScopes() -> i32 { // CHECK:STDOUT: if %true br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc13_14.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_0.loc13: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc13: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc13: = bound_method %int_0.loc13, %impl.elem0.loc13 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc13: = specific_function %Convert.bound.loc13, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %Convert.specific_fn.loc13(%int_0.loc13) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc13: init %i32 = converted %int_0.loc13, %int.convert_checked.loc13 [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %v.var, %.loc13 +// CHECK:STDOUT: %.loc13_14.2: init %i32 = converted %int_0.loc13, %int.convert_checked.loc13 [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %v.var, %.loc13_14.2 +// CHECK:STDOUT: %.loc13_21: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %i32 = binding_pattern w +// CHECK:STDOUT: %.loc21_14.1: %i32 = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %i32 = var w -// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc21: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc21: = bound_method %int_1, %impl.elem0.loc21 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc21: = specific_function %Convert.bound.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc21: init %i32 = converted %int_1, %int.convert_checked.loc21 [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %w.var, %.loc21 +// CHECK:STDOUT: %.loc21_14.2: init %i32 = converted %int_1, %int.convert_checked.loc21 [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %w.var, %.loc21_14.2 +// CHECK:STDOUT: %.loc21_21: type = splice_block %i32.loc21 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: @@ -143,28 +159,44 @@ fn DifferentScopes() -> i32 { // CHECK:STDOUT: if %true.loc27 br !if.then.loc27 else br !if.else.loc27 // CHECK:STDOUT: // CHECK:STDOUT: !if.then.loc27: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc28_14.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_0.loc28: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc28: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc28: = bound_method %int_0.loc28, %impl.elem0.loc28 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc28: = specific_function %Convert.bound.loc28, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc28: init %i32 = call %Convert.specific_fn.loc28(%int_0.loc28) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc28: init %i32 = converted %int_0.loc28, %int.convert_checked.loc28 [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %v.var, %.loc28 +// CHECK:STDOUT: %.loc28_14.2: init %i32 = converted %int_0.loc28, %int.convert_checked.loc28 [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %v.var, %.loc28_14.2 +// CHECK:STDOUT: %.loc28_21: type = splice_block %i32.loc28 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc28: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc28: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %true.loc29: bool = bool_literal true [template = constants.%true] // CHECK:STDOUT: if %true.loc29 br !if.then.loc29 else br !if.else.loc29 // CHECK:STDOUT: // CHECK:STDOUT: !if.then.loc29: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %i32 = binding_pattern w +// CHECK:STDOUT: %.loc37_16.1: %i32 = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %i32 = var w -// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc37: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc37: = bound_method %int_1, %impl.elem0.loc37 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc37: = specific_function %Convert.bound.loc37, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc37: init %i32 = call %Convert.specific_fn.loc37(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc37: init %i32 = converted %int_1, %int.convert_checked.loc37 [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %w.var, %.loc37 +// CHECK:STDOUT: %.loc37_16.2: init %i32 = converted %int_1, %int.convert_checked.loc37 [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %w.var, %.loc37_16.2 +// CHECK:STDOUT: %.loc37_23: type = splice_block %i32.loc37 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc37: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc37: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: br !if.else.loc29 // CHECK:STDOUT: // CHECK:STDOUT: !if.else.loc29: diff --git a/toolchain/check/testdata/return/fail_returned_var_type.carbon b/toolchain/check/testdata/return/fail_returned_var_type.carbon index 4a3009e4d049..961f7bb9272d 100644 --- a/toolchain/check/testdata/return/fail_returned_var_type.carbon +++ b/toolchain/check/testdata/return/fail_returned_var_type.carbon @@ -27,6 +27,9 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %Mismatch.type: type = fn_type @Mismatch [template] // CHECK:STDOUT: %Mismatch: %Mismatch.type = struct_value () [template] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %float: f64 = float_literal 0 [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -58,9 +61,21 @@ fn Mismatch() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Mismatch() -> %i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %v: f64 = bind_name v, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: f64 = binding_pattern v +// CHECK:STDOUT: %.loc19_12: f64 = var_pattern %v.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %v.var: ref f64 = var v // CHECK:STDOUT: %float: f64 = float_literal 0 [template = constants.%float] -// CHECK:STDOUT: assign , -// CHECK:STDOUT: return +// CHECK:STDOUT: assign %v.var, %float +// CHECK:STDOUT: %.loc19_19.1: type = splice_block %.loc19_19.3 [template = f64] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc19_19.2: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc19_19.3: type = converted %float.make_type, %.loc19_19.2 [template = f64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref f64 = bind_name v, %v.var +// CHECK:STDOUT: %.loc19_16: f64 = bind_value %v +// CHECK:STDOUT: return %.loc19_16 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/return/fail_var_in_type.carbon b/toolchain/check/testdata/return/fail_var_in_type.carbon index 5a60461f324a..dba31d8e3348 100644 --- a/toolchain/check/testdata/return/fail_var_in_type.carbon +++ b/toolchain/check/testdata/return/fail_var_in_type.carbon @@ -40,6 +40,10 @@ fn Six() -> x { return 6; } // CHECK:STDOUT: .Six = %Six.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: type = binding_pattern x +// CHECK:STDOUT: %.loc11: type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref type = var x // CHECK:STDOUT: %x: ref type = bind_name x, %x.var // CHECK:STDOUT: %Six.decl: %Six.type = fn_decl @Six [template = constants.%Six] { diff --git a/toolchain/check/testdata/return/no_prelude/import_convert_function.carbon b/toolchain/check/testdata/return/no_prelude/import_convert_function.carbon index 2da5e3bf6c56..bcfb4f071445 100644 --- a/toolchain/check/testdata/return/no_prelude/import_convert_function.carbon +++ b/toolchain/check/testdata/return/no_prelude/import_convert_function.carbon @@ -739,7 +739,15 @@ fn F0(n: i32) -> P.D { // CHECK:STDOUT: // CHECK:STDOUT: class @D { // CHECK:STDOUT: %.loc7_16: %D.elem = field_decl n, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc7_11: %D.elem = var_pattern %.loc7_16 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc7_11: ref %D.elem = var // CHECK:STDOUT: %.loc7_28: %D.elem = field_decl m, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc7_23: %D.elem = var_pattern %.loc7_28 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc7_23: ref %D.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.n.m.566 [template = constants.%complete_type.682] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/return/returned_var.carbon b/toolchain/check/testdata/return/returned_var.carbon index 204d3f51622e..ac8f41d9f787 100644 --- a/toolchain/check/testdata/return/returned_var.carbon +++ b/toolchain/check/testdata/return/returned_var.carbon @@ -78,7 +78,7 @@ fn G() -> i32 { // CHECK:STDOUT: %return.patt: %C = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %C.ref.loc16: type = name_ref C, file.%C.decl [template = constants.%C] // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0 // CHECK:STDOUT: %return: ref %C = return_slot %return.param // CHECK:STDOUT: } @@ -86,23 +86,34 @@ fn G() -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc12: %C.elem = field_decl a, element0 [template] -// CHECK:STDOUT: %.loc13: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: %.loc12_8: %C.elem = field_decl a, element0 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc12_3: %C.elem = var_pattern %.loc12_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc12: ref %C.elem = var +// CHECK:STDOUT: %.loc13_8: %C.elem = field_decl b, element1 [template] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %.loc13_3: %C.elem = var_pattern %.loc13_8 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var.loc13: ref %C.elem = var // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %return.param_patt: %C { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %result: ref %C = bind_name result, %return +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %result.patt: %C = binding_pattern result +// CHECK:STDOUT: %.loc17_12.1: %C = var_pattern %result.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc17_43.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) @@ -121,22 +132,32 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc17_43.6: ref %i32 = class_element_access %return, element1 // CHECK:STDOUT: %.loc17_43.7: init %i32 = initialize_from %.loc17_43.5 to %.loc17_43.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc17_43.8: init %C = class_init (%.loc17_43.4, %.loc17_43.7), %return [template = constants.%C.val] -// CHECK:STDOUT: %.loc17_44: init %C = converted %.loc17_43.1, %.loc17_43.8 [template = constants.%C.val] -// CHECK:STDOUT: assign %return, %.loc17_44 +// CHECK:STDOUT: %.loc17_12.2: init %C = converted %.loc17_43.1, %.loc17_43.8 [template = constants.%C.val] +// CHECK:STDOUT: assign %return, %.loc17_12.2 +// CHECK:STDOUT: %C.ref.loc17: type = name_ref C, file.%C.decl [template = constants.%C] +// CHECK:STDOUT: %result: ref %C = bind_name result, %return // CHECK:STDOUT: return %result to %return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %result.patt: %i32 = binding_pattern result +// CHECK:STDOUT: %.loc22_12.1: %i32 = var_pattern %result.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %result.var: ref %i32 = var result -// CHECK:STDOUT: %result: ref %i32 = bind_name result, %result.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound: = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc22_31: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %result.var, %.loc22_31 +// CHECK:STDOUT: %.loc22_12.2: init %i32 = converted %int_0, %int.convert_checked [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %result.var, %.loc22_12.2 +// CHECK:STDOUT: %.loc22_24: type = splice_block %i32.loc22 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %result: ref %i32 = bind_name result, %result.var // CHECK:STDOUT: %.loc22_16: %i32 = bind_value %result // CHECK:STDOUT: return %.loc22_16 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/return/returned_var_scope.carbon b/toolchain/check/testdata/return/returned_var_scope.carbon index f87755664e3c..3a15582f9a80 100644 --- a/toolchain/check/testdata/return/returned_var_scope.carbon +++ b/toolchain/check/testdata/return/returned_var_scope.carbon @@ -74,8 +74,8 @@ fn EnclosingButAfter(b: bool) -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -85,8 +85,8 @@ fn EnclosingButAfter(b: bool) -> i32 { // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] // CHECK:STDOUT: %b.param: bool = value_param runtime_param0 // CHECK:STDOUT: %.loc21_25.1: type = splice_block %.loc21_25.3 [template = bool] { // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] @@ -105,15 +105,23 @@ fn EnclosingButAfter(b: bool) -> i32 { // CHECK:STDOUT: if %true.loc12 br !if.then.loc12 else br !if.else.loc12 // CHECK:STDOUT: // CHECK:STDOUT: !if.then.loc12: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc13_14.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_0.loc13: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc13: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc13: = bound_method %int_0.loc13, %impl.elem0.loc13 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc13: = specific_function %Convert.bound.loc13, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %Convert.specific_fn.loc13(%int_0.loc13) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc13: init %i32 = converted %int_0.loc13, %int.convert_checked.loc13 [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %v.var, %.loc13 +// CHECK:STDOUT: %.loc13_14.2: init %i32 = converted %int_0.loc13, %int.convert_checked.loc13 [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %v.var, %.loc13_14.2 +// CHECK:STDOUT: %.loc13_21: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: br !if.else.loc12 // CHECK:STDOUT: // CHECK:STDOUT: !if.else.loc12: @@ -121,15 +129,23 @@ fn EnclosingButAfter(b: bool) -> i32 { // CHECK:STDOUT: if %true.loc15 br !if.then.loc15 else br !if.else.loc15 // CHECK:STDOUT: // CHECK:STDOUT: !if.then.loc15: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %i32 = binding_pattern w +// CHECK:STDOUT: %.loc16_14.1: %i32 = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %i32 = var w -// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc16: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc16: = bound_method %int_1, %impl.elem0.loc16 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc16: = specific_function %Convert.bound.loc16, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %Convert.specific_fn.loc16(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc16: init %i32 = converted %int_1, %int.convert_checked.loc16 [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %w.var, %.loc16 +// CHECK:STDOUT: %.loc16_14.2: init %i32 = converted %int_1, %int.convert_checked.loc16 [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %w.var, %.loc16_14.2 +// CHECK:STDOUT: %.loc16_21: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: br !if.else.loc15 // CHECK:STDOUT: // CHECK:STDOUT: !if.else.loc15: @@ -149,28 +165,44 @@ fn EnclosingButAfter(b: bool) -> i32 { // CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %i32 = binding_pattern v +// CHECK:STDOUT: %.loc23_14.1: %i32 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %i32 = var v -// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc23: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc23: = bound_method %int_0, %impl.elem0.loc23 [template = constants.%Convert.bound.d04] // CHECK:STDOUT: %Convert.specific_fn.loc23: = specific_function %Convert.bound.loc23, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62] // CHECK:STDOUT: %int.convert_checked.loc23: init %i32 = call %Convert.specific_fn.loc23(%int_0) [template = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc23_28: init %i32 = converted %int_0, %int.convert_checked.loc23 [template = constants.%int_0.6a9] -// CHECK:STDOUT: assign %v.var, %.loc23_28 +// CHECK:STDOUT: %.loc23_14.2: init %i32 = converted %int_0, %int.convert_checked.loc23 [template = constants.%int_0.6a9] +// CHECK:STDOUT: assign %v.var, %.loc23_14.2 +// CHECK:STDOUT: %.loc23_21: type = splice_block %i32.loc23 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var // CHECK:STDOUT: %.loc23_18: %i32 = bind_value %v // CHECK:STDOUT: return %.loc23_18 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %i32 = binding_pattern w +// CHECK:STDOUT: %.loc26_12.1: %i32 = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %i32 = var w -// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc26: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc26: = bound_method %int_1, %impl.elem0.loc26 [template = constants.%Convert.bound.ab5] // CHECK:STDOUT: %Convert.specific_fn.loc26: = specific_function %Convert.bound.loc26, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] // CHECK:STDOUT: %int.convert_checked.loc26: init %i32 = call %Convert.specific_fn.loc26(%int_1) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc26_26: init %i32 = converted %int_1, %int.convert_checked.loc26 [template = constants.%int_1.5d2] -// CHECK:STDOUT: assign %w.var, %.loc26_26 +// CHECK:STDOUT: %.loc26_12.2: init %i32 = converted %int_1, %int.convert_checked.loc26 [template = constants.%int_1.5d2] +// CHECK:STDOUT: assign %w.var, %.loc26_12.2 +// CHECK:STDOUT: %.loc26_19: type = splice_block %i32.loc26 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc26: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: ref %i32 = bind_name w, %w.var // CHECK:STDOUT: %.loc26_16: %i32 = bind_value %w // CHECK:STDOUT: return %.loc26_16 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_assign_empty.carbon b/toolchain/check/testdata/struct/fail_assign_empty.carbon index 4a83370f8cb9..d55c31ebeeaa 100644 --- a/toolchain/check/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/check/testdata/struct/fail_assign_empty.carbon @@ -37,7 +37,16 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %struct_type.a = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a = var x +// CHECK:STDOUT: %.loc15_16: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_assign_to_empty.carbon b/toolchain/check/testdata/struct/fail_assign_to_empty.carbon index 4b491cf4d529..bdd101eac2ee 100644 --- a/toolchain/check/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/check/testdata/struct/fail_assign_to_empty.carbon @@ -35,7 +35,15 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_struct_type = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %empty_struct_type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_struct_type = var x +// CHECK:STDOUT: %.loc15_9.1: type = splice_block %.loc15_9.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc15_9.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc15_9.3: type = converted %.loc15_9.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_duplicate_name.carbon b/toolchain/check/testdata/struct/fail_duplicate_name.carbon index c787d3c079ec..8235b1703edd 100644 --- a/toolchain/check/testdata/struct/fail_duplicate_name.carbon +++ b/toolchain/check/testdata/struct/fail_duplicate_name.carbon @@ -81,8 +81,8 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4}; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .F = %F.decl -// CHECK:STDOUT: .v = @__global_init.%v -// CHECK:STDOUT: .w = @__global_init.%w +// CHECK:STDOUT: .v = %v +// CHECK:STDOUT: .w = %w // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } @@ -104,9 +104,47 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4}; // CHECK:STDOUT: %return.param: ref = out_param runtime_param0 // CHECK:STDOUT: %return: ref = return_slot %return.param // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: } +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %int_32.loc27_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc27_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc27_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc27_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: = bind_name v, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %i32 = binding_pattern w +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc36: type = splice_block %i32.loc36 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc36: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc36: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: %i32 = bind_name w, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.ba9 = binding_pattern x +// CHECK:STDOUT: %.loc45_1: %struct_type.a.ba9 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.ba9 = var x +// CHECK:STDOUT: %.loc45_16: type = splice_block %struct_type.a [template = constants.%struct_type.a.ba9] { +// CHECK:STDOUT: %int_32.loc45: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc45: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a.ba9] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.ba9 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.b.c = binding_pattern y +// CHECK:STDOUT: %.loc54_1: %struct_type.b.c = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.b.c = var y +// CHECK:STDOUT: %.loc54_25: type = splice_block %struct_type.b.c [template = constants.%struct_type.b.c] { +// CHECK:STDOUT: %int_32.loc54_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc54_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc54_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc54_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.b.c: type = struct_type {.b: %i32, .c: %i32} [template = constants.%struct_type.b.c] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %struct_type.b.c = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -116,11 +154,9 @@ var y: {.b: i32, .c: i32} = {.b = 3, .b = 4}; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1.loc27: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %.loc27: %struct_type.a.a6c = struct_literal (%int_1.loc27) -// CHECK:STDOUT: %v: = bind_name v, // CHECK:STDOUT: %int_1.loc36: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %int_2.loc36: Core.IntLiteral = int_value 2 [template = constants.%int_2] // CHECK:STDOUT: %def.ref: = name_ref def, [template = ] -// CHECK:STDOUT: %w: %i32 = bind_name w, // CHECK:STDOUT: %int_1.loc45: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %int_2.loc45: Core.IntLiteral = int_value 2 [template = constants.%int_2] // CHECK:STDOUT: assign file.%x.var, diff --git a/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon index 347280bc28e2..b2c54d646213 100644 --- a/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_name_mismatch.carbon @@ -46,9 +46,27 @@ var y: {.b: i32} = x; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %struct_type.a = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a = var x +// CHECK:STDOUT: %.loc15_16: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.b.0a3 = binding_pattern y +// CHECK:STDOUT: %.loc21_1: %struct_type.b.0a3 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.b.0a3 = var y +// CHECK:STDOUT: %.loc21_16: type = splice_block %struct_type.b [template = constants.%struct_type.b.0a3] { +// CHECK:STDOUT: %int_32.loc21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %i32} [template = constants.%struct_type.b.0a3] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %struct_type.b.0a3 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon index e2996840d84e..c678e37296cb 100644 --- a/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/check/testdata/struct/fail_field_type_mismatch.carbon @@ -38,7 +38,16 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %struct_type.a = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a = var x +// CHECK:STDOUT: %.loc15_16: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_member_access_type.carbon b/toolchain/check/testdata/struct/fail_member_access_type.carbon index eb898d4fda92..ba4323f6cd58 100644 --- a/toolchain/check/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/check/testdata/struct/fail_member_access_type.carbon @@ -18,6 +18,9 @@ var y: i32 = x.b; // CHECK:STDOUT: --- fail_member_access_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: f64} [template] // CHECK:STDOUT: %float: f64 = float_literal 4 [template] // CHECK:STDOUT: %struct: %struct_type.a = struct_value (%float) [template] @@ -41,9 +44,28 @@ var y: i32 = x.b; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.a = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a = var x +// CHECK:STDOUT: %.loc11_16: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc11_13.2: type = converted %float.make_type, %.loc11_13.1 [template = f64] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: f64} [template = constants.%struct_type.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32 [template = constants.%i32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -52,8 +74,8 @@ var y: i32 = x.b; // CHECK:STDOUT: %float: f64 = float_literal 4 [template = constants.%float] // CHECK:STDOUT: %.loc11_29.1: %struct_type.a = struct_literal (%float) // CHECK:STDOUT: %.loc11_29.2: init %struct_type.a = struct_init (%float) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_30: init %struct_type.a = converted %.loc11_29.1, %.loc11_29.2 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_30 +// CHECK:STDOUT: %.loc11_1: init %struct_type.a = converted %.loc11_29.1, %.loc11_29.2 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %struct_type.a = name_ref x, file.%x // CHECK:STDOUT: assign file.%y.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/struct/fail_non_member_access.carbon b/toolchain/check/testdata/struct/fail_non_member_access.carbon index 7039e62834f6..b2f9783e9989 100644 --- a/toolchain/check/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/check/testdata/struct/fail_non_member_access.carbon @@ -49,9 +49,26 @@ var y: i32 = x.b; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.ba9 = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.a.ba9 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.ba9 = var x +// CHECK:STDOUT: %.loc11_16: type = splice_block %struct_type.a [template = constants.%struct_type.a.ba9] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a.ba9] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.ba9 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -65,8 +82,8 @@ var y: i32 = x.b; // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_4) [template = constants.%int_4.940] // CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_4, %int.convert_checked [template = constants.%int_4.940] // CHECK:STDOUT: %.loc11_27.3: init %struct_type.a.ba9 = struct_init (%.loc11_27.2) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_28: init %struct_type.a.ba9 = converted %.loc11_27.1, %.loc11_27.3 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %struct_type.a.ba9 = converted %.loc11_27.1, %.loc11_27.3 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %struct_type.a.ba9 = name_ref x, file.%x // CHECK:STDOUT: assign file.%y.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/struct/fail_too_few_values.carbon b/toolchain/check/testdata/struct/fail_too_few_values.carbon index 8f59050a7b6c..deeacc573ca9 100644 --- a/toolchain/check/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/check/testdata/struct/fail_too_few_values.carbon @@ -38,7 +38,18 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.b = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %struct_type.a.b = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.b = var x +// CHECK:STDOUT: %.loc15_25: type = splice_block %struct_type.a.b [template = constants.%struct_type.a.b] { +// CHECK:STDOUT: %int_32.loc15_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.b = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_type_assign.carbon b/toolchain/check/testdata/struct/fail_type_assign.carbon index 16e36bd80d12..4c4883101744 100644 --- a/toolchain/check/testdata/struct/fail_type_assign.carbon +++ b/toolchain/check/testdata/struct/fail_type_assign.carbon @@ -10,10 +10,10 @@ // CHECK:STDERR: fail_type_assign.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `type` to `{.a: i32}` [ImplicitAsConversionFailure] // CHECK:STDERR: var x: {.a: i32} = {.a: i32}; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_type_assign.carbon:[[@LINE+4]]:1: note: type `type` does not implement interface `Core.ImplicitAs({.a: i32})` [MissingImplInMemberAccessNote] // CHECK:STDERR: var x: {.a: i32} = {.a: i32}; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~ // CHECK:STDERR: var x: {.a: i32} = {.a: i32}; @@ -40,7 +40,16 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a = binding_pattern x +// CHECK:STDOUT: %.loc18_1: %struct_type.a = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a = var x +// CHECK:STDOUT: %.loc18_16: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_value_as_type.carbon b/toolchain/check/testdata/struct/fail_value_as_type.carbon index 9ba9401227b4..bcee97492216 100644 --- a/toolchain/check/testdata/struct/fail_value_as_type.carbon +++ b/toolchain/check/testdata/struct/fail_value_as_type.carbon @@ -20,6 +20,8 @@ var x: {.a = 1}; // CHECK:STDOUT: --- fail_value_as_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: Core.IntLiteral} [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -36,7 +38,16 @@ var x: {.a = 1}; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: = binding_pattern x +// CHECK:STDOUT: %.loc18_1: = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref = var x -// CHECK:STDOUT: %x: ref = bind_name x, %x.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %.loc18_15.1: %struct_type.a = struct_literal (%int_1) +// CHECK:STDOUT: %.loc18_15.2: type = converted %.loc18_15.1, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: = bind_name x, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/import.carbon b/toolchain/check/testdata/struct/import.carbon index 4b19471a261d..eabfbe302101 100644 --- a/toolchain/check/testdata/struct/import.carbon +++ b/toolchain/check/testdata/struct/import.carbon @@ -45,10 +45,10 @@ var c_bad: C({.c = 1, .d = 2}) = F(); impl package Implicit; // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `C({.a = 1, .b = 2})` to `C({.a = 3, .b = 4})` [ImplicitAsConversionFailure] // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+4]]:1: note: type `C({.a = 1, .b = 2})` does not implement interface `Core.ImplicitAs(C({.a = 3, .b = 4}))` [MissingImplInMemberAccessNote] // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F(); @@ -68,6 +68,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %Convert.specific_fn.d62: = specific_function %Convert.bound.d04, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template] // CHECK:STDOUT: %struct.92d: %struct_type.a.ba9 = struct_value (%int_0.6a9) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %struct_type.b.c.929: type = struct_type {.b: %i32, .c: %tuple.type.a1c} [template] // CHECK:STDOUT: %struct_type.a.d.3d9: type = struct_type {.a: %struct_type.b.c.929, .d: %i32} [template] @@ -117,9 +118,34 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: %struct_type.a.ba9 = binding_pattern a_ref +// CHECK:STDOUT: %.loc4_1: %struct_type.a.ba9 = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref %struct_type.a.ba9 = var a_ref +// CHECK:STDOUT: %.loc4_20: type = splice_block %struct_type.a [template = constants.%struct_type.a.ba9] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a.ba9] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref: ref %struct_type.a.ba9 = bind_name a_ref, %a_ref.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_ref.patt: %struct_type.a.d.3d9 = binding_pattern b_ref +// CHECK:STDOUT: %.loc5_1: %struct_type.a.d.3d9 = var_pattern %b_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ref.var: ref %struct_type.a.d.3d9 = var b_ref +// CHECK:STDOUT: %.loc5_47: type = splice_block %struct_type.a.d [template = constants.%struct_type.a.d.3d9] { +// CHECK:STDOUT: %int_32.loc5_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc5_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_36.1: %tuple.type.85c = tuple_literal (%i32.loc5_32) +// CHECK:STDOUT: %.loc5_36.2: type = converted %.loc5_36.1, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: %struct_type.b.c: type = struct_type {.b: %i32, .c: %tuple.type.a1c} [template = constants.%struct_type.b.c.929] +// CHECK:STDOUT: %int_32.loc5_44: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_44: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.d: type = struct_type {.a: %struct_type.b.c.929, .d: %i32} [template = constants.%struct_type.a.d.3d9] +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ref: ref %struct_type.a.d.3d9 = bind_name b_ref, %b_ref.var // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] { // CHECK:STDOUT: %S.patt.loc8_9.1: %struct_type.a.b.501 = symbolic_binding_pattern S, 0 [symbolic = %S.patt.loc8_9.2 (constants.%S.patt)] @@ -187,8 +213,8 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %int.convert_checked.loc4: init %i32 = call %Convert.specific_fn.loc4(%int_0.loc4) [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc4_31.2: init %i32 = converted %int_0.loc4, %int.convert_checked.loc4 [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc4_31.3: init %struct_type.a.ba9 = struct_init (%.loc4_31.2) to file.%a_ref.var [template = constants.%struct.92d] -// CHECK:STDOUT: %.loc4_32: init %struct_type.a.ba9 = converted %.loc4_31.1, %.loc4_31.3 [template = constants.%struct.92d] -// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_32 +// CHECK:STDOUT: %.loc4_1: init %struct_type.a.ba9 = converted %.loc4_31.1, %.loc4_31.3 [template = constants.%struct.92d] +// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_1 // CHECK:STDOUT: %int_0.loc6_17: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %int_0.loc6_26: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %.loc6_28.1: %tuple.type.985 = tuple_literal (%int_0.loc6_26) @@ -222,8 +248,8 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %.loc6_38.5: ref %i32 = struct_access file.%b_ref.var, element1 // CHECK:STDOUT: %.loc6_38.6: init %i32 = initialize_from %.loc6_38.4 to %.loc6_38.5 [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc6_38.7: init %struct_type.a.d.3d9 = struct_init (%.loc6_38.3, %.loc6_38.6) to file.%b_ref.var [template = constants.%struct.20d] -// CHECK:STDOUT: %.loc6_39: init %struct_type.a.d.3d9 = converted %.loc6_38.1, %.loc6_38.7 [template = constants.%struct.20d] -// CHECK:STDOUT: assign file.%b_ref.var, %.loc6_39 +// CHECK:STDOUT: %.loc5: init %struct_type.a.d.3d9 = converted %.loc6_38.1, %.loc6_38.7 [template = constants.%struct.20d] +// CHECK:STDOUT: assign file.%b_ref.var, %.loc5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -243,6 +269,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.dd4: type = tuple_type (%i32) [template] // CHECK:STDOUT: %struct_type.b.c: type = struct_type {.b: %i32, .c: %tuple.type.dd4} [template] // CHECK:STDOUT: %struct_type.a.d.9db: type = struct_type {.a: %struct_type.b.c, .d: %i32} [template] @@ -253,7 +280,18 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %struct_type.a.b.5ca: type = struct_type {.a: %i32, .b: %i32} [template] // CHECK:STDOUT: %S: %struct_type.a.b.5ca = bind_symbolic_name S, 0 [symbolic] // CHECK:STDOUT: %S.patt: %struct_type.a.b.5ca = symbolic_binding_pattern S, 0 [symbolic] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template] +// CHECK:STDOUT: %Convert.type.ea0: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.847: = impl_witness (imports.%import_ref.773), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.e14: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.4cb: %Convert.type.e14 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.dc5: = bound_method %int_1.5b8, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.51b: = specific_function %Convert.bound.dc5, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_1.47b: %i32 = int_value 1 [template] +// CHECK:STDOUT: %Convert.bound.30f: = bound_method %int_2.ecc, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.9b5: = specific_function %Convert.bound.30f, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_2.d0d: %i32 = int_value 2 [template] // CHECK:STDOUT: %struct: %struct_type.a.b.5ca = struct_value (%int_1.47b, %int_2.d0d) [template] // CHECK:STDOUT: %C.a8a: type = class_type @C, @C(%struct) [template] @@ -289,11 +327,61 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %struct_type.a = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %struct_type.a = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %struct_type.a = var a +// CHECK:STDOUT: %.loc4_16: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template = constants.%struct_type.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %struct_type.a = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %struct_type.a.d.9db = binding_pattern b +// CHECK:STDOUT: %.loc5_1: %struct_type.a.d.9db = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %struct_type.a.d.9db = var b +// CHECK:STDOUT: %.loc5_43: type = splice_block %struct_type.a.d [template = constants.%struct_type.a.d.9db] { +// CHECK:STDOUT: %int_32.loc5_18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc5_28: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_28: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_32.1: %tuple.type.85c = tuple_literal (%i32.loc5_28) +// CHECK:STDOUT: %.loc5_32.2: type = converted %.loc5_32.1, constants.%tuple.type.dd4 [template = constants.%tuple.type.dd4] +// CHECK:STDOUT: %struct_type.b.c: type = struct_type {.b: %i32, .c: %tuple.type.dd4} [template = constants.%struct_type.b.c] +// CHECK:STDOUT: %int_32.loc5_40: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_40: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.d: type = struct_type {.a: %struct_type.b.c, .d: %i32} [template = constants.%struct_type.a.d.9db] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %struct_type.a.d.9db = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.a8a = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C.a8a = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.a8a = var c +// CHECK:STDOUT: %.loc6_26.1: type = splice_block %C [template = constants.%C.a8a] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc6_25.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) +// CHECK:STDOUT: %impl.elem0.loc6_25.1: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc6_25.1: = bound_method %int_1, %impl.elem0.loc6_25.1 [template = constants.%Convert.bound.dc5] +// CHECK:STDOUT: %Convert.specific_fn.loc6_25.1: = specific_function %Convert.bound.loc6_25.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.51b] +// CHECK:STDOUT: %int.convert_checked.loc6_25.1: init %i32 = call %Convert.specific_fn.loc6_25.1(%int_1) [template = constants.%int_1.47b] +// CHECK:STDOUT: %.loc6_25.2: %i32 = value_of_initializer %int.convert_checked.loc6_25.1 [template = constants.%int_1.47b] +// CHECK:STDOUT: %.loc6_25.3: %i32 = converted %int_1, %.loc6_25.2 [template = constants.%int_1.47b] +// CHECK:STDOUT: %impl.elem0.loc6_25.2: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc6_25.2: = bound_method %int_2, %impl.elem0.loc6_25.2 [template = constants.%Convert.bound.30f] +// CHECK:STDOUT: %Convert.specific_fn.loc6_25.2: = specific_function %Convert.bound.loc6_25.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.9b5] +// CHECK:STDOUT: %int.convert_checked.loc6_25.2: init %i32 = call %Convert.specific_fn.loc6_25.2(%int_2) [template = constants.%int_2.d0d] +// CHECK:STDOUT: %.loc6_25.4: %i32 = value_of_initializer %int.convert_checked.loc6_25.2 [template = constants.%int_2.d0d] +// CHECK:STDOUT: %.loc6_25.5: %i32 = converted %int_2, %.loc6_25.4 [template = constants.%int_2.d0d] +// CHECK:STDOUT: %struct: %struct_type.a.b.5ca = struct_value (%.loc6_25.3, %.loc6_25.5) [template = constants.%struct] +// CHECK:STDOUT: %.loc6_26.2: %struct_type.a.b.5ca = converted %.loc6_25.1, %struct [template = constants.%struct] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%struct) [template = constants.%C.a8a] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.a8a = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -316,8 +404,8 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %.loc4_20.1: ref %i32 = struct_access %a_ref.ref, element0 // CHECK:STDOUT: %.loc4_20.2: %i32 = bind_value %.loc4_20.1 // CHECK:STDOUT: %.loc4_20.3: init %struct_type.a = struct_init (%.loc4_20.2) to file.%a.var -// CHECK:STDOUT: %.loc4_25: init %struct_type.a = converted %a_ref.ref, %.loc4_20.3 -// CHECK:STDOUT: assign file.%a.var, %.loc4_25 +// CHECK:STDOUT: %.loc4_1: init %struct_type.a = converted %a_ref.ref, %.loc4_20.3 +// CHECK:STDOUT: assign file.%a.var, %.loc4_1 // CHECK:STDOUT: %b_ref.ref: ref %struct_type.a.d.9db = name_ref b_ref, imports.%import_ref.1d0 // CHECK:STDOUT: %.loc5_47.1: ref %struct_type.b.c = struct_access %b_ref.ref, element0 // CHECK:STDOUT: %.loc5_47.2: ref %i32 = struct_access %.loc5_47.1, element0 @@ -339,8 +427,8 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %.loc5_47.17: ref %i32 = struct_access file.%b.var, element1 // CHECK:STDOUT: %.loc5_47.18: init %i32 = initialize_from %.loc5_47.16 to %.loc5_47.17 // CHECK:STDOUT: %.loc5_47.19: init %struct_type.a.d.9db = struct_init (%.loc5_47.14, %.loc5_47.18) to file.%b.var -// CHECK:STDOUT: %.loc5_52: init %struct_type.a.d.9db = converted %b_ref.ref, %.loc5_47.19 -// CHECK:STDOUT: assign file.%b.var, %.loc5_52 +// CHECK:STDOUT: %.loc5_1: init %struct_type.a.d.9db = converted %b_ref.ref, %.loc5_47.19 +// CHECK:STDOUT: assign file.%b.var, %.loc5_1 // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.b37 [template = constants.%F] // CHECK:STDOUT: %.loc6: ref %C.a8a = splice_block file.%c.var {} // CHECK:STDOUT: %F.call: init %C.a8a = call %F.ref() to %.loc6 @@ -372,6 +460,9 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: %i32} [template] // CHECK:STDOUT: %S: %struct_type.a.b = bind_symbolic_name S, 0 [symbolic] // CHECK:STDOUT: %S.patt: %struct_type.a.b = symbolic_binding_pattern S, 0 [symbolic] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %struct_type.c.d: type = struct_type {.c: Core.IntLiteral, .d: Core.IntLiteral} [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %int_2.d0d: %i32 = int_value 2 [template] @@ -404,8 +495,18 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_bad.patt: = binding_pattern c_bad +// CHECK:STDOUT: %.loc11_1: = var_pattern %c_bad.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_bad.var: ref = var c_bad -// CHECK:STDOUT: %c_bad: ref = bind_name c_bad, %c_bad.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc11_29: %struct_type.c.d = struct_literal (%int_1, %int_2) +// CHECK:STDOUT: } +// CHECK:STDOUT: %c_bad: = bind_name c_bad, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @C(constants.%S: %struct_type.a.b) [from "implicit.carbon"] { @@ -454,7 +555,18 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %struct_type.a.b.5ca: type = struct_type {.a: %i32, .b: %i32} [template] // CHECK:STDOUT: %S: %struct_type.a.b.5ca = bind_symbolic_name S, 0 [symbolic] // CHECK:STDOUT: %S.patt: %struct_type.a.b.5ca = symbolic_binding_pattern S, 0 [symbolic] +// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] +// CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template] +// CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template] +// CHECK:STDOUT: %Convert.type.ea0: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.847: = impl_witness (imports.%import_ref.773), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.e14: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.4cb: %Convert.type.e14 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.a00: = bound_method %int_3.1ba, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.dec: = specific_function %Convert.bound.a00, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_3.d47: %i32 = int_value 3 [template] +// CHECK:STDOUT: %Convert.bound.694: = bound_method %int_4.0c1, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.739: = specific_function %Convert.bound.694, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_4.ea3: %i32 = int_value 4 [template] // CHECK:STDOUT: %struct.8e6: %struct_type.a.b.5ca = struct_value (%int_3.d47, %int_4.ea3) [template] // CHECK:STDOUT: %C.5a7: type = class_type @C, @C(%struct.8e6) [template] @@ -491,7 +603,32 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_bad.patt: %C.5a7 = binding_pattern c_bad +// CHECK:STDOUT: %.loc10_1: %C.5a7 = var_pattern %c_bad.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_bad.var: ref %C.5a7 = var c_bad +// CHECK:STDOUT: %.loc10_30.1: type = splice_block %C [template = constants.%C.5a7] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1] +// CHECK:STDOUT: %.loc10_29.1: %struct_type.a.b.cfd = struct_literal (%int_3, %int_4) +// CHECK:STDOUT: %impl.elem0.loc10_29.1: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc10_29.1: = bound_method %int_3, %impl.elem0.loc10_29.1 [template = constants.%Convert.bound.a00] +// CHECK:STDOUT: %Convert.specific_fn.loc10_29.1: = specific_function %Convert.bound.loc10_29.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.dec] +// CHECK:STDOUT: %int.convert_checked.loc10_29.1: init %i32 = call %Convert.specific_fn.loc10_29.1(%int_3) [template = constants.%int_3.d47] +// CHECK:STDOUT: %.loc10_29.2: %i32 = value_of_initializer %int.convert_checked.loc10_29.1 [template = constants.%int_3.d47] +// CHECK:STDOUT: %.loc10_29.3: %i32 = converted %int_3, %.loc10_29.2 [template = constants.%int_3.d47] +// CHECK:STDOUT: %impl.elem0.loc10_29.2: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc10_29.2: = bound_method %int_4, %impl.elem0.loc10_29.2 [template = constants.%Convert.bound.694] +// CHECK:STDOUT: %Convert.specific_fn.loc10_29.2: = specific_function %Convert.bound.loc10_29.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.739] +// CHECK:STDOUT: %int.convert_checked.loc10_29.2: init %i32 = call %Convert.specific_fn.loc10_29.2(%int_4) [template = constants.%int_4.ea3] +// CHECK:STDOUT: %.loc10_29.4: %i32 = value_of_initializer %int.convert_checked.loc10_29.2 [template = constants.%int_4.ea3] +// CHECK:STDOUT: %.loc10_29.5: %i32 = converted %int_4, %.loc10_29.4 [template = constants.%int_4.ea3] +// CHECK:STDOUT: %struct: %struct_type.a.b.5ca = struct_value (%.loc10_29.3, %.loc10_29.5) [template = constants.%struct.8e6] +// CHECK:STDOUT: %.loc10_30.2: %struct_type.a.b.5ca = converted %.loc10_29.1, %struct [template = constants.%struct.8e6] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%struct.8e6) [template = constants.%C.5a7] +// CHECK:STDOUT: } // CHECK:STDOUT: %c_bad: ref %C.5a7 = bind_name c_bad, %c_bad.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -513,7 +650,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.b37 [template = constants.%F] // CHECK:STDOUT: %.loc10_36: ref %C.a8a = temporary_storage // CHECK:STDOUT: %F.call: init %C.a8a = call %F.ref() to %.loc10_36 -// CHECK:STDOUT: %.loc10_37: %C.5a7 = converted %F.call, [template = ] +// CHECK:STDOUT: %.loc10_1: %C.5a7 = converted %F.call, [template = ] // CHECK:STDOUT: assign file.%c_bad.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/member_access.carbon b/toolchain/check/testdata/struct/member_access.carbon index 27224aa8af71..4085a9716336 100644 --- a/toolchain/check/testdata/struct/member_access.carbon +++ b/toolchain/check/testdata/struct/member_access.carbon @@ -15,6 +15,9 @@ var z: i32 = y; // CHECK:STDOUT: --- member_access.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template] +// CHECK:STDOUT: %Float.type: type = fn_type @Float [template] +// CHECK:STDOUT: %Float: %Float.type = struct_value () [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] // CHECK:STDOUT: %struct_type.a.b.ddf: type = struct_type {.a: f64, .b: %i32} [template] @@ -49,11 +52,40 @@ var z: i32 = y; // CHECK:STDOUT: .z = %z // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.b.ddf = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.a.b.ddf = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.b.ddf = var x +// CHECK:STDOUT: %.loc11_25: type = splice_block %struct_type.a.b [template = constants.%struct_type.a.b.ddf] { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] +// CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %float.make_type [template = f64] +// CHECK:STDOUT: %.loc11_13.2: type = converted %float.make_type, %.loc11_13.1 [template = f64] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: f64, .b: %i32} [template = constants.%struct_type.a.b.ddf] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.b.ddf = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %i32 = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %i32 = var y +// CHECK:STDOUT: %.loc12_8: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %i32 = bind_name y, %y.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %z.patt: %i32 = binding_pattern z +// CHECK:STDOUT: %.loc13_1: %i32 = var_pattern %z.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %z.var: ref %i32 = var z +// CHECK:STDOUT: %.loc13_8: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %z: ref %i32 = bind_name z, %z.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -72,8 +104,8 @@ var z: i32 = y; // CHECK:STDOUT: %.loc11_46.5: ref %i32 = struct_access file.%x.var, element1 // CHECK:STDOUT: %.loc11_46.6: init %i32 = initialize_from %.loc11_46.4 to %.loc11_46.5 [template = constants.%int_1.5d2] // CHECK:STDOUT: %.loc11_46.7: init %struct_type.a.b.ddf = struct_init (%.loc11_46.3, %.loc11_46.6) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_47: init %struct_type.a.b.ddf = converted %.loc11_46.1, %.loc11_46.7 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_47 +// CHECK:STDOUT: %.loc11_1: init %struct_type.a.b.ddf = converted %.loc11_46.1, %.loc11_46.7 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %struct_type.a.b.ddf = name_ref x, file.%x // CHECK:STDOUT: %.loc12_15.1: ref %i32 = struct_access %x.ref, element1 // CHECK:STDOUT: %.loc12_15.2: %i32 = bind_value %.loc12_15.1 diff --git a/toolchain/check/testdata/struct/nested_struct_in_place.carbon b/toolchain/check/testdata/struct/nested_struct_in_place.carbon index 74da148ee45e..c92366886498 100644 --- a/toolchain/check/testdata/struct/nested_struct_in_place.carbon +++ b/toolchain/check/testdata/struct/nested_struct_in_place.carbon @@ -65,8 +65,11 @@ fn G() { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %struct_type.a.b.2f9 = binding_pattern v +// CHECK:STDOUT: %.loc14_3.1: %struct_type.a.b.2f9 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %struct_type.a.b.2f9 = var v -// CHECK:STDOUT: %v: ref %struct_type.a.b.2f9 = bind_name v, %v.var // CHECK:STDOUT: %F.ref.loc14_61: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %.loc14_74.1: ref %tuple.type.189 = struct_access %v.var, element0 // CHECK:STDOUT: %F.call.loc14_63: init %tuple.type.189 = call %F.ref.loc14_61() to %.loc14_74.1 @@ -75,8 +78,28 @@ fn G() { // CHECK:STDOUT: %F.call.loc14_73: init %tuple.type.189 = call %F.ref.loc14_71() to %.loc14_74.2 // CHECK:STDOUT: %.loc14_74.3: %struct_type.a.b.2f9 = struct_literal (%F.call.loc14_63, %F.call.loc14_73) // CHECK:STDOUT: %.loc14_74.4: init %struct_type.a.b.2f9 = struct_init (%F.call.loc14_63, %F.call.loc14_73) to %v.var -// CHECK:STDOUT: %.loc14_75: init %struct_type.a.b.2f9 = converted %.loc14_74.3, %.loc14_74.4 -// CHECK:STDOUT: assign %v.var, %.loc14_75 +// CHECK:STDOUT: %.loc14_3.2: init %struct_type.a.b.2f9 = converted %.loc14_74.3, %.loc14_74.4 +// CHECK:STDOUT: assign %v.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_51: type = splice_block %struct_type.a.b [template = constants.%struct_type.a.b.2f9] { +// CHECK:STDOUT: %int_32.loc14_16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_26: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_26: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_29.1: %tuple.type.ff9 = tuple_literal (%i32.loc14_16, %i32.loc14_21, %i32.loc14_26) +// CHECK:STDOUT: %.loc14_29.2: type = converted %.loc14_29.1, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: %int_32.loc14_37: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_37: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_42: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_42: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_47: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_47: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_50.1: %tuple.type.ff9 = tuple_literal (%i32.loc14_37, %i32.loc14_42, %i32.loc14_47) +// CHECK:STDOUT: %.loc14_50.2: type = converted %.loc14_50.1, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %tuple.type.189, .b: %tuple.type.189} [template = constants.%struct_type.a.b.2f9] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %struct_type.a.b.2f9 = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/no_prelude/empty.carbon b/toolchain/check/testdata/struct/no_prelude/empty.carbon index 9ca51695ec90..ae802e95cccf 100644 --- a/toolchain/check/testdata/struct/no_prelude/empty.carbon +++ b/toolchain/check/testdata/struct/no_prelude/empty.carbon @@ -23,9 +23,25 @@ var y: {} = x; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_struct_type = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %empty_struct_type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_struct_type = var x +// CHECK:STDOUT: %.loc11_9.1: type = splice_block %.loc11_9.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc11_9.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc11_9.3: type = converted %.loc11_9.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %empty_struct_type = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %empty_struct_type = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %empty_struct_type = var y +// CHECK:STDOUT: %.loc12_9.1: type = splice_block %.loc12_9.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc12_9.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc12_9.3: type = converted %.loc12_9.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -33,12 +49,12 @@ var y: {} = x; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_14.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc11_14.2: init %empty_struct_type = struct_init () to file.%x.var [template = constants.%empty_struct] -// CHECK:STDOUT: %.loc11_15: init %empty_struct_type = converted %.loc11_14.1, %.loc11_14.2 [template = constants.%empty_struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_15 +// CHECK:STDOUT: %.loc11_1: init %empty_struct_type = converted %.loc11_14.1, %.loc11_14.2 [template = constants.%empty_struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %empty_struct_type = name_ref x, file.%x // CHECK:STDOUT: %.loc12_13: init %empty_struct_type = struct_init () to file.%y.var [template = constants.%empty_struct] -// CHECK:STDOUT: %.loc12_14: init %empty_struct_type = converted %x.ref, %.loc12_13 [template = constants.%empty_struct] -// CHECK:STDOUT: assign file.%y.var, %.loc12_14 +// CHECK:STDOUT: %.loc12_1: init %empty_struct_type = converted %x.ref, %.loc12_13 [template = constants.%empty_struct] +// CHECK:STDOUT: assign file.%y.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon b/toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon index efc8b760d131..341356bd8761 100644 --- a/toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon +++ b/toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon @@ -26,7 +26,16 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.225 = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %struct_type.a.225 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.225 = var x +// CHECK:STDOUT: %.loc15_15: type = splice_block %struct_type.a [template = constants.%struct_type.a.225] { +// CHECK:STDOUT: %.loc15_14.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc15_14.2: type = converted %.loc15_14.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_struct_type} [template = constants.%struct_type.a.225] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.225 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon b/toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon index 8d83956e94f3..c8da2a8e970a 100644 --- a/toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon +++ b/toolchain/check/testdata/struct/no_prelude/fail_nested_incomplete.carbon @@ -25,6 +25,7 @@ var p: Incomplete* = &s.a; // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %Incomplete} [template] // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -35,9 +36,25 @@ var p: Incomplete* = &s.a; // CHECK:STDOUT: .p = %p // CHECK:STDOUT: } // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: = binding_pattern s +// CHECK:STDOUT: %.loc20_1: = var_pattern %s.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %s.var: ref = var s -// CHECK:STDOUT: %s: ref = bind_name s, %s.var +// CHECK:STDOUT: %.loc20_23: type = splice_block %struct_type.a [template = constants.%struct_type.a] { +// CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] +// CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %Incomplete} [template = constants.%struct_type.a] +// CHECK:STDOUT: } +// CHECK:STDOUT: %s: = bind_name s, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr = binding_pattern p +// CHECK:STDOUT: %.loc22_1: %ptr = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr = var p +// CHECK:STDOUT: %.loc22_18: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %Incomplete.ref.loc22: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] +// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -45,7 +62,7 @@ var p: Incomplete* = &s.a; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %s.ref: ref = name_ref s, file.%s +// CHECK:STDOUT: %s.ref: = name_ref s, file.%s // CHECK:STDOUT: %a.ref: = name_ref a, [template = ] // CHECK:STDOUT: %addr: = addr_of %a.ref [template = ] // CHECK:STDOUT: assign file.%p.var, diff --git a/toolchain/check/testdata/struct/one_entry.carbon b/toolchain/check/testdata/struct/one_entry.carbon index 1338830656ff..b9191f099c6a 100644 --- a/toolchain/check/testdata/struct/one_entry.carbon +++ b/toolchain/check/testdata/struct/one_entry.carbon @@ -45,9 +45,27 @@ var y: {.a: i32} = x; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.ba9 = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.a.ba9 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.ba9 = var x +// CHECK:STDOUT: %.loc11_16: type = splice_block %struct_type.a.loc11 [template = constants.%struct_type.a.ba9] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.loc11: type = struct_type {.a: %i32} [template = constants.%struct_type.a.ba9] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.ba9 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.a.ba9 = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %struct_type.a.ba9 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.a.ba9 = var y +// CHECK:STDOUT: %.loc12_16: type = splice_block %struct_type.a.loc12 [template = constants.%struct_type.a.ba9] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.loc12: type = struct_type {.a: %i32} [template = constants.%struct_type.a.ba9] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %struct_type.a.ba9 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -61,14 +79,14 @@ var y: {.a: i32} = x; // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_4) [template = constants.%int_4.940] // CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_4, %int.convert_checked [template = constants.%int_4.940] // CHECK:STDOUT: %.loc11_27.3: init %struct_type.a.ba9 = struct_init (%.loc11_27.2) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_28: init %struct_type.a.ba9 = converted %.loc11_27.1, %.loc11_27.3 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %struct_type.a.ba9 = converted %.loc11_27.1, %.loc11_27.3 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %struct_type.a.ba9 = name_ref x, file.%x // CHECK:STDOUT: %.loc12_20.1: ref %i32 = struct_access %x.ref, element0 // CHECK:STDOUT: %.loc12_20.2: %i32 = bind_value %.loc12_20.1 // CHECK:STDOUT: %.loc12_20.3: init %struct_type.a.ba9 = struct_init (%.loc12_20.2) to file.%y.var -// CHECK:STDOUT: %.loc12_21: init %struct_type.a.ba9 = converted %x.ref, %.loc12_20.3 -// CHECK:STDOUT: assign file.%y.var, %.loc12_21 +// CHECK:STDOUT: %.loc12_1: init %struct_type.a.ba9 = converted %x.ref, %.loc12_20.3 +// CHECK:STDOUT: assign file.%y.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/reorder_fields.carbon b/toolchain/check/testdata/struct/reorder_fields.carbon index cad7306275c7..f5032b62a733 100644 --- a/toolchain/check/testdata/struct/reorder_fields.carbon +++ b/toolchain/check/testdata/struct/reorder_fields.carbon @@ -76,13 +76,13 @@ fn F() -> {.a: i32, .b: f64} { // CHECK:STDOUT: %return.patt: %struct_type.a.b = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %struct_type.a.b = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] -// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] -// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] -// CHECK:STDOUT: %.loc14_25.1: type = value_of_initializer %float.make_type [template = f64] -// CHECK:STDOUT: %.loc14_25.2: type = converted %float.make_type, %.loc14_25.1 [template = f64] -// CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: f64} [template = constants.%struct_type.a.b] +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_64.loc14: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc14: init type = call constants.%Float(%int_64.loc14) [template = f64] +// CHECK:STDOUT: %.loc14_25.1: type = value_of_initializer %float.make_type.loc14 [template = f64] +// CHECK:STDOUT: %.loc14_25.2: type = converted %float.make_type.loc14, %.loc14_25.1 [template = f64] +// CHECK:STDOUT: %struct_type.a.b.loc14: type = struct_type {.a: %i32, .b: f64} [template = constants.%struct_type.a.b] // CHECK:STDOUT: %return.param: ref %struct_type.a.b = out_param runtime_param0 // CHECK:STDOUT: %return: ref %struct_type.a.b = return_slot %return.param // CHECK:STDOUT: } @@ -94,24 +94,48 @@ fn F() -> {.a: i32, .b: f64} { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> %return.param_patt: %struct_type.a.b { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.b = binding_pattern x +// CHECK:STDOUT: } // CHECK:STDOUT: %MakeF64.ref: %MakeF64.type = name_ref MakeF64, file.%MakeF64.decl [template = constants.%MakeF64] // CHECK:STDOUT: %MakeF64.call: init f64 = call %MakeF64.ref() // CHECK:STDOUT: %MakeI32.ref: %MakeI32.type = name_ref MakeI32, file.%MakeI32.decl [template = constants.%MakeI32] // CHECK:STDOUT: %MakeI32.call: init %i32 = call %MakeI32.ref() // CHECK:STDOUT: %.loc15_62.1: %struct_type.b.a = struct_literal (%MakeF64.call, %MakeI32.call) +// CHECK:STDOUT: %.loc15_27: type = splice_block %struct_type.a.b.loc15 [template = constants.%struct_type.a.b] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_64.loc15: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc15: init type = call constants.%Float(%int_64.loc15) [template = f64] +// CHECK:STDOUT: %.loc15_24.1: type = value_of_initializer %float.make_type.loc15 [template = f64] +// CHECK:STDOUT: %.loc15_24.2: type = converted %float.make_type.loc15, %.loc15_24.1 [template = f64] +// CHECK:STDOUT: %struct_type.a.b.loc15: type = struct_type {.a: %i32, .b: f64} [template = constants.%struct_type.a.b] +// CHECK:STDOUT: } // CHECK:STDOUT: %.loc15_62.2: %i32 = value_of_initializer %MakeI32.call // CHECK:STDOUT: %.loc15_62.3: %i32 = converted %MakeI32.call, %.loc15_62.2 // CHECK:STDOUT: %.loc15_62.4: f64 = value_of_initializer %MakeF64.call // CHECK:STDOUT: %.loc15_62.5: f64 = converted %MakeF64.call, %.loc15_62.4 // CHECK:STDOUT: %struct.loc15: %struct_type.a.b = struct_value (%.loc15_62.3, %.loc15_62.5) -// CHECK:STDOUT: %.loc15_63: %struct_type.a.b = converted %.loc15_62.1, %struct.loc15 -// CHECK:STDOUT: %x: %struct_type.a.b = bind_name x, %.loc15_63 +// CHECK:STDOUT: %.loc15_62.6: %struct_type.a.b = converted %.loc15_62.1, %struct.loc15 +// CHECK:STDOUT: %x: %struct_type.a.b = bind_name x, %.loc15_62.6 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.b.a = binding_pattern y +// CHECK:STDOUT: } // CHECK:STDOUT: %x.ref: %struct_type.a.b = name_ref x, %x +// CHECK:STDOUT: %.loc16_27: type = splice_block %struct_type.b.a [template = constants.%struct_type.b.a] { +// CHECK:STDOUT: %int_64.loc16: Core.IntLiteral = int_value 64 [template = constants.%int_64] +// CHECK:STDOUT: %float.make_type.loc16: init type = call constants.%Float(%int_64.loc16) [template = f64] +// CHECK:STDOUT: %.loc16_15.1: type = value_of_initializer %float.make_type.loc16 [template = f64] +// CHECK:STDOUT: %.loc16_15.2: type = converted %float.make_type.loc16, %.loc16_15.1 [template = f64] +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.b.a: type = struct_type {.b: f64, .a: %i32} [template = constants.%struct_type.b.a] +// CHECK:STDOUT: } // CHECK:STDOUT: %.loc16_31.1: f64 = struct_access %x.ref, element1 // CHECK:STDOUT: %.loc16_31.2: %i32 = struct_access %x.ref, element0 // CHECK:STDOUT: %struct.loc16: %struct_type.b.a = struct_value (%.loc16_31.1, %.loc16_31.2) -// CHECK:STDOUT: %.loc16_32: %struct_type.b.a = converted %x.ref, %struct.loc16 -// CHECK:STDOUT: %y: %struct_type.b.a = bind_name y, %.loc16_32 +// CHECK:STDOUT: %.loc16_31.3: %struct_type.b.a = converted %x.ref, %struct.loc16 +// CHECK:STDOUT: %y: %struct_type.b.a = bind_name y, %.loc16_31.3 // CHECK:STDOUT: %y.ref: %struct_type.b.a = name_ref y, %y // CHECK:STDOUT: %.loc17_10.1: %i32 = struct_access %y.ref, element1 // CHECK:STDOUT: %.loc17_10.2: ref %i32 = struct_access %return, element1 diff --git a/toolchain/check/testdata/struct/tuple_as_element.carbon b/toolchain/check/testdata/struct/tuple_as_element.carbon index 49f675292070..8f6b8865dc89 100644 --- a/toolchain/check/testdata/struct/tuple_as_element.carbon +++ b/toolchain/check/testdata/struct/tuple_as_element.carbon @@ -16,6 +16,7 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %struct_type.a.b.3d5: type = struct_type {.a: %i32, .b: %tuple.type.a1c} [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] @@ -52,9 +53,35 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.b.3d5 = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.a.b.3d5 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.b.3d5 = var x +// CHECK:STDOUT: %.loc11_28: type = splice_block %struct_type.a.b.loc11 [template = constants.%struct_type.a.b.3d5] { +// CHECK:STDOUT: %int_32.loc11_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_27.1: %tuple.type.85c = tuple_literal (%i32.loc11_23) +// CHECK:STDOUT: %.loc11_27.2: type = converted %.loc11_27.1, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: %struct_type.a.b.loc11: type = struct_type {.a: %i32, .b: %tuple.type.a1c} [template = constants.%struct_type.a.b.3d5] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.b.3d5 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.a.b.3d5 = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %struct_type.a.b.3d5 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.a.b.3d5 = var y +// CHECK:STDOUT: %.loc12_28: type = splice_block %struct_type.a.b.loc12 [template = constants.%struct_type.a.b.3d5] { +// CHECK:STDOUT: %int_32.loc12_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc12_23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_27.1: %tuple.type.85c = tuple_literal (%i32.loc12_23) +// CHECK:STDOUT: %.loc12_27.2: type = converted %.loc12_27.1, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: %struct_type.a.b.loc12: type = struct_type {.a: %i32, .b: %tuple.type.a1c} [template = constants.%struct_type.a.b.3d5] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %struct_type.a.b.3d5 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -81,8 +108,8 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc11_50.6: init %tuple.type.a1c = converted %.loc11_49.1, %.loc11_49.3 [template = constants.%tuple] // CHECK:STDOUT: %.loc11_50.7: init %tuple.type.a1c = initialize_from %.loc11_50.6 to %.loc11_50.5 [template = constants.%tuple] // CHECK:STDOUT: %.loc11_50.8: init %struct_type.a.b.3d5 = struct_init (%.loc11_50.4, %.loc11_50.7) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_51: init %struct_type.a.b.3d5 = converted %.loc11_50.1, %.loc11_50.8 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_51 +// CHECK:STDOUT: %.loc11_1: init %struct_type.a.b.3d5 = converted %.loc11_50.1, %.loc11_50.8 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %struct_type.a.b.3d5 = name_ref x, file.%x // CHECK:STDOUT: %.loc12_32.1: ref %i32 = struct_access %x.ref, element0 // CHECK:STDOUT: %.loc12_32.2: %i32 = bind_value %.loc12_32.1 @@ -96,8 +123,8 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc12_32.9: init %tuple.type.a1c = converted %.loc12_32.5, %.loc12_32.8 // CHECK:STDOUT: %.loc12_32.10: init %tuple.type.a1c = initialize_from %.loc12_32.9 to %.loc12_32.7 // CHECK:STDOUT: %.loc12_32.11: init %struct_type.a.b.3d5 = struct_init (%.loc12_32.4, %.loc12_32.10) to file.%y.var -// CHECK:STDOUT: %.loc12_33: init %struct_type.a.b.3d5 = converted %x.ref, %.loc12_32.11 -// CHECK:STDOUT: assign file.%y.var, %.loc12_33 +// CHECK:STDOUT: %.loc12_1: init %struct_type.a.b.3d5 = converted %x.ref, %.loc12_32.11 +// CHECK:STDOUT: assign file.%y.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/two_entries.carbon b/toolchain/check/testdata/struct/two_entries.carbon index e8654391fa0e..db4c16588264 100644 --- a/toolchain/check/testdata/struct/two_entries.carbon +++ b/toolchain/check/testdata/struct/two_entries.carbon @@ -48,15 +48,73 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .v = @__global_init.%v -// CHECK:STDOUT: .w = @__global_init.%w +// CHECK:STDOUT: .v = %v +// CHECK:STDOUT: .w = %w // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %struct_type.a.b.501 = binding_pattern v +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11_25: type = splice_block %struct_type.a.b.loc11 [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc11_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.loc11: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc11_44.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc11_44.1: = bound_method @__global_init.%int_1.loc11, %impl.elem0.loc11_44.1 [template = constants.%Convert.bound.ab5] +// CHECK:STDOUT: %Convert.specific_fn.loc11_44.1: = specific_function %Convert.bound.loc11_44.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] +// CHECK:STDOUT: %int.convert_checked.loc11_44.1: init %i32 = call %Convert.specific_fn.loc11_44.1(@__global_init.%int_1.loc11) [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_44.1: %i32 = value_of_initializer %int.convert_checked.loc11_44.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc11_44.2: %i32 = converted @__global_init.%int_1.loc11, %.loc11_44.1 [template = constants.%int_1.5d2] +// CHECK:STDOUT: %impl.elem0.loc11_44.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc11_44.2: = bound_method @__global_init.%int_2.loc11, %impl.elem0.loc11_44.2 [template = constants.%Convert.bound.ef9] +// CHECK:STDOUT: %Convert.specific_fn.loc11_44.2: = specific_function %Convert.bound.loc11_44.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] +// CHECK:STDOUT: %int.convert_checked.loc11_44.2: init %i32 = call %Convert.specific_fn.loc11_44.2(@__global_init.%int_2.loc11) [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc11_44.3: %i32 = value_of_initializer %int.convert_checked.loc11_44.2 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %.loc11_44.4: %i32 = converted @__global_init.%int_2.loc11, %.loc11_44.3 [template = constants.%int_2.ef8] +// CHECK:STDOUT: %struct: %struct_type.a.b.501 = struct_value (%.loc11_44.2, %.loc11_44.4) [template = constants.%struct] +// CHECK:STDOUT: %.loc11_44.5: %struct_type.a.b.501 = converted @__global_init.%.loc11, %struct [template = constants.%struct] +// CHECK:STDOUT: %v: %struct_type.a.b.501 = bind_name v, %.loc11_44.5 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %struct_type.a.b.501 = binding_pattern w +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc12: type = splice_block %struct_type.a.b.loc12 [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc12_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc12_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.loc12: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: %struct_type.a.b.501 = bind_name w, @__global_init.%v.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.a.b.501 = binding_pattern x +// CHECK:STDOUT: %.loc14_1: %struct_type.a.b.501 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.a.b.501 = var x +// CHECK:STDOUT: %.loc14_25: type = splice_block %struct_type.a.b.loc14 [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc14_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.loc14: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.a.b.501 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.a.b.501 = binding_pattern y +// CHECK:STDOUT: %.loc15_1: %struct_type.a.b.501 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.a.b.501 = var y +// CHECK:STDOUT: %.loc15_25: type = splice_block %struct_type.a.b.loc15 [template = constants.%struct_type.a.b.501] { +// CHECK:STDOUT: %int_32.loc15_13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %struct_type.a.b.loc15: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %struct_type.a.b.501 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -64,24 +122,8 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc11: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] -// CHECK:STDOUT: %.loc11_44.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc11, %int_2.loc11) -// CHECK:STDOUT: %impl.elem0.loc11_44.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11_44.1: = bound_method %int_1.loc11, %impl.elem0.loc11_44.1 [template = constants.%Convert.bound.ab5] -// CHECK:STDOUT: %Convert.specific_fn.loc11_44.1: = specific_function %Convert.bound.loc11_44.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c] -// CHECK:STDOUT: %int.convert_checked.loc11_44.1: init %i32 = call %Convert.specific_fn.loc11_44.1(%int_1.loc11) [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_44.2: %i32 = value_of_initializer %int.convert_checked.loc11_44.1 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %.loc11_44.3: %i32 = converted %int_1.loc11, %.loc11_44.2 [template = constants.%int_1.5d2] -// CHECK:STDOUT: %impl.elem0.loc11_44.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11_44.2: = bound_method %int_2.loc11, %impl.elem0.loc11_44.2 [template = constants.%Convert.bound.ef9] -// CHECK:STDOUT: %Convert.specific_fn.loc11_44.2: = specific_function %Convert.bound.loc11_44.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787] -// CHECK:STDOUT: %int.convert_checked.loc11_44.2: init %i32 = call %Convert.specific_fn.loc11_44.2(%int_2.loc11) [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc11_44.4: %i32 = value_of_initializer %int.convert_checked.loc11_44.2 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %.loc11_44.5: %i32 = converted %int_2.loc11, %.loc11_44.4 [template = constants.%int_2.ef8] -// CHECK:STDOUT: %struct: %struct_type.a.b.501 = struct_value (%.loc11_44.3, %.loc11_44.5) [template = constants.%struct] -// CHECK:STDOUT: %.loc11_45: %struct_type.a.b.501 = converted %.loc11_44.1, %struct [template = constants.%struct] -// CHECK:STDOUT: %v: %struct_type.a.b.501 = bind_name v, %.loc11_45 -// CHECK:STDOUT: %v.ref: %struct_type.a.b.501 = name_ref v, %v -// CHECK:STDOUT: %w: %struct_type.a.b.501 = bind_name w, %v.ref +// CHECK:STDOUT: %.loc11: %struct_type.a.b.cfd = struct_literal (%int_1.loc11, %int_2.loc11) +// CHECK:STDOUT: %v.ref: %struct_type.a.b.501 = name_ref v, file.%v // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %int_2.loc14: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] // CHECK:STDOUT: %.loc14_44.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc14, %int_2.loc14) @@ -100,8 +142,8 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc14_44.6: ref %i32 = struct_access file.%x.var, element1 // CHECK:STDOUT: %.loc14_44.7: init %i32 = initialize_from %.loc14_44.5 to %.loc14_44.6 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc14_44.8: init %struct_type.a.b.501 = struct_init (%.loc14_44.4, %.loc14_44.7) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc14_45: init %struct_type.a.b.501 = converted %.loc14_44.1, %.loc14_44.8 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc14_45 +// CHECK:STDOUT: %.loc14_1: init %struct_type.a.b.501 = converted %.loc14_44.1, %.loc14_44.8 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc14_1 // CHECK:STDOUT: %x.ref: ref %struct_type.a.b.501 = name_ref x, file.%x // CHECK:STDOUT: %.loc15_29.1: ref %i32 = struct_access %x.ref, element0 // CHECK:STDOUT: %.loc15_29.2: %i32 = bind_value %.loc15_29.1 @@ -112,8 +154,8 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc15_29.7: ref %i32 = struct_access file.%y.var, element1 // CHECK:STDOUT: %.loc15_29.8: init %i32 = initialize_from %.loc15_29.6 to %.loc15_29.7 // CHECK:STDOUT: %.loc15_29.9: init %struct_type.a.b.501 = struct_init (%.loc15_29.4, %.loc15_29.8) to file.%y.var -// CHECK:STDOUT: %.loc15_30: init %struct_type.a.b.501 = converted %x.ref, %.loc15_29.9 -// CHECK:STDOUT: assign file.%y.var, %.loc15_30 +// CHECK:STDOUT: %.loc15_1: init %struct_type.a.b.501 = converted %x.ref, %.loc15_29.9 +// CHECK:STDOUT: assign file.%y.var, %.loc15_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/access/element_access.carbon b/toolchain/check/testdata/tuple/access/element_access.carbon index 467f6c02d9ef..4ce3ac5a7217 100644 --- a/toolchain/check/testdata/tuple/access/element_access.carbon +++ b/toolchain/check/testdata/tuple/access/element_access.carbon @@ -17,6 +17,7 @@ var c: i32 = b.0; // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template] @@ -48,11 +49,39 @@ var c: i32 = b.0; // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.a1c = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.a1c = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.a1c = var a +// CHECK:STDOUT: %.loc11_13.1: type = splice_block %.loc11_13.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_13.2: %tuple.type.85c = tuple_literal (%i32.loc11) +// CHECK:STDOUT: %.loc11_13.3: type = converted %.loc11_13.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.a1c = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %tuple.type.a1c = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %tuple.type.a1c = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %tuple.type.a1c = var b +// CHECK:STDOUT: %.loc12_13.1: type = splice_block %.loc12_13.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_13.2: %tuple.type.85c = tuple_literal (%i32.loc12) +// CHECK:STDOUT: %.loc12_13.3: type = converted %.loc12_13.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %tuple.type.a1c = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc13_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc13_8: type = splice_block %i32.loc13 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -66,14 +95,14 @@ var c: i32 = b.0; // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_12) [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_21.2: init %i32 = converted %int_12, %int.convert_checked [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_21.3: init %tuple.type.a1c = tuple_init (%.loc11_21.2) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_22: init %tuple.type.a1c = converted %.loc11_21.1, %.loc11_21.3 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_22 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.a1c = converted %.loc11_21.1, %.loc11_21.3 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.a1c = name_ref a, file.%a // CHECK:STDOUT: %tuple.elem0.loc12: ref %i32 = tuple_access %a.ref, element0 // CHECK:STDOUT: %.loc12_17.1: %i32 = bind_value %tuple.elem0.loc12 // CHECK:STDOUT: %.loc12_17.2: init %tuple.type.a1c = tuple_init (%.loc12_17.1) to file.%b.var -// CHECK:STDOUT: %.loc12_18: init %tuple.type.a1c = converted %a.ref, %.loc12_17.2 -// CHECK:STDOUT: assign file.%b.var, %.loc12_18 +// CHECK:STDOUT: %.loc12_1: init %tuple.type.a1c = converted %a.ref, %.loc12_17.2 +// CHECK:STDOUT: assign file.%b.var, %.loc12_1 // CHECK:STDOUT: %b.ref: ref %tuple.type.a1c = name_ref b, file.%b // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: %tuple.elem0.loc13: ref %i32 = tuple_access %b.ref, element0 diff --git a/toolchain/check/testdata/tuple/access/fail_access_error.carbon b/toolchain/check/testdata/tuple/access/fail_access_error.carbon index b9304b4323f9..5d8771dd4dfe 100644 --- a/toolchain/check/testdata/tuple/access/fail_access_error.carbon +++ b/toolchain/check/testdata/tuple/access/fail_access_error.carbon @@ -20,6 +20,7 @@ var b: i32 = a.(oops); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %int_6.462: Core.IntLiteral = int_value 6 [template] @@ -53,9 +54,29 @@ var b: i32 = a.(oops); // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.d07 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.d07 = var a +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.d07 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -79,8 +100,8 @@ var b: i32 = a.(oops); // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_27.5: init %i32 = initialize_from %.loc11_27.4 to %tuple.elem1 [template = constants.%int_6.e56] // CHECK:STDOUT: %.loc11_27.6: init %tuple.type.d07 = tuple_init (%.loc11_27.3, %.loc11_27.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_28: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.d07 = name_ref a, file.%a // CHECK:STDOUT: %oops.ref: = name_ref oops, [template = ] // CHECK:STDOUT: assign file.%b.var, diff --git a/toolchain/check/testdata/tuple/access/fail_large_index.carbon b/toolchain/check/testdata/tuple/access/fail_large_index.carbon index 2094a9815c45..f213eaf841c9 100644 --- a/toolchain/check/testdata/tuple/access/fail_large_index.carbon +++ b/toolchain/check/testdata/tuple/access/fail_large_index.carbon @@ -26,6 +26,7 @@ var d: i32 = b.(0x7FFF_FFFF); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template] @@ -59,13 +60,49 @@ var d: i32 = b.(0x7FFF_FFFF); // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.a1c = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.a1c = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.a1c = var a +// CHECK:STDOUT: %.loc11_13.1: type = splice_block %.loc11_13.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_13.2: %tuple.type.85c = tuple_literal (%i32.loc11) +// CHECK:STDOUT: %.loc11_13.3: type = converted %.loc11_13.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.a1c = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %tuple.type.a1c = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %tuple.type.a1c = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %tuple.type.a1c = var b +// CHECK:STDOUT: %.loc12_13.1: type = splice_block %.loc12_13.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_13.2: %tuple.type.85c = tuple_literal (%i32.loc12) +// CHECK:STDOUT: %.loc12_13.3: type = converted %.loc12_13.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %tuple.type.a1c = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc17_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc17_8: type = splice_block %i32.loc17 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: %.loc22_1: %i32 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %i32 = var d +// CHECK:STDOUT: %.loc22_8: type = splice_block %i32.loc22 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %i32 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -79,14 +116,14 @@ var d: i32 = b.(0x7FFF_FFFF); // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_12) [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_21.2: init %i32 = converted %int_12, %int.convert_checked [template = constants.%int_12.1e1] // CHECK:STDOUT: %.loc11_21.3: init %tuple.type.a1c = tuple_init (%.loc11_21.2) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_22: init %tuple.type.a1c = converted %.loc11_21.1, %.loc11_21.3 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_22 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.a1c = converted %.loc11_21.1, %.loc11_21.3 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.a1c = name_ref a, file.%a // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %a.ref, element0 // CHECK:STDOUT: %.loc12_17.1: %i32 = bind_value %tuple.elem0 // CHECK:STDOUT: %.loc12_17.2: init %tuple.type.a1c = tuple_init (%.loc12_17.1) to file.%b.var -// CHECK:STDOUT: %.loc12_18: init %tuple.type.a1c = converted %a.ref, %.loc12_17.2 -// CHECK:STDOUT: assign file.%b.var, %.loc12_18 +// CHECK:STDOUT: %.loc12_1: init %tuple.type.a1c = converted %a.ref, %.loc12_17.2 +// CHECK:STDOUT: assign file.%b.var, %.loc12_1 // CHECK:STDOUT: %b.ref.loc17: ref %tuple.type.a1c = name_ref b, file.%b // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: assign file.%c.var, diff --git a/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon b/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon index 4602f740fbf8..1651f47d6724 100644 --- a/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon @@ -20,6 +20,7 @@ var b: i32 = a.(-10); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %int_6.462: Core.IntLiteral = int_value 6 [template] @@ -61,9 +62,29 @@ var b: i32 = a.(-10); // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.d07 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.d07 = var a +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.d07 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -87,8 +108,8 @@ var b: i32 = a.(-10); // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_27.5: init %i32 = initialize_from %.loc11_27.4 to %tuple.elem1 [template = constants.%int_6.e56] // CHECK:STDOUT: %.loc11_27.6: init %tuple.type.d07 = tuple_init (%.loc11_27.3, %.loc11_27.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_28: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.d07 = name_ref a, file.%a // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [template = constants.%int_10] // CHECK:STDOUT: %impl.elem0.loc16: %Op.type.e42 = impl_witness_access constants.%impl_witness.0f6, element0 [template = constants.%Op.bba] diff --git a/toolchain/check/testdata/tuple/access/fail_non_deterministic_type.carbon b/toolchain/check/testdata/tuple/access/fail_non_deterministic_type.carbon index d2f83ba3e960..42464dffdff6 100644 --- a/toolchain/check/testdata/tuple/access/fail_non_deterministic_type.carbon +++ b/toolchain/check/testdata/tuple/access/fail_non_deterministic_type.carbon @@ -21,6 +21,7 @@ var c: i32 = a.(b); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] @@ -59,11 +60,39 @@ var c: i32 = a.(b); // CHECK:STDOUT: .c = %c // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.d07 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.d07 = var a +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.d07 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc12_8: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %i32 = binding_pattern c +// CHECK:STDOUT: %.loc17_1: %i32 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %i32 = var c +// CHECK:STDOUT: %.loc17_8: type = splice_block %i32.loc17 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %i32 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -87,8 +116,8 @@ var c: i32 = a.(b); // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_26.5: init %i32 = initialize_from %.loc11_26.4 to %tuple.elem1 [template = constants.%int_3.822] // CHECK:STDOUT: %.loc11_26.6: init %tuple.type.d07 = tuple_init (%.loc11_26.3, %.loc11_26.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_27: init %tuple.type.d07 = converted %.loc11_26.1, %.loc11_26.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_27 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_26.1, %.loc11_26.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] // CHECK:STDOUT: %Convert.bound.loc12: = bound_method %int_0, %impl.elem0.loc12 [template = constants.%Convert.bound.d04] diff --git a/toolchain/check/testdata/tuple/access/fail_non_int_indexing.carbon b/toolchain/check/testdata/tuple/access/fail_non_int_indexing.carbon index 68f006fa0f29..961c95f4e264 100644 --- a/toolchain/check/testdata/tuple/access/fail_non_int_indexing.carbon +++ b/toolchain/check/testdata/tuple/access/fail_non_int_indexing.carbon @@ -23,6 +23,7 @@ var b: i32 = a.(2.6); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %int_6.462: Core.IntLiteral = int_value 6 [template] @@ -57,9 +58,29 @@ var b: i32 = a.(2.6); // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.d07 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.d07 = var a +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.d07 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc19_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc19_8: type = splice_block %i32.loc19 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc19: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -83,8 +104,8 @@ var b: i32 = a.(2.6); // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_27.5: init %i32 = initialize_from %.loc11_27.4 to %tuple.elem1 [template = constants.%int_6.e56] // CHECK:STDOUT: %.loc11_27.6: init %tuple.type.d07 = tuple_init (%.loc11_27.3, %.loc11_27.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_28: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.d07 = name_ref a, file.%a // CHECK:STDOUT: %float: f64 = float_literal 2.6000000000000001 [template = constants.%float] // CHECK:STDOUT: %.loc19: Core.IntLiteral = converted %float, [template = ] diff --git a/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon b/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon index 00c47afafe27..d400366bef27 100644 --- a/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon +++ b/toolchain/check/testdata/tuple/access/fail_non_tuple_access.carbon @@ -69,8 +69,11 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_0.loc16: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: %int_1.loc16: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %non_tuple.patt: %array_type = binding_pattern non_tuple +// CHECK:STDOUT: %.loc18_3.1: %array_type = var_pattern %non_tuple.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %non_tuple.var: ref %array_type = var non_tuple -// CHECK:STDOUT: %non_tuple: ref %array_type = bind_name non_tuple, %non_tuple.var // CHECK:STDOUT: %int_5.loc18_30: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] // CHECK:STDOUT: %int_5.loc18_33: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b] // CHECK:STDOUT: %.loc18_34.1: %tuple.type = tuple_literal (%int_5.loc18_30, %int_5.loc18_33) @@ -91,13 +94,28 @@ fn Main() { // CHECK:STDOUT: %.loc18_34.6: ref %i32 = array_index %non_tuple.var, %int_1.loc18 // CHECK:STDOUT: %.loc18_34.7: init %i32 = initialize_from %.loc18_34.5 to %.loc18_34.6 [template = constants.%int_5.0f6] // CHECK:STDOUT: %.loc18_34.8: init %array_type = array_init (%.loc18_34.4, %.loc18_34.7) to %non_tuple.var [template = constants.%array] -// CHECK:STDOUT: %.loc18_35: init %array_type = converted %.loc18_34.1, %.loc18_34.8 [template = constants.%array] -// CHECK:STDOUT: assign %non_tuple.var, %.loc18_35 +// CHECK:STDOUT: %.loc18_3.2: init %array_type = converted %.loc18_34.1, %.loc18_34.8 [template = constants.%array] +// CHECK:STDOUT: assign %non_tuple.var, %.loc18_3.2 +// CHECK:STDOUT: %.loc18_25: type = splice_block %array_type [template = constants.%array_type] { +// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] +// CHECK:STDOUT: %array_type: type = array_type %int_2, %i32 [template = constants.%array_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %non_tuple: ref %array_type = bind_name non_tuple, %non_tuple.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %first.patt: %i32 = binding_pattern first +// CHECK:STDOUT: %.loc23_3: %i32 = var_pattern %first.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %first.var: ref %i32 = var first -// CHECK:STDOUT: %first: ref %i32 = bind_name first, %first.var // CHECK:STDOUT: %non_tuple.ref: ref %array_type = name_ref non_tuple, %non_tuple // CHECK:STDOUT: %int_0.loc23: Core.IntLiteral = int_value 0 [template = constants.%int_0] // CHECK:STDOUT: assign %first.var, +// CHECK:STDOUT: %.loc23_14: type = splice_block %i32.loc23 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %first: ref %i32 = bind_name first, %first.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/access/fail_out_of_bound_access.carbon b/toolchain/check/testdata/tuple/access/fail_out_of_bound_access.carbon index b5e43a9ce202..5ce810d4d7fb 100644 --- a/toolchain/check/testdata/tuple/access/fail_out_of_bound_access.carbon +++ b/toolchain/check/testdata/tuple/access/fail_out_of_bound_access.carbon @@ -20,6 +20,7 @@ var b: i32 = a.2; // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %int_6.462: Core.IntLiteral = int_value 6 [template] @@ -54,9 +55,29 @@ var b: i32 = a.2; // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.d07 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.d07 = var a +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.d07 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -80,8 +101,8 @@ var b: i32 = a.2; // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_27.5: init %i32 = initialize_from %.loc11_27.4 to %tuple.elem1 [template = constants.%int_6.e56] // CHECK:STDOUT: %.loc11_27.6: init %tuple.type.d07 = tuple_init (%.loc11_27.3, %.loc11_27.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_28: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_27.1, %.loc11_27.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.d07 = name_ref a, file.%a // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] // CHECK:STDOUT: assign file.%b.var, diff --git a/toolchain/check/testdata/tuple/access/fail_out_of_bound_not_literal.carbon b/toolchain/check/testdata/tuple/access/fail_out_of_bound_not_literal.carbon index c5080197ca23..9f0f75fb9b73 100644 --- a/toolchain/check/testdata/tuple/access/fail_out_of_bound_not_literal.carbon +++ b/toolchain/check/testdata/tuple/access/fail_out_of_bound_not_literal.carbon @@ -20,6 +20,7 @@ var b: i32 = a.({.index = 2}.index); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] // CHECK:STDOUT: %int_34.3f9: Core.IntLiteral = int_value 34 [template] @@ -56,9 +57,29 @@ var b: i32 = a.({.index = 2}.index); // CHECK:STDOUT: .b = %b // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.d07 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.d07 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.d07 = var a +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.d07 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc16_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc16_8: type = splice_block %i32.loc16 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -82,8 +103,8 @@ var b: i32 = a.({.index = 2}.index); // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_28.5: init %i32 = initialize_from %.loc11_28.4 to %tuple.elem1 [template = constants.%int_34.980] // CHECK:STDOUT: %.loc11_28.6: init %tuple.type.d07 = tuple_init (%.loc11_28.3, %.loc11_28.5) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_29: init %tuple.type.d07 = converted %.loc11_28.1, %.loc11_28.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_29 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.d07 = converted %.loc11_28.1, %.loc11_28.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref: ref %tuple.type.d07 = name_ref a, file.%a // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2] // CHECK:STDOUT: %.loc16_28.1: %struct_type.index = struct_literal (%int_2) diff --git a/toolchain/check/testdata/tuple/access/index_not_literal.carbon b/toolchain/check/testdata/tuple/access/index_not_literal.carbon index 32ed6e99b754..237e6d0848bf 100644 --- a/toolchain/check/testdata/tuple/access/index_not_literal.carbon +++ b/toolchain/check/testdata/tuple/access/index_not_literal.carbon @@ -16,8 +16,11 @@ var d: i32 = a.({.index = 1 as i32}.index); // CHECK:STDOUT: --- index_not_literal.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.261: type = tuple_type (bool, %i32) [template] // CHECK:STDOUT: %true: bool = bool_literal true [template] // CHECK:STDOUT: %int_34.3f9: Core.IntLiteral = int_value 34 [template] @@ -76,13 +79,51 @@ var d: i32 = a.({.index = 1 as i32}.index); // CHECK:STDOUT: .d = %d // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.261 = binding_pattern a +// CHECK:STDOUT: %.loc11_1: %tuple.type.261 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.261 = var a +// CHECK:STDOUT: %.loc11_18.1: type = splice_block %.loc11_18.5 [template = constants.%tuple.type.261] { +// CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_18.2: %tuple.type.24b = tuple_literal (%bool.make_type.loc11, %i32.loc11) +// CHECK:STDOUT: %.loc11_18.3: type = value_of_initializer %bool.make_type.loc11 [template = bool] +// CHECK:STDOUT: %.loc11_18.4: type = converted %bool.make_type.loc11, %.loc11_18.3 [template = bool] +// CHECK:STDOUT: %.loc11_18.5: type = converted %.loc11_18.2, constants.%tuple.type.261 [template = constants.%tuple.type.261] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.261 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %i32 = binding_pattern b +// CHECK:STDOUT: %.loc12_1: %i32 = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var b +// CHECK:STDOUT: %.loc12_8: type = splice_block %i32.loc12 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: bool = binding_pattern c +// CHECK:STDOUT: %.loc13_1: bool = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref bool = var c +// CHECK:STDOUT: %.loc13_8.1: type = splice_block %.loc13_8.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc13: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc13_8.2: type = value_of_initializer %bool.make_type.loc13 [template = bool] +// CHECK:STDOUT: %.loc13_8.3: type = converted %bool.make_type.loc13, %.loc13_8.2 [template = bool] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref bool = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %i32 = binding_pattern d +// CHECK:STDOUT: %.loc14_1: %i32 = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %i32 = var d +// CHECK:STDOUT: %.loc14_8: type = splice_block %i32.loc14 [template = constants.%i32] { +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %i32 = bind_name d, %d.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -101,8 +142,8 @@ var d: i32 = a.({.index = 1 as i32}.index); // CHECK:STDOUT: %tuple.elem1.loc11: ref %i32 = tuple_access file.%a.var, element1 // CHECK:STDOUT: %.loc11_31.4: init %i32 = initialize_from %.loc11_31.3 to %tuple.elem1.loc11 [template = constants.%int_34.980] // CHECK:STDOUT: %.loc11_31.5: init %tuple.type.261 = tuple_init (%.loc11_31.2, %.loc11_31.4) to file.%a.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_32: init %tuple.type.261 = converted %.loc11_31.1, %.loc11_31.5 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc11_32 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.261 = converted %.loc11_31.1, %.loc11_31.5 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc11_1 // CHECK:STDOUT: %a.ref.loc12: ref %tuple.type.261 = name_ref a, file.%a // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %.loc12_28.1: %struct_type.index.b1b = struct_literal (%int_1.loc12) diff --git a/toolchain/check/testdata/tuple/fail_assign_nested.carbon b/toolchain/check/testdata/tuple/fail_assign_nested.carbon index d67a5fe9c44d..dc49efb767a7 100644 --- a/toolchain/check/testdata/tuple/fail_assign_nested.carbon +++ b/toolchain/check/testdata/tuple/fail_assign_nested.carbon @@ -19,6 +19,8 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %tuple.type.1c9: type = tuple_type (%tuple.type.24b, %tuple.type.24b) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %tuple.type.ff1: type = tuple_type (%tuple.type.d07, %tuple.type.d07) [template] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] @@ -45,7 +47,27 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.ff1 = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %tuple.type.ff1 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.ff1 = var x +// CHECK:STDOUT: %.loc15_31.1: type = splice_block %.loc15_31.5 [template = constants.%tuple.type.ff1] { +// CHECK:STDOUT: %int_32.loc15_10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_18: %tuple.type.24b = tuple_literal (%i32.loc15_10, %i32.loc15_15) +// CHECK:STDOUT: %int_32.loc15_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_27: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_30: %tuple.type.24b = tuple_literal (%i32.loc15_22, %i32.loc15_27) +// CHECK:STDOUT: %.loc15_31.2: %tuple.type.1c9 = tuple_literal (%.loc15_18, %.loc15_30) +// CHECK:STDOUT: %.loc15_31.3: type = converted %.loc15_18, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: %.loc15_31.4: type = converted %.loc15_30, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: %.loc15_31.5: type = converted %.loc15_31.2, constants.%tuple.type.ff1 [template = constants.%tuple.type.ff1] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.ff1 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/fail_element_type_mismatch.carbon b/toolchain/check/testdata/tuple/fail_element_type_mismatch.carbon index 8a1a829e6d6a..8e408697f178 100644 --- a/toolchain/check/testdata/tuple/fail_element_type_mismatch.carbon +++ b/toolchain/check/testdata/tuple/fail_element_type_mismatch.carbon @@ -22,6 +22,7 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %float: f64 = float_literal 65.890000000000001 [template] @@ -50,7 +51,19 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.d07 = binding_pattern x +// CHECK:STDOUT: %.loc18_1: %tuple.type.d07 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.d07 = var x +// CHECK:STDOUT: %.loc18_17.1: type = splice_block %.loc18_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc18_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_17.2: %tuple.type.24b = tuple_literal (%i32.loc18_9, %i32.loc18_14) +// CHECK:STDOUT: %.loc18_17.3: type = converted %.loc18_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.d07 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/fail_nested_incomplete.carbon b/toolchain/check/testdata/tuple/fail_nested_incomplete.carbon index ceeef727464d..aa9266e48635 100644 --- a/toolchain/check/testdata/tuple/fail_nested_incomplete.carbon +++ b/toolchain/check/testdata/tuple/fail_nested_incomplete.carbon @@ -25,6 +25,10 @@ var p: Incomplete* = &t[1]; // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [template] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %tuple.type.8a4: type = tuple_type (%i32, %Incomplete) [template] // CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [template] // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: } @@ -46,9 +50,28 @@ var p: Incomplete* = &t[1]; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [template = constants.%Incomplete] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %t.patt: = binding_pattern t +// CHECK:STDOUT: %.loc20_1: = var_pattern %t.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %t.var: ref = var t -// CHECK:STDOUT: %t: ref = bind_name t, %t.var +// CHECK:STDOUT: %.loc20_24.1: type = splice_block %.loc20_24.3 [template = constants.%tuple.type.8a4] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] +// CHECK:STDOUT: %.loc20_24.2: %tuple.type.24b = tuple_literal (%i32, %Incomplete.ref.loc20) +// CHECK:STDOUT: %.loc20_24.3: type = converted %.loc20_24.2, constants.%tuple.type.8a4 [template = constants.%tuple.type.8a4] +// CHECK:STDOUT: } +// CHECK:STDOUT: %t: = bind_name t, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %p.patt: %ptr = binding_pattern p +// CHECK:STDOUT: %.loc22_1: %ptr = var_pattern %p.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %p.var: ref %ptr = var p +// CHECK:STDOUT: %.loc22_18: type = splice_block %ptr [template = constants.%ptr] { +// CHECK:STDOUT: %Incomplete.ref.loc22: type = name_ref Incomplete, %Incomplete.decl [template = constants.%Incomplete] +// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [template = constants.%ptr] +// CHECK:STDOUT: } // CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -56,7 +79,7 @@ var p: Incomplete* = &t[1]; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %t.ref: ref = name_ref t, file.%t +// CHECK:STDOUT: %t.ref: = name_ref t, file.%t // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: %addr: = addr_of [template = ] // CHECK:STDOUT: assign file.%p.var, diff --git a/toolchain/check/testdata/tuple/fail_too_few_element.carbon b/toolchain/check/testdata/tuple/fail_too_few_element.carbon index 9fcd7e324a8f..db29db6bb0d5 100644 --- a/toolchain/check/testdata/tuple/fail_too_few_element.carbon +++ b/toolchain/check/testdata/tuple/fail_too_few_element.carbon @@ -19,6 +19,7 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template] @@ -38,7 +39,19 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.d07 = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %tuple.type.d07 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.d07 = var x +// CHECK:STDOUT: %.loc15_17.1: type = splice_block %.loc15_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc15_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_17.2: %tuple.type.24b = tuple_literal (%i32.loc15_9, %i32.loc15_14) +// CHECK:STDOUT: %.loc15_17.3: type = converted %.loc15_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.d07 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/fail_type_assign.carbon b/toolchain/check/testdata/tuple/fail_type_assign.carbon index 150f07860f01..13f37dbfe37b 100644 --- a/toolchain/check/testdata/tuple/fail_type_assign.carbon +++ b/toolchain/check/testdata/tuple/fail_type_assign.carbon @@ -41,7 +41,17 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.a1c = binding_pattern x +// CHECK:STDOUT: %.loc18_1: %tuple.type.a1c = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.a1c = var x +// CHECK:STDOUT: %.loc18_14.1: type = splice_block %.loc18_14.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_14.2: %tuple.type.85c = tuple_literal (%i32) +// CHECK:STDOUT: %.loc18_14.3: type = converted %.loc18_14.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.a1c = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/fail_value_as_type.carbon b/toolchain/check/testdata/tuple/fail_value_as_type.carbon index 760d5ac75b7c..b9f934238373 100644 --- a/toolchain/check/testdata/tuple/fail_value_as_type.carbon +++ b/toolchain/check/testdata/tuple/fail_value_as_type.carbon @@ -20,6 +20,8 @@ var x: (1, ); // CHECK:STDOUT: --- fail_value_as_type.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -36,7 +38,16 @@ var x: (1, ); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: = binding_pattern x +// CHECK:STDOUT: %.loc18_1: = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref = var x -// CHECK:STDOUT: %x: ref = bind_name x, %x.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %.loc18_12.1: %tuple.type = tuple_literal (%int_1) +// CHECK:STDOUT: %.loc18_12.2: type = converted %int_1, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: = bind_name x, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/import.carbon b/toolchain/check/testdata/tuple/import.carbon index 5063de368ca5..5d092d3ca8cd 100644 --- a/toolchain/check/testdata/tuple/import.carbon +++ b/toolchain/check/testdata/tuple/import.carbon @@ -47,10 +47,10 @@ impl package Implicit; // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `C((1, 2))` to `C((3, 4))` [ImplicitAsConversionFailure] // CHECK:STDERR: var c_bad: C((3, 4)) = F(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+4]]:1: note: type `C((1, 2))` does not implement interface `Core.ImplicitAs(C((3, 4)))` [MissingImplInMemberAccessNote] // CHECK:STDERR: var c_bad: C((3, 4)) = F(); -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var c_bad: C((3, 4)) = F(); @@ -59,6 +59,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template] // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template] @@ -70,7 +71,9 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %Convert.specific_fn.d62: = specific_function %Convert.bound.d04, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template] // CHECK:STDOUT: %tuple.592: %tuple.type.a1c = tuple_value (%int_0.6a9) [template] +// CHECK:STDOUT: %tuple.type.8c7: type = tuple_type (%tuple.type.85c, type) [template] // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %tuple.type.58c: type = tuple_type (%tuple.type.8c7, %tuple.type.24b) [template] // CHECK:STDOUT: %tuple.type.fe6: type = tuple_type (%tuple.type.a1c, %i32) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %tuple.type.fc1: type = tuple_type (%tuple.type.fe6, %tuple.type.d07) [template] @@ -122,9 +125,41 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: %tuple.type.a1c = binding_pattern a_ref +// CHECK:STDOUT: %.loc4_1: %tuple.type.a1c = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref %tuple.type.a1c = var a_ref +// CHECK:STDOUT: %.loc4_17.1: type = splice_block %.loc4_17.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc4_17.2: %tuple.type.85c = tuple_literal (%i32.loc4) +// CHECK:STDOUT: %.loc4_17.3: type = converted %.loc4_17.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref: ref %tuple.type.a1c = bind_name a_ref, %a_ref.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b_ref.patt: %tuple.type.fc1 = binding_pattern b_ref +// CHECK:STDOUT: %.loc5_1: %tuple.type.fc1 = var_pattern %b_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ref.var: ref %tuple.type.fc1 = var b_ref +// CHECK:STDOUT: %.loc5_38.1: type = splice_block %.loc5_38.6 [template = constants.%tuple.type.fc1] { +// CHECK:STDOUT: %int_32.loc5_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_19: %tuple.type.85c = tuple_literal (%i32.loc5_15) +// CHECK:STDOUT: %int_32.loc5_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_25: %tuple.type.8c7 = tuple_literal (%.loc5_19, %i32.loc5_22) +// CHECK:STDOUT: %int_32.loc5_29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc5_34: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_34: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_37: %tuple.type.24b = tuple_literal (%i32.loc5_29, %i32.loc5_34) +// CHECK:STDOUT: %.loc5_38.2: %tuple.type.58c = tuple_literal (%.loc5_25, %.loc5_37) +// CHECK:STDOUT: %.loc5_38.3: type = converted %.loc5_19, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: %.loc5_38.4: type = converted %.loc5_25, constants.%tuple.type.fe6 [template = constants.%tuple.type.fe6] +// CHECK:STDOUT: %.loc5_38.5: type = converted %.loc5_37, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: %.loc5_38.6: type = converted %.loc5_38.2, constants.%tuple.type.fc1 [template = constants.%tuple.type.fc1] +// CHECK:STDOUT: } // CHECK:STDOUT: %b_ref: ref %tuple.type.fc1 = bind_name b_ref, %b_ref.var // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] { // CHECK:STDOUT: %X.patt.loc7_9.1: %tuple.type.d07 = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc7_9.2 (constants.%X.patt)] @@ -193,8 +228,8 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %int.convert_checked.loc4: init %i32 = call %Convert.specific_fn.loc4(%int_0.loc4) [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc4_24.2: init %i32 = converted %int_0.loc4, %int.convert_checked.loc4 [template = constants.%int_0.6a9] // CHECK:STDOUT: %.loc4_24.3: init %tuple.type.a1c = tuple_init (%.loc4_24.2) to file.%a_ref.var [template = constants.%tuple.592] -// CHECK:STDOUT: %.loc4_25: init %tuple.type.a1c = converted %.loc4_24.1, %.loc4_24.3 [template = constants.%tuple.592] -// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_25 +// CHECK:STDOUT: %.loc4_1: init %tuple.type.a1c = converted %.loc4_24.1, %.loc4_24.3 [template = constants.%tuple.592] +// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_1 // CHECK:STDOUT: %int_0.loc5: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6] // CHECK:STDOUT: %.loc5_47.1: %tuple.type.985 = tuple_literal (%int_0.loc5) // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] @@ -240,8 +275,8 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %.loc5_59.6: init %tuple.type.d07 = tuple_init (%.loc5_59.3, %.loc5_59.5) to %tuple.elem1.loc5_60 [template = constants.%tuple.11a] // CHECK:STDOUT: %.loc5_60.3: init %tuple.type.d07 = converted %.loc5_59.1, %.loc5_59.6 [template = constants.%tuple.11a] // CHECK:STDOUT: %.loc5_60.4: init %tuple.type.fc1 = tuple_init (%.loc5_60.2, %.loc5_60.3) to file.%b_ref.var [template = constants.%tuple.ba9] -// CHECK:STDOUT: %.loc5_61: init %tuple.type.fc1 = converted %.loc5_60.1, %.loc5_60.4 [template = constants.%tuple.ba9] -// CHECK:STDOUT: assign file.%b_ref.var, %.loc5_61 +// CHECK:STDOUT: %.loc5_1: init %tuple.type.fc1 = converted %.loc5_60.1, %.loc5_60.4 [template = constants.%tuple.ba9] +// CHECK:STDOUT: assign file.%b_ref.var, %.loc5_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -260,7 +295,11 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.dd4: type = tuple_type (%i32) [template] +// CHECK:STDOUT: %tuple.type.8c7: type = tuple_type (%tuple.type.85c, type) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %tuple.type.58c: type = tuple_type (%tuple.type.8c7, %tuple.type.24b) [template] // CHECK:STDOUT: %tuple.type.154: type = tuple_type (%tuple.type.dd4, %i32) [template] // CHECK:STDOUT: %tuple.type.c2c: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %tuple.type.cfa: type = tuple_type (%tuple.type.154, %tuple.type.c2c) [template] @@ -270,7 +309,18 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [template] // CHECK:STDOUT: %X: %tuple.type.c2c = bind_symbolic_name X, 0 [symbolic] // CHECK:STDOUT: %X.patt: %tuple.type.c2c = symbolic_binding_pattern X, 0 [symbolic] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template] +// CHECK:STDOUT: %Convert.type.ea0: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.847: = impl_witness (imports.%import_ref.773), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.e14: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.4cb: %Convert.type.e14 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.dc5: = bound_method %int_1.5b8, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.51b: = specific_function %Convert.bound.dc5, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_1.47b: %i32 = int_value 1 [template] +// CHECK:STDOUT: %Convert.bound.30f: = bound_method %int_2.ecc, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.9b5: = specific_function %Convert.bound.30f, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_2.d0d: %i32 = int_value 2 [template] // CHECK:STDOUT: %tuple: %tuple.type.c2c = tuple_value (%int_1.47b, %int_2.d0d) [template] // CHECK:STDOUT: %C.cf0: type = class_type @C, @C(%tuple) [template] @@ -306,11 +356,68 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %tuple.type.dd4 = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %tuple.type.dd4 = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %tuple.type.dd4 = var a +// CHECK:STDOUT: %.loc4_13.1: type = splice_block %.loc4_13.3 [template = constants.%tuple.type.dd4] { +// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc4_13.2: %tuple.type.85c = tuple_literal (%i32.loc4) +// CHECK:STDOUT: %.loc4_13.3: type = converted %.loc4_13.2, constants.%tuple.type.dd4 [template = constants.%tuple.type.dd4] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %tuple.type.dd4 = bind_name a, %a.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %tuple.type.cfa = binding_pattern b +// CHECK:STDOUT: %.loc5_1: %tuple.type.cfa = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %tuple.type.cfa = var b +// CHECK:STDOUT: %.loc5_34.1: type = splice_block %.loc5_34.6 [template = constants.%tuple.type.cfa] { +// CHECK:STDOUT: %int_32.loc5_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_15: %tuple.type.85c = tuple_literal (%i32.loc5_11) +// CHECK:STDOUT: %int_32.loc5_18: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_18: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_21: %tuple.type.8c7 = tuple_literal (%.loc5_15, %i32.loc5_18) +// CHECK:STDOUT: %int_32.loc5_25: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_25: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc5_30: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc5_30: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc5_33: %tuple.type.24b = tuple_literal (%i32.loc5_25, %i32.loc5_30) +// CHECK:STDOUT: %.loc5_34.2: %tuple.type.58c = tuple_literal (%.loc5_21, %.loc5_33) +// CHECK:STDOUT: %.loc5_34.3: type = converted %.loc5_15, constants.%tuple.type.dd4 [template = constants.%tuple.type.dd4] +// CHECK:STDOUT: %.loc5_34.4: type = converted %.loc5_21, constants.%tuple.type.154 [template = constants.%tuple.type.154] +// CHECK:STDOUT: %.loc5_34.5: type = converted %.loc5_33, constants.%tuple.type.c2c [template = constants.%tuple.type.c2c] +// CHECK:STDOUT: %.loc5_34.6: type = converted %.loc5_34.2, constants.%tuple.type.cfa [template = constants.%tuple.type.cfa] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %tuple.type.cfa = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %C.cf0 = binding_pattern c +// CHECK:STDOUT: %.loc6_1: %C.cf0 = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %C.cf0 = var c +// CHECK:STDOUT: %.loc6_16.1: type = splice_block %C [template = constants.%C.cf0] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %.loc6_15.1: %tuple.type.f94 = tuple_literal (%int_1, %int_2) +// CHECK:STDOUT: %impl.elem0.loc6_15.1: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc6_15.1: = bound_method %int_1, %impl.elem0.loc6_15.1 [template = constants.%Convert.bound.dc5] +// CHECK:STDOUT: %Convert.specific_fn.loc6_15.1: = specific_function %Convert.bound.loc6_15.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.51b] +// CHECK:STDOUT: %int.convert_checked.loc6_15.1: init %i32 = call %Convert.specific_fn.loc6_15.1(%int_1) [template = constants.%int_1.47b] +// CHECK:STDOUT: %.loc6_15.2: %i32 = value_of_initializer %int.convert_checked.loc6_15.1 [template = constants.%int_1.47b] +// CHECK:STDOUT: %.loc6_15.3: %i32 = converted %int_1, %.loc6_15.2 [template = constants.%int_1.47b] +// CHECK:STDOUT: %impl.elem0.loc6_15.2: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc6_15.2: = bound_method %int_2, %impl.elem0.loc6_15.2 [template = constants.%Convert.bound.30f] +// CHECK:STDOUT: %Convert.specific_fn.loc6_15.2: = specific_function %Convert.bound.loc6_15.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.9b5] +// CHECK:STDOUT: %int.convert_checked.loc6_15.2: init %i32 = call %Convert.specific_fn.loc6_15.2(%int_2) [template = constants.%int_2.d0d] +// CHECK:STDOUT: %.loc6_15.4: %i32 = value_of_initializer %int.convert_checked.loc6_15.2 [template = constants.%int_2.d0d] +// CHECK:STDOUT: %.loc6_15.5: %i32 = converted %int_2, %.loc6_15.4 [template = constants.%int_2.d0d] +// CHECK:STDOUT: %tuple: %tuple.type.c2c = tuple_value (%.loc6_15.3, %.loc6_15.5) [template = constants.%tuple] +// CHECK:STDOUT: %.loc6_16.2: %tuple.type.c2c = converted %.loc6_15.1, %tuple [template = constants.%tuple] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%tuple) [template = constants.%C.cf0] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %C.cf0 = bind_name c, %c.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -333,8 +440,8 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %tuple.elem0.loc4: ref %i32 = tuple_access %a_ref.ref, element0 // CHECK:STDOUT: %.loc4_17.1: %i32 = bind_value %tuple.elem0.loc4 // CHECK:STDOUT: %.loc4_17.2: init %tuple.type.dd4 = tuple_init (%.loc4_17.1) to file.%a.var -// CHECK:STDOUT: %.loc4_22: init %tuple.type.dd4 = converted %a_ref.ref, %.loc4_17.2 -// CHECK:STDOUT: assign file.%a.var, %.loc4_22 +// CHECK:STDOUT: %.loc4_1: init %tuple.type.dd4 = converted %a_ref.ref, %.loc4_17.2 +// CHECK:STDOUT: assign file.%a.var, %.loc4_1 // CHECK:STDOUT: %b_ref.ref: ref %tuple.type.cfa = name_ref b_ref, imports.%import_ref.447 // CHECK:STDOUT: %tuple.elem0.loc5_38.1: ref %tuple.type.154 = tuple_access %b_ref.ref, element0 // CHECK:STDOUT: %tuple.elem0.loc5_38.2: ref %tuple.type.dd4 = tuple_access %tuple.elem0.loc5_38.1, element0 @@ -364,8 +471,8 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %.loc5_38.13: init %tuple.type.c2c = tuple_init (%.loc5_38.10, %.loc5_38.12) to %tuple.elem1.loc5_38.4 // CHECK:STDOUT: %.loc5_38.14: init %tuple.type.c2c = converted %tuple.elem1.loc5_38.3, %.loc5_38.13 // CHECK:STDOUT: %.loc5_38.15: init %tuple.type.cfa = tuple_init (%.loc5_38.8, %.loc5_38.14) to file.%b.var -// CHECK:STDOUT: %.loc5_43: init %tuple.type.cfa = converted %b_ref.ref, %.loc5_38.15 -// CHECK:STDOUT: assign file.%b.var, %.loc5_43 +// CHECK:STDOUT: %.loc5_1: init %tuple.type.cfa = converted %b_ref.ref, %.loc5_38.15 +// CHECK:STDOUT: assign file.%b.var, %.loc5_1 // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.b37 [template = constants.%F] // CHECK:STDOUT: %.loc6: ref %C.cf0 = splice_block file.%c.var {} // CHECK:STDOUT: %F.call: init %C.cf0 = call %F.ref() to %.loc6 @@ -397,6 +504,10 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %tuple.type.c2c: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %X: %tuple.type.c2c = bind_symbolic_name X, 0 [symbolic] // CHECK:STDOUT: %X.patt: %tuple.type.c2c = symbolic_binding_pattern X, 0 [symbolic] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] +// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template] +// CHECK:STDOUT: %tuple.type.37f: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [template] // CHECK:STDOUT: %F.type: type = fn_type @F [template] // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %int_2.d0d: %i32 = int_value 2 [template] @@ -429,8 +540,19 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_bad.patt: = binding_pattern c_bad +// CHECK:STDOUT: %.loc12_1: = var_pattern %c_bad.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_bad.var: ref = var c_bad -// CHECK:STDOUT: %c_bad: ref = bind_name c_bad, %c_bad.var +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] +// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %.loc12_22: %tuple.type.37f = tuple_literal (%int_1, %int_2, %int_3) +// CHECK:STDOUT: } +// CHECK:STDOUT: %c_bad: = bind_name c_bad, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @C(constants.%X: %tuple.type.c2c) [from "implicit.carbon"] { @@ -479,7 +601,18 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %tuple.type.c2c: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %X: %tuple.type.c2c = bind_symbolic_name X, 0 [symbolic] // CHECK:STDOUT: %X.patt: %tuple.type.c2c = symbolic_binding_pattern X, 0 [symbolic] +// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template] +// CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template] +// CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template] +// CHECK:STDOUT: %Convert.type.ea0: type = fn_type @Convert.1, @ImplicitAs(%i32) [template] +// CHECK:STDOUT: %impl_witness.847: = impl_witness (imports.%import_ref.773), @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.type.e14: type = fn_type @Convert.2, @impl.1(%int_32) [template] +// CHECK:STDOUT: %Convert.4cb: %Convert.type.e14 = struct_value () [template] +// CHECK:STDOUT: %Convert.bound.a00: = bound_method %int_3.1ba, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.dec: = specific_function %Convert.bound.a00, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_3.d47: %i32 = int_value 3 [template] +// CHECK:STDOUT: %Convert.bound.694: = bound_method %int_4.0c1, %Convert.4cb [template] +// CHECK:STDOUT: %Convert.specific_fn.739: = specific_function %Convert.bound.694, @Convert.2(%int_32) [template] // CHECK:STDOUT: %int_4.ea3: %i32 = int_value 4 [template] // CHECK:STDOUT: %tuple.5de: %tuple.type.c2c = tuple_value (%int_3.d47, %int_4.ea3) [template] // CHECK:STDOUT: %C.ed5: type = class_type @C, @C(%tuple.5de) [template] @@ -516,7 +649,32 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c_bad.patt: %C.ed5 = binding_pattern c_bad +// CHECK:STDOUT: %.loc11_1: %C.ed5 = var_pattern %c_bad.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c_bad.var: ref %C.ed5 = var c_bad +// CHECK:STDOUT: %.loc11_20.1: type = splice_block %C [template = constants.%C.ed5] { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.bb9 [template = constants.%C.generic] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba] +// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1] +// CHECK:STDOUT: %.loc11_19.1: %tuple.type.f94 = tuple_literal (%int_3, %int_4) +// CHECK:STDOUT: %impl.elem0.loc11_19.1: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc11_19.1: = bound_method %int_3, %impl.elem0.loc11_19.1 [template = constants.%Convert.bound.a00] +// CHECK:STDOUT: %Convert.specific_fn.loc11_19.1: = specific_function %Convert.bound.loc11_19.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.dec] +// CHECK:STDOUT: %int.convert_checked.loc11_19.1: init %i32 = call %Convert.specific_fn.loc11_19.1(%int_3) [template = constants.%int_3.d47] +// CHECK:STDOUT: %.loc11_19.2: %i32 = value_of_initializer %int.convert_checked.loc11_19.1 [template = constants.%int_3.d47] +// CHECK:STDOUT: %.loc11_19.3: %i32 = converted %int_3, %.loc11_19.2 [template = constants.%int_3.d47] +// CHECK:STDOUT: %impl.elem0.loc11_19.2: %Convert.type.ea0 = impl_witness_access constants.%impl_witness.847, element0 [template = constants.%Convert.4cb] +// CHECK:STDOUT: %Convert.bound.loc11_19.2: = bound_method %int_4, %impl.elem0.loc11_19.2 [template = constants.%Convert.bound.694] +// CHECK:STDOUT: %Convert.specific_fn.loc11_19.2: = specific_function %Convert.bound.loc11_19.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.739] +// CHECK:STDOUT: %int.convert_checked.loc11_19.2: init %i32 = call %Convert.specific_fn.loc11_19.2(%int_4) [template = constants.%int_4.ea3] +// CHECK:STDOUT: %.loc11_19.4: %i32 = value_of_initializer %int.convert_checked.loc11_19.2 [template = constants.%int_4.ea3] +// CHECK:STDOUT: %.loc11_19.5: %i32 = converted %int_4, %.loc11_19.4 [template = constants.%int_4.ea3] +// CHECK:STDOUT: %tuple: %tuple.type.c2c = tuple_value (%.loc11_19.3, %.loc11_19.5) [template = constants.%tuple.5de] +// CHECK:STDOUT: %.loc11_20.2: %tuple.type.c2c = converted %.loc11_19.1, %tuple [template = constants.%tuple.5de] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%tuple.5de) [template = constants.%C.ed5] +// CHECK:STDOUT: } // CHECK:STDOUT: %c_bad: ref %C.ed5 = bind_name c_bad, %c_bad.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -538,7 +696,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.b37 [template = constants.%F] // CHECK:STDOUT: %.loc11_26: ref %C.cf0 = temporary_storage // CHECK:STDOUT: %F.call: init %C.cf0 = call %F.ref() to %.loc11_26 -// CHECK:STDOUT: %.loc11_27: %C.ed5 = converted %F.call, [template = ] +// CHECK:STDOUT: %.loc11_1: %C.ed5 = converted %F.call, [template = ] // CHECK:STDOUT: assign file.%c_bad.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuple/nested_tuple.carbon b/toolchain/check/testdata/tuple/nested_tuple.carbon index 52f2fa694a49..3ca71fddee3d 100644 --- a/toolchain/check/testdata/tuple/nested_tuple.carbon +++ b/toolchain/check/testdata/tuple/nested_tuple.carbon @@ -15,6 +15,8 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] +// CHECK:STDOUT: %tuple.type.45d: type = tuple_type (%tuple.type.24b, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %tuple.type.f72: type = tuple_type (%tuple.type.d07, %i32) [template] // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template] @@ -54,7 +56,23 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.f72 = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %tuple.type.f72 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.f72 = var x +// CHECK:STDOUT: %.loc11_24.1: type = splice_block %.loc11_24.4 [template = constants.%tuple.type.f72] { +// CHECK:STDOUT: %int_32.loc11_10: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_15: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_18: %tuple.type.24b = tuple_literal (%i32.loc11_10, %i32.loc11_15) +// CHECK:STDOUT: %int_32.loc11_21: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_21: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_24.2: %tuple.type.45d = tuple_literal (%.loc11_18, %i32.loc11_21) +// CHECK:STDOUT: %.loc11_24.3: type = converted %.loc11_18, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: %.loc11_24.4: type = converted %.loc11_24.2, constants.%tuple.type.f72 [template = constants.%tuple.type.f72] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.f72 = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -90,8 +108,8 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: %tuple.elem1.loc11_40: ref %i32 = tuple_access file.%x.var, element1 // CHECK:STDOUT: %.loc11_40.4: init %i32 = initialize_from %.loc11_40.3 to %tuple.elem1.loc11_40 [template = constants.%int_6.e56] // CHECK:STDOUT: %.loc11_40.5: init %tuple.type.f72 = tuple_init (%.loc11_40.2, %.loc11_40.4) to file.%x.var [template = constants.%tuple.51f] -// CHECK:STDOUT: %.loc11_41: init %tuple.type.f72 = converted %.loc11_40.1, %.loc11_40.5 [template = constants.%tuple.51f] -// CHECK:STDOUT: assign file.%x.var, %.loc11_41 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.f72 = converted %.loc11_40.1, %.loc11_40.5 [template = constants.%tuple.51f] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/nested_tuple_in_place.carbon b/toolchain/check/testdata/tuple/nested_tuple_in_place.carbon index 0dbee0fb5246..8777c2fe070f 100644 --- a/toolchain/check/testdata/tuple/nested_tuple_in_place.carbon +++ b/toolchain/check/testdata/tuple/nested_tuple_in_place.carbon @@ -29,9 +29,11 @@ fn H() { // CHECK:STDOUT: %F: %F.type = struct_value () [template] // CHECK:STDOUT: %G.type: type = fn_type @G [template] // CHECK:STDOUT: %G: %G.type = struct_value () [template] +// CHECK:STDOUT: %tuple.type.f9f: type = tuple_type (%tuple.type.ff9, %tuple.type.ff9) [template] // CHECK:STDOUT: %tuple.type.99b: type = tuple_type (%tuple.type.189, %tuple.type.189) [template] // CHECK:STDOUT: %H.type: type = fn_type @H [template] // CHECK:STDOUT: %H: %H.type = struct_value () [template] +// CHECK:STDOUT: %tuple.type.3a3: type = tuple_type (type, %tuple.type.ff9, type) [template] // CHECK:STDOUT: %tuple.type.516: type = tuple_type (%i32, %tuple.type.189, %i32) [template] // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template] @@ -88,8 +90,11 @@ fn H() { // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %tuple.type.99b = binding_pattern v +// CHECK:STDOUT: %.loc14_3.1: %tuple.type.99b = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %tuple.type.99b = var v -// CHECK:STDOUT: %v: ref %tuple.type.99b = bind_name v, %v.var // CHECK:STDOUT: %F.ref.loc14_48: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %tuple.elem0: ref %tuple.type.189 = tuple_access %v.var, element0 // CHECK:STDOUT: %F.call.loc14_50: init %tuple.type.189 = call %F.ref.loc14_48() to %tuple.elem0 @@ -98,15 +103,39 @@ fn H() { // CHECK:STDOUT: %F.call.loc14_55: init %tuple.type.189 = call %F.ref.loc14_53() to %tuple.elem1 // CHECK:STDOUT: %.loc14_56.1: %tuple.type.99b = tuple_literal (%F.call.loc14_50, %F.call.loc14_55) // CHECK:STDOUT: %.loc14_56.2: init %tuple.type.99b = tuple_init (%F.call.loc14_50, %F.call.loc14_55) to %v.var -// CHECK:STDOUT: %.loc14_57: init %tuple.type.99b = converted %.loc14_56.1, %.loc14_56.2 -// CHECK:STDOUT: assign %v.var, %.loc14_57 +// CHECK:STDOUT: %.loc14_3.2: init %tuple.type.99b = converted %.loc14_56.1, %.loc14_56.2 +// CHECK:STDOUT: assign %v.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_43.1: type = splice_block %.loc14_43.5 [template = constants.%tuple.type.99b] { +// CHECK:STDOUT: %int_32.loc14_12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_25: %tuple.type.ff9 = tuple_literal (%i32.loc14_12, %i32.loc14_17, %i32.loc14_22) +// CHECK:STDOUT: %int_32.loc14_29: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_34: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_34: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_39: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_39: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_42: %tuple.type.ff9 = tuple_literal (%i32.loc14_29, %i32.loc14_34, %i32.loc14_39) +// CHECK:STDOUT: %.loc14_43.2: %tuple.type.f9f = tuple_literal (%.loc14_25, %.loc14_42) +// CHECK:STDOUT: %.loc14_43.3: type = converted %.loc14_25, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: %.loc14_43.4: type = converted %.loc14_42, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: %.loc14_43.5: type = converted %.loc14_43.2, constants.%tuple.type.99b [template = constants.%tuple.type.99b] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %tuple.type.99b = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @H() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %tuple.type.516 = binding_pattern v +// CHECK:STDOUT: %.loc18_3.1: %tuple.type.516 = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %tuple.type.516 = var v -// CHECK:STDOUT: %v: ref %tuple.type.516 = bind_name v, %v.var // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8] // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] // CHECK:STDOUT: %tuple.elem1: ref %tuple.type.189 = tuple_access %v.var, element1 @@ -128,8 +157,25 @@ fn H() { // CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %v.var, element2 // CHECK:STDOUT: %.loc18_50.5: init %i32 = initialize_from %.loc18_50.4 to %tuple.elem2 [template = constants.%int_2.ef8] // CHECK:STDOUT: %.loc18_50.6: init %tuple.type.516 = tuple_init (%.loc18_50.3, %F.call, %.loc18_50.5) to %v.var -// CHECK:STDOUT: %.loc18_51: init %tuple.type.516 = converted %.loc18_50.1, %.loc18_50.6 -// CHECK:STDOUT: assign %v.var, %.loc18_51 +// CHECK:STDOUT: %.loc18_3.2: init %tuple.type.516 = converted %.loc18_50.1, %.loc18_50.6 +// CHECK:STDOUT: assign %v.var, %.loc18_3.2 +// CHECK:STDOUT: %.loc18_36.1: type = splice_block %.loc18_36.4 [template = constants.%tuple.type.516] { +// CHECK:STDOUT: %int_32.loc18_11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_17: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_22: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc18_27: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_30: %tuple.type.ff9 = tuple_literal (%i32.loc18_17, %i32.loc18_22, %i32.loc18_27) +// CHECK:STDOUT: %int_32.loc18_33: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc18_33: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc18_36.2: %tuple.type.3a3 = tuple_literal (%i32.loc18_11, %.loc18_30, %i32.loc18_33) +// CHECK:STDOUT: %.loc18_36.3: type = converted %.loc18_30, constants.%tuple.type.189 [template = constants.%tuple.type.189] +// CHECK:STDOUT: %.loc18_36.4: type = converted %.loc18_36.2, constants.%tuple.type.516 [template = constants.%tuple.type.516] +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: ref %tuple.type.516 = bind_name v, %v.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/no_prelude/empty.carbon b/toolchain/check/testdata/tuple/no_prelude/empty.carbon index b12481d3a2f2..de6b1d09dc74 100644 --- a/toolchain/check/testdata/tuple/no_prelude/empty.carbon +++ b/toolchain/check/testdata/tuple/no_prelude/empty.carbon @@ -23,9 +23,25 @@ var y: () = x; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc11_9.1: type = splice_block %.loc11_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc11_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_9.3: type = converted %.loc11_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %empty_tuple.type = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %empty_tuple.type = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %empty_tuple.type = var y +// CHECK:STDOUT: %.loc12_9.1: type = splice_block %.loc12_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_9.3: type = converted %.loc12_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %empty_tuple.type = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -33,12 +49,12 @@ var y: () = x; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_14.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc11_14.2: init %empty_tuple.type = tuple_init () to file.%x.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc11_15: init %empty_tuple.type = converted %.loc11_14.1, %.loc11_14.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%x.var, %.loc11_15 +// CHECK:STDOUT: %.loc11_1: init %empty_tuple.type = converted %.loc11_14.1, %.loc11_14.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %empty_tuple.type = name_ref x, file.%x // CHECK:STDOUT: %.loc12_13: init %empty_tuple.type = tuple_init () to file.%y.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_14: init %empty_tuple.type = converted %x.ref, %.loc12_13 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%y.var, %.loc12_14 +// CHECK:STDOUT: %.loc12_1: init %empty_tuple.type = converted %x.ref, %.loc12_13 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%y.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/no_prelude/fail_assign_empty.carbon b/toolchain/check/testdata/tuple/no_prelude/fail_assign_empty.carbon index 81e5d3429562..36a6356b354d 100644 --- a/toolchain/check/testdata/tuple/no_prelude/fail_assign_empty.carbon +++ b/toolchain/check/testdata/tuple/no_prelude/fail_assign_empty.carbon @@ -25,7 +25,17 @@ var x: ((),) = (); // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type = var x +// CHECK:STDOUT: %.loc15_12.1: type = splice_block %.loc15_12.4 [template = constants.%tuple.type] { +// CHECK:STDOUT: %.loc15_10: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_12.2: %tuple.type = tuple_literal (%.loc15_10) +// CHECK:STDOUT: %.loc15_12.3: type = converted %.loc15_10, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc15_12.4: type = converted %.loc15_12.2, constants.%tuple.type [template = constants.%tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/no_prelude/fail_assign_to_empty.carbon b/toolchain/check/testdata/tuple/no_prelude/fail_assign_to_empty.carbon index 8ccf40a6bfdb..bc8a4866f0fd 100644 --- a/toolchain/check/testdata/tuple/no_prelude/fail_assign_to_empty.carbon +++ b/toolchain/check/testdata/tuple/no_prelude/fail_assign_to_empty.carbon @@ -25,7 +25,15 @@ var x: () = ((),); // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc15_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc15_9.1: type = splice_block %.loc15_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc15_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_9.3: type = converted %.loc15_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/one_element.carbon b/toolchain/check/testdata/tuple/one_element.carbon index d5a1b2834142..382690f041d2 100644 --- a/toolchain/check/testdata/tuple/one_element.carbon +++ b/toolchain/check/testdata/tuple/one_element.carbon @@ -16,6 +16,7 @@ var y: (i32,) = x; // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template] // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template] // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template] // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template] @@ -45,9 +46,29 @@ var y: (i32,) = x; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.a1c = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %tuple.type.a1c = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.a1c = var x +// CHECK:STDOUT: %.loc11_13.1: type = splice_block %.loc11_13.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_13.2: %tuple.type.85c = tuple_literal (%i32.loc11) +// CHECK:STDOUT: %.loc11_13.3: type = converted %.loc11_13.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.a1c = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %tuple.type.a1c = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %tuple.type.a1c = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %tuple.type.a1c = var y +// CHECK:STDOUT: %.loc12_13.1: type = splice_block %.loc12_13.3 [template = constants.%tuple.type.a1c] { +// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_13.2: %tuple.type.85c = tuple_literal (%i32.loc12) +// CHECK:STDOUT: %.loc12_13.3: type = converted %.loc12_13.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %tuple.type.a1c = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -61,14 +82,14 @@ var y: (i32,) = x; // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_4) [template = constants.%int_4.940] // CHECK:STDOUT: %.loc11_20.2: init %i32 = converted %int_4, %int.convert_checked [template = constants.%int_4.940] // CHECK:STDOUT: %.loc11_20.3: init %tuple.type.a1c = tuple_init (%.loc11_20.2) to file.%x.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_21: init %tuple.type.a1c = converted %.loc11_20.1, %.loc11_20.3 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%x.var, %.loc11_21 +// CHECK:STDOUT: %.loc11_1: init %tuple.type.a1c = converted %.loc11_20.1, %.loc11_20.3 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %tuple.type.a1c = name_ref x, file.%x // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %x.ref, element0 // CHECK:STDOUT: %.loc12_17.1: %i32 = bind_value %tuple.elem0 // CHECK:STDOUT: %.loc12_17.2: init %tuple.type.a1c = tuple_init (%.loc12_17.1) to file.%y.var -// CHECK:STDOUT: %.loc12_18: init %tuple.type.a1c = converted %x.ref, %.loc12_17.2 -// CHECK:STDOUT: assign file.%y.var, %.loc12_18 +// CHECK:STDOUT: %.loc12_1: init %tuple.type.a1c = converted %x.ref, %.loc12_17.2 +// CHECK:STDOUT: assign file.%y.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/tuple/two_elements.carbon b/toolchain/check/testdata/tuple/two_elements.carbon index 86bd3f68aaab..e9029ffaeaa6 100644 --- a/toolchain/check/testdata/tuple/two_elements.carbon +++ b/toolchain/check/testdata/tuple/two_elements.carbon @@ -19,6 +19,7 @@ var y: (i32, i32) = x; // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template] +// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template] // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template] // CHECK:STDOUT: %int_102.b54: Core.IntLiteral = int_value 102 [template] @@ -48,15 +49,77 @@ var y: (i32, i32) = x; // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .v = @__global_init.%v -// CHECK:STDOUT: .w = @__global_init.%w +// CHECK:STDOUT: .v = %v +// CHECK:STDOUT: .w = %w // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %tuple.type.d07 = binding_pattern v +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc11_17.1: type = splice_block %.loc11_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc11_17.2: %tuple.type.24b = tuple_literal (%i32.loc11_9, %i32.loc11_14) +// CHECK:STDOUT: %.loc11_17.3: type = converted %.loc11_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %impl.elem0.loc11_28.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc11_28.1: = bound_method @__global_init.%int_4.loc11, %impl.elem0.loc11_28.1 [template = constants.%Convert.bound.ac3] +// CHECK:STDOUT: %Convert.specific_fn.loc11_28.1: = specific_function %Convert.bound.loc11_28.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450] +// CHECK:STDOUT: %int.convert_checked.loc11_28.1: init %i32 = call %Convert.specific_fn.loc11_28.1(@__global_init.%int_4.loc11) [template = constants.%int_4.940] +// CHECK:STDOUT: %.loc11_28.1: %i32 = value_of_initializer %int.convert_checked.loc11_28.1 [template = constants.%int_4.940] +// CHECK:STDOUT: %.loc11_28.2: %i32 = converted @__global_init.%int_4.loc11, %.loc11_28.1 [template = constants.%int_4.940] +// CHECK:STDOUT: %impl.elem0.loc11_28.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] +// CHECK:STDOUT: %Convert.bound.loc11_28.2: = bound_method @__global_init.%int_102.loc11, %impl.elem0.loc11_28.2 [template = constants.%Convert.bound.063] +// CHECK:STDOUT: %Convert.specific_fn.loc11_28.2: = specific_function %Convert.bound.loc11_28.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.9b4] +// CHECK:STDOUT: %int.convert_checked.loc11_28.2: init %i32 = call %Convert.specific_fn.loc11_28.2(@__global_init.%int_102.loc11) [template = constants.%int_102.b91] +// CHECK:STDOUT: %.loc11_28.3: %i32 = value_of_initializer %int.convert_checked.loc11_28.2 [template = constants.%int_102.b91] +// CHECK:STDOUT: %.loc11_28.4: %i32 = converted @__global_init.%int_102.loc11, %.loc11_28.3 [template = constants.%int_102.b91] +// CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%.loc11_28.2, %.loc11_28.4) [template = constants.%tuple] +// CHECK:STDOUT: %.loc11_28.5: %tuple.type.d07 = converted @__global_init.%.loc11, %tuple [template = constants.%tuple] +// CHECK:STDOUT: %v: %tuple.type.d07 = bind_name v, %.loc11_28.5 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %tuple.type.d07 = binding_pattern w +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc12_17.1: type = splice_block %.loc12_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc12_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc12_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc12_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc12_17.2: %tuple.type.24b = tuple_literal (%i32.loc12_9, %i32.loc12_14) +// CHECK:STDOUT: %.loc12_17.3: type = converted %.loc12_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } +// CHECK:STDOUT: %w: %tuple.type.d07 = bind_name w, @__global_init.%v.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %tuple.type.d07 = binding_pattern x +// CHECK:STDOUT: %.loc14_1: %tuple.type.d07 = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %tuple.type.d07 = var x +// CHECK:STDOUT: %.loc14_17.1: type = splice_block %.loc14_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc14_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc14_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc14_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc14_17.2: %tuple.type.24b = tuple_literal (%i32.loc14_9, %i32.loc14_14) +// CHECK:STDOUT: %.loc14_17.3: type = converted %.loc14_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %tuple.type.d07 = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %tuple.type.d07 = binding_pattern y +// CHECK:STDOUT: %.loc15_1: %tuple.type.d07 = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %tuple.type.d07 = var y +// CHECK:STDOUT: %.loc15_17.1: type = splice_block %.loc15_17.3 [template = constants.%tuple.type.d07] { +// CHECK:STDOUT: %int_32.loc15_9: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %int_32.loc15_14: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32.loc15_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc15_17.2: %tuple.type.24b = tuple_literal (%i32.loc15_9, %i32.loc15_14) +// CHECK:STDOUT: %.loc15_17.3: type = converted %.loc15_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %tuple.type.d07 = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -64,24 +127,8 @@ var y: (i32, i32) = x; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_4.loc11: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1] // CHECK:STDOUT: %int_102.loc11: Core.IntLiteral = int_value 102 [template = constants.%int_102.b54] -// CHECK:STDOUT: %.loc11_28.1: %tuple.type.f94 = tuple_literal (%int_4.loc11, %int_102.loc11) -// CHECK:STDOUT: %impl.elem0.loc11_28.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11_28.1: = bound_method %int_4.loc11, %impl.elem0.loc11_28.1 [template = constants.%Convert.bound.ac3] -// CHECK:STDOUT: %Convert.specific_fn.loc11_28.1: = specific_function %Convert.bound.loc11_28.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450] -// CHECK:STDOUT: %int.convert_checked.loc11_28.1: init %i32 = call %Convert.specific_fn.loc11_28.1(%int_4.loc11) [template = constants.%int_4.940] -// CHECK:STDOUT: %.loc11_28.2: %i32 = value_of_initializer %int.convert_checked.loc11_28.1 [template = constants.%int_4.940] -// CHECK:STDOUT: %.loc11_28.3: %i32 = converted %int_4.loc11, %.loc11_28.2 [template = constants.%int_4.940] -// CHECK:STDOUT: %impl.elem0.loc11_28.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956] -// CHECK:STDOUT: %Convert.bound.loc11_28.2: = bound_method %int_102.loc11, %impl.elem0.loc11_28.2 [template = constants.%Convert.bound.063] -// CHECK:STDOUT: %Convert.specific_fn.loc11_28.2: = specific_function %Convert.bound.loc11_28.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.9b4] -// CHECK:STDOUT: %int.convert_checked.loc11_28.2: init %i32 = call %Convert.specific_fn.loc11_28.2(%int_102.loc11) [template = constants.%int_102.b91] -// CHECK:STDOUT: %.loc11_28.4: %i32 = value_of_initializer %int.convert_checked.loc11_28.2 [template = constants.%int_102.b91] -// CHECK:STDOUT: %.loc11_28.5: %i32 = converted %int_102.loc11, %.loc11_28.4 [template = constants.%int_102.b91] -// CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%.loc11_28.3, %.loc11_28.5) [template = constants.%tuple] -// CHECK:STDOUT: %.loc11_29: %tuple.type.d07 = converted %.loc11_28.1, %tuple [template = constants.%tuple] -// CHECK:STDOUT: %v: %tuple.type.d07 = bind_name v, %.loc11_29 -// CHECK:STDOUT: %v.ref: %tuple.type.d07 = name_ref v, %v -// CHECK:STDOUT: %w: %tuple.type.d07 = bind_name w, %v.ref +// CHECK:STDOUT: %.loc11: %tuple.type.f94 = tuple_literal (%int_4.loc11, %int_102.loc11) +// CHECK:STDOUT: %v.ref: %tuple.type.d07 = name_ref v, file.%v // CHECK:STDOUT: %int_4.loc14: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1] // CHECK:STDOUT: %int_102.loc14: Core.IntLiteral = int_value 102 [template = constants.%int_102.b54] // CHECK:STDOUT: %.loc14_28.1: %tuple.type.f94 = tuple_literal (%int_4.loc14, %int_102.loc14) @@ -100,8 +147,8 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %tuple.elem1.loc14: ref %i32 = tuple_access file.%x.var, element1 // CHECK:STDOUT: %.loc14_28.5: init %i32 = initialize_from %.loc14_28.4 to %tuple.elem1.loc14 [template = constants.%int_102.b91] // CHECK:STDOUT: %.loc14_28.6: init %tuple.type.d07 = tuple_init (%.loc14_28.3, %.loc14_28.5) to file.%x.var [template = constants.%tuple] -// CHECK:STDOUT: %.loc14_29: init %tuple.type.d07 = converted %.loc14_28.1, %.loc14_28.6 [template = constants.%tuple] -// CHECK:STDOUT: assign file.%x.var, %.loc14_29 +// CHECK:STDOUT: %.loc14_1: init %tuple.type.d07 = converted %.loc14_28.1, %.loc14_28.6 [template = constants.%tuple] +// CHECK:STDOUT: assign file.%x.var, %.loc14_1 // CHECK:STDOUT: %x.ref: ref %tuple.type.d07 = name_ref x, file.%x // CHECK:STDOUT: %tuple.elem0.loc15_21.1: ref %i32 = tuple_access %x.ref, element0 // CHECK:STDOUT: %.loc15_21.1: %i32 = bind_value %tuple.elem0.loc15_21.1 @@ -112,8 +159,8 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %tuple.elem1.loc15_21.2: ref %i32 = tuple_access file.%y.var, element1 // CHECK:STDOUT: %.loc15_21.4: init %i32 = initialize_from %.loc15_21.3 to %tuple.elem1.loc15_21.2 // CHECK:STDOUT: %.loc15_21.5: init %tuple.type.d07 = tuple_init (%.loc15_21.2, %.loc15_21.4) to file.%y.var -// CHECK:STDOUT: %.loc15_22: init %tuple.type.d07 = converted %x.ref, %.loc15_21.5 -// CHECK:STDOUT: assign file.%y.var, %.loc15_22 +// CHECK:STDOUT: %.loc15_1: init %tuple.type.d07 = converted %x.ref, %.loc15_21.5 +// CHECK:STDOUT: assign file.%y.var, %.loc15_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_not_copyable.carbon b/toolchain/check/testdata/var/fail_not_copyable.carbon index fcf2f5039ea4..d4e8c65dfb22 100644 --- a/toolchain/check/testdata/var/fail_not_copyable.carbon +++ b/toolchain/check/testdata/var/fail_not_copyable.carbon @@ -59,7 +59,7 @@ fn F(x: X) { // CHECK:STDOUT: %x.param_patt: %X = value_param_pattern %x.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %x.param: %X = value_param runtime_param0 -// CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %X.ref.loc14: type = name_ref X, file.%X.decl [template = constants.%X] // CHECK:STDOUT: %x: %X = bind_name x, %x.param // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -71,14 +71,23 @@ fn F(x: X) { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%x.param_patt: %X) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %s.patt: String = binding_pattern s +// CHECK:STDOUT: %.loc21: String = var_pattern %s.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %s.var: ref String = var s -// CHECK:STDOUT: %s: ref String = bind_name s, %s.var // CHECK:STDOUT: %str: String = string_literal "hello" [template = constants.%str] // CHECK:STDOUT: assign %s.var, +// CHECK:STDOUT: %s: ref String = bind_name s, %s.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %X = binding_pattern y +// CHECK:STDOUT: %.loc28: %X = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %X = var y -// CHECK:STDOUT: %y: ref %X = bind_name y, %y.var // CHECK:STDOUT: %x.ref: %X = name_ref x, %x // CHECK:STDOUT: assign %y.var, +// CHECK:STDOUT: %X.ref.loc28: type = name_ref X, file.%X.decl [template = constants.%X] +// CHECK:STDOUT: %y: ref %X = bind_name y, %y.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_storage_is_literal.carbon b/toolchain/check/testdata/var/fail_storage_is_literal.carbon index b4e70ceac6e8..89678773472b 100644 --- a/toolchain/check/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/check/testdata/var/fail_storage_is_literal.carbon @@ -46,10 +46,18 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: = binding_pattern x +// CHECK:STDOUT: %.loc19_3: = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref = var x -// CHECK:STDOUT: %x: ref = bind_name x, %x.var -// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %int_1.loc19_14: Core.IntLiteral = int_value 1 [template = constants.%int_1] // CHECK:STDOUT: assign %x.var, +// CHECK:STDOUT: %.1: = splice_block [template = ] { +// CHECK:STDOUT: %int_1.loc19_10: Core.IntLiteral = int_value 1 [template = constants.%int_1] +// CHECK:STDOUT: %.loc19_10: type = converted %int_1.loc19_10, [template = ] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: = bind_name x, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon b/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon index d877a962765b..b6ae2d43ab5c 100644 --- a/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon +++ b/toolchain/check/testdata/var/fail_todo_control_flow_init.carbon @@ -77,6 +77,8 @@ var y2: bool = false or true; // CHECK:STDOUT: constants { // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %true: bool = bool_literal true [template] +// CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template] +// CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -96,13 +98,47 @@ var y2: bool = false or true; // CHECK:STDOUT: .y2 = %y2 // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc27_1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc27_9.1: type = splice_block %.loc27_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc27_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc27_9.3: type = converted %.loc27_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x2.patt: %empty_tuple.type = binding_pattern x2 +// CHECK:STDOUT: %.loc45_1: %empty_tuple.type = var_pattern %x2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x2.var: ref %empty_tuple.type = var x2 +// CHECK:STDOUT: %.loc45_10.1: type = splice_block %.loc45_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc45_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc45_10.3: type = converted %.loc45_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x2: ref %empty_tuple.type = bind_name x2, %x2.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: bool = binding_pattern y +// CHECK:STDOUT: %.loc59_1: bool = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref bool = var y +// CHECK:STDOUT: %.loc59_8.1: type = splice_block %.loc59_8.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc59: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc59_8.2: type = value_of_initializer %bool.make_type.loc59 [template = bool] +// CHECK:STDOUT: %.loc59_8.3: type = converted %bool.make_type.loc59, %.loc59_8.2 [template = bool] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref bool = bind_name y, %y.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y2.patt: bool = binding_pattern y2 +// CHECK:STDOUT: %.loc73_1: bool = var_pattern %y2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y2.var: ref bool = var y2 +// CHECK:STDOUT: %.loc73_9.1: type = splice_block %.loc73_9.3 [template = bool] { +// CHECK:STDOUT: %bool.make_type.loc73: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc73_9.2: type = value_of_initializer %bool.make_type.loc73 [template = bool] +// CHECK:STDOUT: %.loc73_9.3: type = converted %bool.make_type.loc73, %.loc73_9.2 [template = bool] +// CHECK:STDOUT: } // CHECK:STDOUT: %y2: ref bool = bind_name y2, %y2.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/decl.carbon b/toolchain/check/testdata/var/no_prelude/decl.carbon index 853c0029dd88..9c54ef9a36d1 100644 --- a/toolchain/check/testdata/var/no_prelude/decl.carbon +++ b/toolchain/check/testdata/var/no_prelude/decl.carbon @@ -29,7 +29,15 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc12_3: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/no_prelude/decl_with_init.carbon b/toolchain/check/testdata/var/no_prelude/decl_with_init.carbon index df63de8b5b32..f62679467d5c 100644 --- a/toolchain/check/testdata/var/no_prelude/decl_with_init.carbon +++ b/toolchain/check/testdata/var/no_prelude/decl_with_init.carbon @@ -30,12 +30,20 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc12_3.1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: %.loc12_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc12_16.2: init %empty_tuple.type = tuple_init () to %x.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_17: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var, %.loc12_17 +// CHECK:STDOUT: %.loc12_3.2: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %x.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/export_name.carbon b/toolchain/check/testdata/var/no_prelude/export_name.carbon index a07b8eab4e4a..9f55258ebae6 100644 --- a/toolchain/check/testdata/var/no_prelude/export_name.carbon +++ b/toolchain/check/testdata/var/no_prelude/export_name.carbon @@ -54,7 +54,15 @@ var w: () = v; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .v = %v // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %empty_tuple.type = binding_pattern v +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %empty_tuple.type = var v +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %v: ref %empty_tuple.type = bind_name v, %v.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -93,7 +101,15 @@ var w: () = v; // CHECK:STDOUT: .w = %w // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %w.patt: %empty_tuple.type = binding_pattern w +// CHECK:STDOUT: %.loc12_1: %empty_tuple.type = var_pattern %w.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %w.var: ref %empty_tuple.type = var w +// CHECK:STDOUT: %.loc12_9.1: type = splice_block %.loc12_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_9.3: type = converted %.loc12_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %w: ref %empty_tuple.type = bind_name w, %w.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -101,8 +117,8 @@ var w: () = v; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %v.ref: ref %empty_tuple.type = name_ref v, imports.%import_ref [template = ] // CHECK:STDOUT: %.loc12_13: init %empty_tuple.type = tuple_init () to file.%w.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_14: init %empty_tuple.type = converted %v.ref, %.loc12_13 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%w.var, %.loc12_14 +// CHECK:STDOUT: %.loc12_1: init %empty_tuple.type = converted %v.ref, %.loc12_13 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%w.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon b/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon index a826201b77f5..0e528b88091c 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_duplicate_decl.carbon @@ -39,18 +39,34 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt.loc13: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc13_3.1: %empty_tuple.type = var_pattern %x.patt.loc13 +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var.loc13: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x.loc13: ref %empty_tuple.type = bind_name x, %x.var.loc13 // CHECK:STDOUT: %.loc13_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc13_16.2: init %empty_tuple.type = tuple_init () to %x.var.loc13 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_17: init %empty_tuple.type = converted %.loc13_16.1, %.loc13_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var.loc13, %.loc13_17 +// CHECK:STDOUT: %.loc13_3.2: init %empty_tuple.type = converted %.loc13_16.1, %.loc13_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %x.var.loc13, %.loc13_3.2 +// CHECK:STDOUT: %.loc13_11.1: type = splice_block %.loc13_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc13_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc13_11.3: type = converted %.loc13_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.loc13: ref %empty_tuple.type = bind_name x, %x.var.loc13 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt.loc21: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc21_3.1: %empty_tuple.type = var_pattern %x.patt.loc21 +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var.loc21: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x.loc21: ref %empty_tuple.type = bind_name x, %x.var.loc21 // CHECK:STDOUT: %.loc21_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc21_16.2: init %empty_tuple.type = tuple_init () to %x.var.loc21 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc21_17: init %empty_tuple.type = converted %.loc21_16.1, %.loc21_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var.loc21, %.loc21_17 +// CHECK:STDOUT: %.loc21_3.2: init %empty_tuple.type = converted %.loc21_16.1, %.loc21_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %x.var.loc21, %.loc21_3.2 +// CHECK:STDOUT: %.loc21_11.1: type = splice_block %.loc21_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc21_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc21_11.3: type = converted %.loc21_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.loc21: ref %empty_tuple.type = bind_name x, %x.var.loc21 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_generic.carbon b/toolchain/check/testdata/var/no_prelude/fail_generic.carbon index 74a1b60d09ef..28d52d1e81cf 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_generic.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_generic.carbon @@ -23,6 +23,7 @@ fn Main() { // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] // CHECK:STDOUT: %Main: %Main.type = struct_value () [template] // CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x [symbolic] +// CHECK:STDOUT: %x.patt: %empty_tuple.type = symbolic_binding_pattern x [symbolic] // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -35,12 +36,20 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x, %x.var [symbolic = constants.%x] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = symbolic_binding_pattern x [symbolic = constants.%x.patt] +// CHECK:STDOUT: %.loc16_3.1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } +// CHECK:STDOUT: %.var: ref %empty_tuple.type = var // CHECK:STDOUT: %.loc16_17.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc16_17.2: init %empty_tuple.type = tuple_init () to %x.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_18: init %empty_tuple.type = converted %.loc16_17.1, %.loc16_17.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var, %.loc16_18 +// CHECK:STDOUT: %.loc16_17.2: init %empty_tuple.type = tuple_init () to %.var [template = constants.%empty_tuple] +// CHECK:STDOUT: %.loc16_3.2: init %empty_tuple.type = converted %.loc16_17.1, %.loc16_17.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %.var, %.loc16_3.2 +// CHECK:STDOUT: %.loc16_12.1: type = splice_block %.loc16_12.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc16_12.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_12.3: type = converted %.loc16_12.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: %empty_tuple.type = bind_symbolic_name x, %.var [symbolic = constants.%x] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon b/toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon index 6006cc924cf2..c8157605d1e2 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_init_type_mismatch.carbon @@ -11,7 +11,7 @@ fn Main() { // CHECK:STDERR: fail_init_type_mismatch.carbon:[[@LINE+4]]:3: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound] // CHECK:STDERR: var x: {} = (); - // CHECK:STDERR: ^~~~~~~~~~~~~~~ + // CHECK:STDERR: ^~~~~~~~~ // CHECK:STDERR: var x: {} = (); } @@ -35,13 +35,21 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_struct_type = binding_pattern x +// CHECK:STDOUT: %.loc16_3.1: %empty_struct_type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_struct_type = var x -// CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var // CHECK:STDOUT: %.loc16_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc16_16.2: %empty_tuple.type = converted %.loc16_16.1, %empty_tuple [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_17: %empty_struct_type = converted %.loc16_16.1, [template = ] +// CHECK:STDOUT: %.loc16_3.2: %empty_struct_type = converted %.loc16_16.1, [template = ] // CHECK:STDOUT: assign %x.var, +// CHECK:STDOUT: %.loc16_11.1: type = splice_block %.loc16_11.3 [template = constants.%empty_struct_type] { +// CHECK:STDOUT: %.loc16_11.2: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc16_11.3: type = converted %.loc16_11.2, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon b/toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon index dfb4c6864539..6d8540d411b6 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon @@ -9,7 +9,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_init_with_self.carbon fn Main() { - // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+4]]:15: error: name `x` not found [NameNotFound] + // CHECK:STDERR: fail_init_with_self.carbon:[[@LINE+4]]:15: error: `x` used before initialization [UsedBeforeInitialization] // CHECK:STDERR: var x: () = x; // CHECK:STDERR: ^ // CHECK:STDERR: @@ -33,10 +33,18 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc16_3: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] // CHECK:STDOUT: assign %x.var, +// CHECK:STDOUT: %.loc16_11.1: type = splice_block %.loc16_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc16_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_11.3: type = converted %.loc16_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon b/toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon index 50ddc7155cdc..9732d8e7027e 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_lookup_outside_scope.carbon @@ -32,13 +32,29 @@ var y: () = x; // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %empty_tuple.type = binding_pattern y +// CHECK:STDOUT: %.loc19_1: %empty_tuple.type = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %empty_tuple.type = var y +// CHECK:STDOUT: %.loc19_9.1: type = splice_block %.loc19_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc19_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_9.3: type = converted %.loc19_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %empty_tuple.type = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc12_3: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon b/toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon index ff306ff4896f..d8950cb8427d 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_modifiers.carbon @@ -50,18 +50,50 @@ abstract var e: (); // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .b = %b +// CHECK:STDOUT: .b [protected] = %b // CHECK:STDOUT: .c [private] = %c -// CHECK:STDOUT: .d = %d +// CHECK:STDOUT: .d [protected] = %d // CHECK:STDOUT: .e = %e // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b +// CHECK:STDOUT: %.loc15_11: %empty_tuple.type = var_pattern %b.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b +// CHECK:STDOUT: %.loc15_19.1: type = splice_block %.loc15_19.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc15_19.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc15_19.3: type = converted %.loc15_19.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %c.patt: %empty_tuple.type = binding_pattern c +// CHECK:STDOUT: %.loc24_19: %empty_tuple.type = var_pattern %c.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %empty_tuple.type = var c +// CHECK:STDOUT: %.loc24_27.1: type = splice_block %.loc24_27.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc24_27.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc24_27.3: type = converted %.loc24_27.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d +// CHECK:STDOUT: %.loc37_21: %empty_tuple.type = var_pattern %d.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d +// CHECK:STDOUT: %.loc37_29.1: type = splice_block %.loc37_29.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc37_29.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc37_29.3: type = converted %.loc37_29.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e +// CHECK:STDOUT: %.loc43_10: %empty_tuple.type = var_pattern %e.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e +// CHECK:STDOUT: %.loc43_18.1: type = splice_block %.loc43_18.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc43_18.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc43_18.3: type = converted %.loc43_18.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon b/toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon index 5bd94df11e66..e4014e341a01 100644 --- a/toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon +++ b/toolchain/check/testdata/var/no_prelude/fail_namespace_conflict.carbon @@ -40,9 +40,25 @@ var A: () = (); // CHECK:STDOUT: .A = %A.loc11 // CHECK:STDOUT: } // CHECK:STDOUT: %A.loc11: = namespace [template] {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %A.patt.loc20: %empty_tuple.type = binding_pattern A +// CHECK:STDOUT: %.loc20_1: %empty_tuple.type = var_pattern %A.patt.loc20 +// CHECK:STDOUT: } // CHECK:STDOUT: %A.var.loc20: ref %empty_tuple.type = var A +// CHECK:STDOUT: %.loc20_9.1: type = splice_block %.loc20_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc20_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc20_9.3: type = converted %.loc20_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %A.loc20: ref %empty_tuple.type = bind_name A, %A.var.loc20 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %A.patt.loc29: %empty_tuple.type = binding_pattern A +// CHECK:STDOUT: %.loc29_1: %empty_tuple.type = var_pattern %A.patt.loc29 +// CHECK:STDOUT: } // CHECK:STDOUT: %A.var.loc29: ref %empty_tuple.type = var A +// CHECK:STDOUT: %.loc29_9.1: type = splice_block %.loc29_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc29_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc29_9.3: type = converted %.loc29_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %A.loc29: ref %empty_tuple.type = bind_name A, %A.var.loc29 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -50,8 +66,8 @@ var A: () = (); // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc29_14.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc29_14.2: init %empty_tuple.type = tuple_init () to file.%A.var.loc29 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc29_15: init %empty_tuple.type = converted %.loc29_14.1, %.loc29_14.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%A.var.loc29, %.loc29_15 +// CHECK:STDOUT: %.loc29_1: init %empty_tuple.type = converted %.loc29_14.1, %.loc29_14.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%A.var.loc29, %.loc29_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_decl.carbon b/toolchain/check/testdata/var/no_prelude/global_decl.carbon index 47d49e559419..9b9edea6ed4a 100644 --- a/toolchain/check/testdata/var/no_prelude/global_decl.carbon +++ b/toolchain/check/testdata/var/no_prelude/global_decl.carbon @@ -21,7 +21,16 @@ var x: {.v: ()}; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.v = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.v = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.v = var x +// CHECK:STDOUT: %.loc11_15: type = splice_block %struct_type.v [template = constants.%struct_type.v] { +// CHECK:STDOUT: %.loc11_14.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_14.2: type = converted %.loc11_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %empty_tuple.type} [template = constants.%struct_type.v] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.v = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon b/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon index f8849b5cf501..19647f853dc3 100644 --- a/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon +++ b/toolchain/check/testdata/var/no_prelude/global_decl_with_init.carbon @@ -23,7 +23,16 @@ var x: {.v: ()} = {.v = ()}; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.v = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.v = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.v = var x +// CHECK:STDOUT: %.loc11_15: type = splice_block %struct_type.v [template = constants.%struct_type.v] { +// CHECK:STDOUT: %.loc11_14.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_14.2: type = converted %.loc11_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %empty_tuple.type} [template = constants.%struct_type.v] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.v = bind_name x, %x.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -35,8 +44,8 @@ var x: {.v: ()} = {.v = ()}; // CHECK:STDOUT: %.loc11_26.2: init %empty_tuple.type = tuple_init () to %.loc11_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_27.3: init %empty_tuple.type = converted %.loc11_26.1, %.loc11_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_27.4: init %struct_type.v = struct_init (%.loc11_27.3) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_28: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_lookup.carbon b/toolchain/check/testdata/var/no_prelude/global_lookup.carbon index c9c70cea3b05..3675e9ef21ab 100644 --- a/toolchain/check/testdata/var/no_prelude/global_lookup.carbon +++ b/toolchain/check/testdata/var/no_prelude/global_lookup.carbon @@ -25,9 +25,27 @@ var y: {.v: ()} = x; // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .y = %y // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.v = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.v = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.v = var x +// CHECK:STDOUT: %.loc11_15: type = splice_block %struct_type.v.loc11 [template = constants.%struct_type.v] { +// CHECK:STDOUT: %.loc11_14.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_14.2: type = converted %.loc11_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %struct_type.v.loc11: type = struct_type {.v: %empty_tuple.type} [template = constants.%struct_type.v] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.v = bind_name x, %x.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.v = binding_pattern y +// CHECK:STDOUT: %.loc12_1: %struct_type.v = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.v = var y +// CHECK:STDOUT: %.loc12_15: type = splice_block %struct_type.v.loc12 [template = constants.%struct_type.v] { +// CHECK:STDOUT: %.loc12_14.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_14.2: type = converted %.loc12_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %struct_type.v.loc12: type = struct_type {.v: %empty_tuple.type} [template = constants.%struct_type.v] +// CHECK:STDOUT: } // CHECK:STDOUT: %y: ref %struct_type.v = bind_name y, %y.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -39,16 +57,16 @@ var y: {.v: ()} = x; // CHECK:STDOUT: %.loc11_26.2: init %empty_tuple.type = tuple_init () to %.loc11_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_27.3: init %empty_tuple.type = converted %.loc11_26.1, %.loc11_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_27.4: init %struct_type.v = struct_init (%.loc11_27.3) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_28: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: %x.ref: ref %struct_type.v = name_ref x, file.%x // CHECK:STDOUT: %.loc12_19.1: ref %empty_tuple.type = struct_access %x.ref, element0 // CHECK:STDOUT: %.loc12_19.2: ref %empty_tuple.type = struct_access file.%y.var, element0 // CHECK:STDOUT: %.loc12_19.3: init %empty_tuple.type = tuple_init () to %.loc12_19.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc12_19.4: init %empty_tuple.type = converted %.loc12_19.1, %.loc12_19.3 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc12_19.5: init %struct_type.v = struct_init (%.loc12_19.4) to file.%y.var [template = constants.%struct] -// CHECK:STDOUT: %.loc12_20: init %struct_type.v = converted %x.ref, %.loc12_19.5 [template = constants.%struct] -// CHECK:STDOUT: assign file.%y.var, %.loc12_20 +// CHECK:STDOUT: %.loc12_1: init %struct_type.v = converted %x.ref, %.loc12_19.5 [template = constants.%struct] +// CHECK:STDOUT: assign file.%y.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon b/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon index 0056295ebbe7..3bec6e55f6cd 100644 --- a/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon +++ b/toolchain/check/testdata/var/no_prelude/global_lookup_in_scope.carbon @@ -30,23 +30,41 @@ fn Main() { // CHECK:STDOUT: .x = %x // CHECK:STDOUT: .Main = %Main.decl // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %struct_type.v = binding_pattern x +// CHECK:STDOUT: %.loc11_1: %struct_type.v = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %struct_type.v = var x +// CHECK:STDOUT: %.loc11_15: type = splice_block %struct_type.v [template = constants.%struct_type.v] { +// CHECK:STDOUT: %.loc11_14.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc11_14.2: type = converted %.loc11_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %empty_tuple.type} [template = constants.%struct_type.v] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %struct_type.v = bind_name x, %x.var // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %y.patt: %struct_type.v = binding_pattern y +// CHECK:STDOUT: %.loc14_3.1: %struct_type.v = var_pattern %y.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %y.var: ref %struct_type.v = var y -// CHECK:STDOUT: %y: ref %struct_type.v = bind_name y, %y.var // CHECK:STDOUT: %x.ref: ref %struct_type.v = name_ref x, file.%x // CHECK:STDOUT: %.loc14_21.1: ref %empty_tuple.type = struct_access %x.ref, element0 // CHECK:STDOUT: %.loc14_21.2: ref %empty_tuple.type = struct_access %y.var, element0 // CHECK:STDOUT: %.loc14_21.3: init %empty_tuple.type = tuple_init () to %.loc14_21.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc14_21.4: init %empty_tuple.type = converted %.loc14_21.1, %.loc14_21.3 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc14_21.5: init %struct_type.v = struct_init (%.loc14_21.4) to %y.var [template = constants.%struct] -// CHECK:STDOUT: %.loc14_22: init %struct_type.v = converted %x.ref, %.loc14_21.5 [template = constants.%struct] -// CHECK:STDOUT: assign %y.var, %.loc14_22 +// CHECK:STDOUT: %.loc14_3.2: init %struct_type.v = converted %x.ref, %.loc14_21.5 [template = constants.%struct] +// CHECK:STDOUT: assign %y.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_17: type = splice_block %struct_type.v [template = constants.%struct_type.v] { +// CHECK:STDOUT: %.loc14_16.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc14_16.2: type = converted %.loc14_16.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %empty_tuple.type} [template = constants.%struct_type.v] +// CHECK:STDOUT: } +// CHECK:STDOUT: %y: ref %struct_type.v = bind_name y, %y.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -58,8 +76,8 @@ fn Main() { // CHECK:STDOUT: %.loc11_26.2: init %empty_tuple.type = tuple_init () to %.loc11_27.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_27.3: init %empty_tuple.type = converted %.loc11_26.1, %.loc11_26.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc11_27.4: init %struct_type.v = struct_init (%.loc11_27.3) to file.%x.var [template = constants.%struct] -// CHECK:STDOUT: %.loc11_28: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct] -// CHECK:STDOUT: assign file.%x.var, %.loc11_28 +// CHECK:STDOUT: %.loc11_1: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct] +// CHECK:STDOUT: assign file.%x.var, %.loc11_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/import.carbon b/toolchain/check/testdata/var/no_prelude/import.carbon index 7fe3dba5e930..819a3ccb095b 100644 --- a/toolchain/check/testdata/var/no_prelude/import.carbon +++ b/toolchain/check/testdata/var/no_prelude/import.carbon @@ -31,7 +31,15 @@ var a: () = a_ref; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .a_ref = %a_ref // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a_ref.patt: %empty_tuple.type = binding_pattern a_ref +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a_ref.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref.var: ref %empty_tuple.type = var a_ref +// CHECK:STDOUT: %.loc4_13.1: type = splice_block %.loc4_13.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_13.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_13.3: type = converted %.loc4_13.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a_ref: ref %empty_tuple.type = bind_name a_ref, %a_ref.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -39,8 +47,8 @@ var a: () = a_ref; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_18.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc4_18.2: init %empty_tuple.type = tuple_init () to file.%a_ref.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_19: init %empty_tuple.type = converted %.loc4_18.1, %.loc4_18.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_19 +// CHECK:STDOUT: %.loc4_1: init %empty_tuple.type = converted %.loc4_18.1, %.loc4_18.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%a_ref.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -62,7 +70,15 @@ var a: () = a_ref; // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import = import Implicit // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %a.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a +// CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_9.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -70,8 +86,8 @@ var a: () = a_ref; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a_ref.ref: ref %empty_tuple.type = name_ref a_ref, imports.%import_ref // CHECK:STDOUT: %.loc4_13: init %empty_tuple.type = tuple_init () to file.%a.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_18: init %empty_tuple.type = converted %a_ref.ref, %.loc4_13 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%a.var, %.loc4_18 +// CHECK:STDOUT: %.loc4_1: init %empty_tuple.type = converted %a_ref.ref, %.loc4_13 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%a.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/import_access.carbon b/toolchain/check/testdata/var/no_prelude/import_access.carbon index b7edd98572d1..2bd947ed1c1c 100644 --- a/toolchain/check/testdata/var/no_prelude/import_access.carbon +++ b/toolchain/check/testdata/var/no_prelude/import_access.carbon @@ -63,7 +63,15 @@ var v2: () = Test.v; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .v [private] = %v // CHECK:STDOUT: } +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: %empty_tuple.type = binding_pattern v +// CHECK:STDOUT: %.loc4_9: %empty_tuple.type = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref %empty_tuple.type = var v +// CHECK:STDOUT: %.loc4_17.1: type = splice_block %.loc4_17.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_17.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_17.3: type = converted %.loc4_17.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %v: ref %empty_tuple.type = bind_name v, %v.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -71,8 +79,8 @@ var v2: () = Test.v; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc4_22.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc4_22.2: init %empty_tuple.type = tuple_init () to file.%v.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_23: init %empty_tuple.type = converted %.loc4_22.1, %.loc4_22.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%v.var, %.loc4_23 +// CHECK:STDOUT: %.loc4_9: init %empty_tuple.type = converted %.loc4_22.1, %.loc4_22.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%v.var, %.loc4_9 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -94,7 +102,15 @@ var v2: () = Test.v; // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v2.patt: %empty_tuple.type = binding_pattern v2 +// CHECK:STDOUT: %.loc4_1: %empty_tuple.type = var_pattern %v2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v2.var: ref %empty_tuple.type = var v2 +// CHECK:STDOUT: %.loc4_10.1: type = splice_block %.loc4_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc4_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc4_10.3: type = converted %.loc4_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %v2: ref %empty_tuple.type = bind_name v2, %v2.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -102,8 +118,8 @@ var v2: () = Test.v; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %v.ref: ref %empty_tuple.type = name_ref v, imports.%import_ref // CHECK:STDOUT: %.loc4_14: init %empty_tuple.type = tuple_init () to file.%v2.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc4_15: init %empty_tuple.type = converted %v.ref, %.loc4_14 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign file.%v2.var, %.loc4_15 +// CHECK:STDOUT: %.loc4_1: init %empty_tuple.type = converted %v.ref, %.loc4_14 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign file.%v2.var, %.loc4_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -118,7 +134,15 @@ var v2: () = Test.v; // CHECK:STDOUT: .v2 = %v2 // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v2.patt: %empty_tuple.type = binding_pattern v2 +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %v2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v2.var: ref %empty_tuple.type = var v2 +// CHECK:STDOUT: %.loc10_10.1: type = splice_block %.loc10_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_10.3: type = converted %.loc10_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %v2: ref %empty_tuple.type = bind_name v2, %v2.var // CHECK:STDOUT: } // CHECK:STDOUT: @@ -147,7 +171,15 @@ var v2: () = Test.v; // CHECK:STDOUT: .v2 = %v2 // CHECK:STDOUT: } // CHECK:STDOUT: %Test.import = import Test +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v2.patt: %empty_tuple.type = binding_pattern v2 +// CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %v2.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v2.var: ref %empty_tuple.type = var v2 +// CHECK:STDOUT: %.loc10_10.1: type = splice_block %.loc10_10.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc10_10.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc10_10.3: type = converted %.loc10_10.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %v2: ref %empty_tuple.type = bind_name v2, %v2.var // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/no_prelude/lookup.carbon b/toolchain/check/testdata/var/no_prelude/lookup.carbon index 4b0d15249052..feffe6fc9c7c 100644 --- a/toolchain/check/testdata/var/no_prelude/lookup.carbon +++ b/toolchain/check/testdata/var/no_prelude/lookup.carbon @@ -31,12 +31,20 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc12_3.1: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: %.loc12_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc12_16.2: init %empty_tuple.type = tuple_init () to %x.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_17: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var, %.loc12_17 +// CHECK:STDOUT: %.loc12_3.2: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %x.var, %.loc12_3.2 +// CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: %x.ref: ref %empty_tuple.type = name_ref x, %x // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/no_prelude/shadowing.carbon b/toolchain/check/testdata/var/no_prelude/shadowing.carbon index 17e20e98c0b2..ddaa51f53e2e 100644 --- a/toolchain/check/testdata/var/no_prelude/shadowing.carbon +++ b/toolchain/check/testdata/var/no_prelude/shadowing.carbon @@ -44,33 +44,57 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %NS.patt: %empty_tuple.type = binding_pattern NS +// CHECK:STDOUT: %.loc14_3.1: %empty_tuple.type = var_pattern %NS.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %NS.var: ref %empty_tuple.type = var NS -// CHECK:STDOUT: %NS: ref %empty_tuple.type = bind_name NS, %NS.var // CHECK:STDOUT: %.loc14_17.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc14_17.2: init %empty_tuple.type = tuple_init () to %NS.var [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc14_18: init %empty_tuple.type = converted %.loc14_17.1, %.loc14_17.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %NS.var, %.loc14_18 +// CHECK:STDOUT: %.loc14_3.2: init %empty_tuple.type = converted %.loc14_17.1, %.loc14_17.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %NS.var, %.loc14_3.2 +// CHECK:STDOUT: %.loc14_12.1: type = splice_block %.loc14_12.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc14_12.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc14_12.3: type = converted %.loc14_12.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %NS: ref %empty_tuple.type = bind_name NS, %NS.var // CHECK:STDOUT: %NS.ref: ref %empty_tuple.type = name_ref NS, %NS // CHECK:STDOUT: %.loc15_9.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc15_9.2: init %empty_tuple.type = tuple_init () to %NS.ref [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc15_6: init %empty_tuple.type = converted %.loc15_9.1, %.loc15_9.2 [template = constants.%empty_tuple] // CHECK:STDOUT: assign %NS.ref, %.loc15_6 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt.loc17: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc17_3.1: %empty_tuple.type = var_pattern %x.patt.loc17 +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var.loc17: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x.loc17: ref %empty_tuple.type = bind_name x, %x.var.loc17 // CHECK:STDOUT: %.loc17_16.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc17_16.2: init %empty_tuple.type = tuple_init () to %x.var.loc17 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc17_17: init %empty_tuple.type = converted %.loc17_16.1, %.loc17_16.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var.loc17, %.loc17_17 +// CHECK:STDOUT: %.loc17_3.2: init %empty_tuple.type = converted %.loc17_16.1, %.loc17_16.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %x.var.loc17, %.loc17_3.2 +// CHECK:STDOUT: %.loc17_11.1: type = splice_block %.loc17_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc17_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc17_11.3: type = converted %.loc17_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.loc17: ref %empty_tuple.type = bind_name x, %x.var.loc17 // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true] // CHECK:STDOUT: if %true br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt.loc19: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc19_5.1: %empty_tuple.type = var_pattern %x.patt.loc19 +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var.loc19: ref %empty_tuple.type = var x -// CHECK:STDOUT: %x.loc19: ref %empty_tuple.type = bind_name x, %x.var.loc19 // CHECK:STDOUT: %.loc19_18.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc19_18.2: init %empty_tuple.type = tuple_init () to %x.var.loc19 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc19_19: init %empty_tuple.type = converted %.loc19_18.1, %.loc19_18.2 [template = constants.%empty_tuple] -// CHECK:STDOUT: assign %x.var.loc19, %.loc19_19 +// CHECK:STDOUT: %.loc19_5.2: init %empty_tuple.type = converted %.loc19_18.1, %.loc19_18.2 [template = constants.%empty_tuple] +// CHECK:STDOUT: assign %x.var.loc19, %.loc19_5.2 +// CHECK:STDOUT: %.loc19_13.1: type = splice_block %.loc19_13.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc19_13.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc19_13.3: type = converted %.loc19_13.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %x.loc19: ref %empty_tuple.type = bind_name x, %x.var.loc19 // CHECK:STDOUT: %x.ref: ref %empty_tuple.type = name_ref x, %x.loc19 // CHECK:STDOUT: %.loc22_10.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc22_10.2: init %empty_tuple.type = tuple_init () to %x.ref [template = constants.%empty_tuple] diff --git a/toolchain/check/testdata/where_expr/designator.carbon b/toolchain/check/testdata/where_expr/designator.carbon index 1b99b314f490..3d52a462bd0f 100644 --- a/toolchain/check/testdata/where_expr/designator.carbon +++ b/toolchain/check/testdata/where_expr/designator.carbon @@ -334,7 +334,15 @@ class D { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo() -> %empty_tuple.type { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x +// CHECK:STDOUT: %.loc5_3: %empty_tuple.type = var_pattern %x.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x +// CHECK:STDOUT: %.loc5_11.1: type = splice_block %.loc5_11.3 [template = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc5_11.2: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc5_11.3: type = converted %.loc5_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: } // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var // CHECK:STDOUT: %.Self.ref: = name_ref .Self, [template = ] // CHECK:STDOUT: %x.ref: = name_ref x, [template = ] diff --git a/toolchain/check/testdata/where_expr/dot_self_index.carbon b/toolchain/check/testdata/where_expr/dot_self_index.carbon index 4fced364e41f..d90d14456c7a 100644 --- a/toolchain/check/testdata/where_expr/dot_self_index.carbon +++ b/toolchain/check/testdata/where_expr/dot_self_index.carbon @@ -109,7 +109,7 @@ fn G(U: Empty(i32) where .A = i32*) { // CHECK:STDOUT: %Empty.type.loc18_26.1: type = facet_type <@Empty, @Empty(constants.%T)> [symbolic = %Empty.type.loc18_26.2 (constants.%Empty.type.3e5fde.2)] // CHECK:STDOUT: %.Self.1: @H.%Empty.type.loc18_26.2 (%Empty.type.3e5fde.2) = bind_symbolic_name .Self [symbolic = %.Self.2 (constants.%.Self.c95)] // CHECK:STDOUT: %.Self.ref: @H.%Empty.type.loc18_26.2 (%Empty.type.3e5fde.2) = name_ref .Self, %.Self.1 [symbolic = %.Self.2 (constants.%.Self.c95)] -// CHECK:STDOUT: %.loc18_34: @H.%assoc_type (%assoc_type.79df66.2) = specific_constant @Empty.%assoc0.loc12_15.1, @Empty(constants.%T) [symbolic = %assoc0 (constants.%assoc0.b2890e.2)] +// CHECK:STDOUT: %.loc18_34: @H.%assoc_type (%assoc_type.79df66.2) = specific_constant @Empty.%assoc0.loc12_8.1, @Empty(constants.%T) [symbolic = %assoc0 (constants.%assoc0.b2890e.2)] // CHECK:STDOUT: %A.ref: @H.%assoc_type (%assoc_type.79df66.2) = name_ref A, %.loc18_34 [symbolic = %assoc0 (constants.%assoc0.b2890e.2)] // CHECK:STDOUT: %.Self.as_wit.loc18_34.1: = facet_access_witness %.Self.ref [symbolic = %.Self.as_wit.loc18_34.2 (constants.%.Self.as_wit.da4)] // CHECK:STDOUT: %impl.elem0.loc18_34.1: type = impl_witness_access %.Self.as_wit.loc18_34.1, element0 [symbolic = %impl.elem0.loc18_34.2 (constants.%impl.elem0.41c)] @@ -135,7 +135,7 @@ fn G(U: Empty(i32) where .A = i32*) { // CHECK:STDOUT: %Empty.type: type = facet_type <@Empty, @Empty(constants.%i32)> [template = constants.%Empty.type.f0b] // CHECK:STDOUT: %.Self: %Empty.type.f0b = bind_symbolic_name .Self [symbolic = constants.%.Self.e6e] // CHECK:STDOUT: %.Self.ref: %Empty.type.f0b = name_ref .Self, %.Self [symbolic = constants.%.Self.e6e] -// CHECK:STDOUT: %.loc20_26: %assoc_type.eda = specific_constant @Empty.%assoc0.loc12_15.1, @Empty(constants.%i32) [template = constants.%assoc0.da0] +// CHECK:STDOUT: %.loc20_26: %assoc_type.eda = specific_constant @Empty.%assoc0.loc12_8.1, @Empty(constants.%i32) [template = constants.%assoc0.da0] // CHECK:STDOUT: %A.ref: %assoc_type.eda = name_ref A, %.loc20_26 [template = constants.%assoc0.da0] // CHECK:STDOUT: %.Self.as_wit: = facet_access_witness %.Self.ref [symbolic = constants.%.Self.as_wit.581] // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %.Self.as_wit, element0 [symbolic = constants.%impl.elem0.797] @@ -158,16 +158,16 @@ fn G(U: Empty(i32) where .A = i32*) { // CHECK:STDOUT: %Empty.type: type = facet_type <@Empty, @Empty(%W.loc11_17.2)> [symbolic = %Empty.type (constants.%Empty.type.3e5fde.1)] // CHECK:STDOUT: %Self.2: %Empty.type.3e5fde.1 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %assoc_type: type = assoc_entity_type @Empty.%Empty.type (%Empty.type.3e5fde.1), type [symbolic = %assoc_type (constants.%assoc_type.79df66.1)] -// CHECK:STDOUT: %assoc0.loc12_15.2: @Empty.%assoc_type (%assoc_type.79df66.1) = assoc_entity element0, %A [symbolic = %assoc0.loc12_15.2 (constants.%assoc0.b2890e.1)] +// CHECK:STDOUT: %assoc0.loc12_8.2: @Empty.%assoc_type (%assoc_type.79df66.1) = assoc_entity element0, %A [symbolic = %assoc0.loc12_8.2 (constants.%assoc0.b2890e.1)] // CHECK:STDOUT: // CHECK:STDOUT: interface { // CHECK:STDOUT: %Self.1: @Empty.%Empty.type (%Empty.type.3e5fde.1) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %A: type = assoc_const_decl A [template] -// CHECK:STDOUT: %assoc0.loc12_15.1: @Empty.%assoc_type (%assoc_type.79df66.1) = assoc_entity element0, %A [symbolic = %assoc0.loc12_15.2 (constants.%assoc0.b2890e.1)] +// CHECK:STDOUT: %assoc0.loc12_8.1: @Empty.%assoc_type (%assoc_type.79df66.1) = assoc_entity element0, %A [symbolic = %assoc0.loc12_8.2 (constants.%assoc0.b2890e.1)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self.1 -// CHECK:STDOUT: .A = %assoc0.loc12_15.1 +// CHECK:STDOUT: .A = %assoc0.loc12_8.1 // CHECK:STDOUT: witness = (%A) // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -225,7 +225,7 @@ fn G(U: Empty(i32) where .A = i32*) { // CHECK:STDOUT: %Empty.type => constants.%Empty.type.3e5fde.2 // CHECK:STDOUT: %Self.2 => constants.%Self // CHECK:STDOUT: %assoc_type => constants.%assoc_type.79df66.2 -// CHECK:STDOUT: %assoc0.loc12_15.2 => constants.%assoc0.b2890e.2 +// CHECK:STDOUT: %assoc0.loc12_8.2 => constants.%assoc0.b2890e.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @H(constants.%T, constants.%V) { @@ -254,7 +254,7 @@ fn G(U: Empty(i32) where .A = i32*) { // CHECK:STDOUT: %Empty.type => constants.%Empty.type.f0b // CHECK:STDOUT: %Self.2 => constants.%Self // CHECK:STDOUT: %assoc_type => constants.%assoc_type.eda -// CHECK:STDOUT: %assoc0.loc12_15.2 => constants.%assoc0.da0 +// CHECK:STDOUT: %assoc0.loc12_8.2 => constants.%assoc0.da0 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @H(constants.%i32, bool) { diff --git a/toolchain/check/testdata/where_expr/equal_rewrite.carbon b/toolchain/check/testdata/where_expr/equal_rewrite.carbon index 83d3e26d3ced..9534392ab9b4 100644 --- a/toolchain/check/testdata/where_expr/equal_rewrite.carbon +++ b/toolchain/check/testdata/where_expr/equal_rewrite.carbon @@ -172,12 +172,12 @@ interface A {} class D {} impl D as A {} // TODO: This should be a compile-time binding, once that is supported. -// CHECK:STDERR: fail_todo_let.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `type` to `type where...` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_todo_let.carbon:[[@LINE+7]]:35: error: cannot implicitly convert from `type` to `type where...` [ImplicitAsConversionFailure] // CHECK:STDERR: let B: type where .Self impls A = D; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_todo_let.carbon:[[@LINE+4]]:1: note: type `type` does not implement interface `Core.ImplicitAs(type where...)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: ^ +// CHECK:STDERR: fail_todo_let.carbon:[[@LINE+4]]:35: note: type `type` does not implement interface `Core.ImplicitAs(type where...)` [MissingImplInMemberAccessNote] // CHECK:STDERR: let B: type where .Self impls A = D; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^ // CHECK:STDERR: let B: type where .Self impls A = D; @@ -192,30 +192,30 @@ interface E { // Testing how these types get stringified in error messages. // TODO: This should be a compile-time binding, once that is supported. -// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `type` to `E where .(E.G) = () and .(E.F) = bool` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+7]]:42: error: cannot implicitly convert from `type` to `E where .(E.G) = () and .(E.F) = bool` [ImplicitAsConversionFailure] // CHECK:STDERR: let H: (E where .F = bool and .G = ()) = f64; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:1: note: type `type` does not implement interface `Core.ImplicitAs(E where .(E.G) = () and .(E.F) = bool)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: ^~~ +// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:42: note: type `type` does not implement interface `Core.ImplicitAs(E where .(E.G) = () and .(E.F) = bool)` [MissingImplInMemberAccessNote] // CHECK:STDERR: let H: (E where .F = bool and .G = ()) = f64; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~ // CHECK:STDERR: let H: (E where .F = bool and .G = ()) = f64; -// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `type` to `E where .(E.G) = i32 and .(E.F) = {}` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+7]]:45: error: cannot implicitly convert from `type` to `E where .(E.G) = i32 and .(E.F) = {}` [ImplicitAsConversionFailure] // CHECK:STDERR: let J: ((E where .F = {}) where .G = i32) = bool; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:1: note: type `type` does not implement interface `Core.ImplicitAs(E where .(E.G) = i32 and .(E.F) = {})` [MissingImplInMemberAccessNote] +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:45: note: type `type` does not implement interface `Core.ImplicitAs(E where .(E.G) = i32 and .(E.F) = {})` [MissingImplInMemberAccessNote] // CHECK:STDERR: let J: ((E where .F = {}) where .G = i32) = bool; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~ // CHECK:STDERR: let J: ((E where .F = {}) where .G = i32) = bool; -// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `type` to `E where .(E.F) = .(E.G)` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+7]]:33: error: cannot implicitly convert from `type` to `E where .(E.F) = .(E.G)` [ImplicitAsConversionFailure] // CHECK:STDERR: let K: (E where .F = .Self.G) = bool; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:1: note: type `type` does not implement interface `Core.ImplicitAs(E where .(E.F) = .(E.G))` [MissingImplInMemberAccessNote] +// CHECK:STDERR: ^~~~ +// CHECK:STDERR: fail_type_does_not_implement_where.carbon:[[@LINE+4]]:33: note: type `type` does not implement interface `Core.ImplicitAs(E where .(E.F) = .(E.G))` [MissingImplInMemberAccessNote] // CHECK:STDERR: let K: (E where .F = .Self.G) = bool; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: ^~~~ // CHECK:STDERR: let K: (E where .F = .Self.G) = bool; @@ -1094,11 +1094,11 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.169 = import_ref Main//equal_constraint, inst17 [no loc], unloaded -// CHECK:STDOUT: %import_ref.d17 = import_ref Main//equal_constraint, loc5_15, unloaded +// CHECK:STDOUT: %import_ref.d17 = import_ref Main//equal_constraint, loc5_8, unloaded // CHECK:STDOUT: %import_ref.77a = import_ref Main//equal_constraint, P, unloaded // CHECK:STDOUT: %import_ref.b61 = import_ref Main//nested_rewrites, inst17 [no loc], unloaded -// CHECK:STDOUT: %import_ref.2a9 = import_ref Main//nested_rewrites, loc5_15, unloaded -// CHECK:STDOUT: %import_ref.508 = import_ref Main//nested_rewrites, loc6_15, unloaded +// CHECK:STDOUT: %import_ref.2a9 = import_ref Main//nested_rewrites, loc5_8, unloaded +// CHECK:STDOUT: %import_ref.508 = import_ref Main//nested_rewrites, loc6_8, unloaded // CHECK:STDOUT: %import_ref.75c = import_ref Main//nested_rewrites, B, unloaded // CHECK:STDOUT: %import_ref.aff = import_ref Main//nested_rewrites, C, unloaded // CHECK:STDOUT: } @@ -1252,6 +1252,7 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [template] // CHECK:STDOUT: %impl_witness: = impl_witness () [template] +// CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic] // CHECK:STDOUT: %type_where: type = facet_type [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1268,7 +1269,7 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .A = %A.decl // CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .B = @__global_init.%B +// CHECK:STDOUT: .B = %B // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %A.decl: type = interface_decl @A [template = constants.%A.type] {} {} @@ -1278,6 +1279,19 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A.type] // CHECK:STDOUT: } // CHECK:STDOUT: %impl_witness: = impl_witness () [template = constants.%impl_witness] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %B.patt: %type_where = binding_pattern B +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15_13.1: type = splice_block %.loc15_13.2 [template = constants.%type_where] { +// CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self] +// CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A.type] +// CHECK:STDOUT: %.loc15_13.2: type = where_expr %.Self [template = constants.%type_where] { +// CHECK:STDOUT: requirement_impls %.Self.ref, %A.ref +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc15_35: %type_where = converted @__global_init.%D.ref, [template = ] +// CHECK:STDOUT: %B: %type_where = bind_name B, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @A { @@ -1301,8 +1315,6 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D] -// CHECK:STDOUT: %.loc15: %type_where = converted %D.ref, [template = ] -// CHECK:STDOUT: %B: %type_where = bind_name B, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1351,12 +1363,86 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .E = %E.decl -// CHECK:STDOUT: .H = @__global_init.%H -// CHECK:STDOUT: .J = @__global_init.%J -// CHECK:STDOUT: .K = @__global_init.%K +// CHECK:STDOUT: .H = %H +// CHECK:STDOUT: .J = %J +// CHECK:STDOUT: .K = %K // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %E.decl: type = interface_decl @E [template = constants.%E.type] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %H.patt: %E_where.type.366 = binding_pattern H +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc18_11.1: type = splice_block %.loc18_11.2 [template = constants.%E_where.type.366] { +// CHECK:STDOUT: %E.ref.loc18: type = name_ref E, %E.decl [template = constants.%E.type] +// CHECK:STDOUT: %.Self.1: %E.type = bind_symbolic_name .Self [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %.Self.ref.loc18_17: %E.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %F.ref.loc18: %assoc_type = name_ref F, @E.%assoc0 [template = constants.%assoc0.4b1] +// CHECK:STDOUT: %.Self.as_wit.loc18_17: = facet_access_witness %.Self.ref.loc18_17 [symbolic = constants.%.Self.as_wit.f42] +// CHECK:STDOUT: %impl.elem0.loc18: type = impl_witness_access %.Self.as_wit.loc18_17, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool] +// CHECK:STDOUT: %.loc18_22.1: type = value_of_initializer %bool.make_type [template = bool] +// CHECK:STDOUT: %.loc18_22.2: type = converted %bool.make_type, %.loc18_22.1 [template = bool] +// CHECK:STDOUT: %.Self.ref.loc18_31: %E.type = name_ref .Self, %.Self.1 [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %G.ref.loc18: %assoc_type = name_ref G, @E.%assoc1 [template = constants.%assoc1] +// CHECK:STDOUT: %.Self.as_wit.loc18_31: = facet_access_witness %.Self.ref.loc18_31 [symbolic = constants.%.Self.as_wit.f42] +// CHECK:STDOUT: %impl.elem1.loc18: type = impl_witness_access %.Self.as_wit.loc18_31, element1 [symbolic = constants.%impl.elem1.91f] +// CHECK:STDOUT: %.loc18_37.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc18_37.2: type = converted %.loc18_37.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc18_11.2: type = where_expr %.Self.1 [template = constants.%E_where.type.366] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc18, %.loc18_22.2 +// CHECK:STDOUT: requirement_rewrite %impl.elem1.loc18, %.loc18_37.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc18_42: %E_where.type.366 = converted @__global_init.%float.make_type, [template = ] +// CHECK:STDOUT: %H: %E_where.type.366 = bind_name H, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %J.patt: %E_where.type.bef = binding_pattern J +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc27_27.1: type = splice_block %.loc27_27.2 [template = constants.%E_where.type.bef] { +// CHECK:STDOUT: %E.ref.loc27: type = name_ref E, %E.decl [template = constants.%E.type] +// CHECK:STDOUT: %.Self.2: %E.type = bind_symbolic_name .Self [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %.Self.ref.loc27_18: %E.type = name_ref .Self, %.Self.2 [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %F.ref.loc27: %assoc_type = name_ref F, @E.%assoc0 [template = constants.%assoc0.4b1] +// CHECK:STDOUT: %.Self.as_wit.loc27_18: = facet_access_witness %.Self.ref.loc27_18 [symbolic = constants.%.Self.as_wit.f42] +// CHECK:STDOUT: %impl.elem0.loc27: type = impl_witness_access %.Self.as_wit.loc27_18, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.loc27_24.1: %empty_struct_type = struct_literal () +// CHECK:STDOUT: %.loc27_24.2: type = converted %.loc27_24.1, constants.%empty_struct_type [template = constants.%empty_struct_type] +// CHECK:STDOUT: %.loc27_12: type = where_expr %.Self.2 [template = constants.%E_where.type.324] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc27, %.loc27_24.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: %.Self.3: %E_where.type.324 = bind_symbolic_name .Self [symbolic = constants.%.Self.665] +// CHECK:STDOUT: %.Self.ref.loc27_33: %E_where.type.324 = name_ref .Self, %.Self.3 [symbolic = constants.%.Self.665] +// CHECK:STDOUT: %G.ref.loc27: %assoc_type = name_ref G, @E.%assoc1 [template = constants.%assoc1] +// CHECK:STDOUT: %.Self.as_wit.loc27_33: = facet_access_witness %.Self.ref.loc27_33 [symbolic = constants.%.Self.as_wit.bb3] +// CHECK:STDOUT: %impl.elem1.loc27: type = impl_witness_access %.Self.as_wit.loc27_33, element1 [symbolic = constants.%impl.elem1.244] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32] +// CHECK:STDOUT: %.loc27_27.2: type = where_expr %.Self.3 [template = constants.%E_where.type.bef] { +// CHECK:STDOUT: requirement_rewrite %impl.elem1.loc27, %i32 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc27_45: %E_where.type.bef = converted @__global_init.%bool.make_type.loc27, [template = ] +// CHECK:STDOUT: %J: %E_where.type.bef = bind_name J, +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %K.patt: %E_where.type.503 = binding_pattern K +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc36_11.1: type = splice_block %.loc36_11.2 [template = constants.%E_where.type.503] { +// CHECK:STDOUT: %E.ref.loc36: type = name_ref E, %E.decl [template = constants.%E.type] +// CHECK:STDOUT: %.Self.4: %E.type = bind_symbolic_name .Self [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %.Self.ref.loc36_17: %E.type = name_ref .Self, %.Self.4 [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %F.ref.loc36: %assoc_type = name_ref F, @E.%assoc0 [template = constants.%assoc0.4b1] +// CHECK:STDOUT: %.Self.as_wit.loc36_17: = facet_access_witness %.Self.ref.loc36_17 [symbolic = constants.%.Self.as_wit.f42] +// CHECK:STDOUT: %impl.elem0.loc36: type = impl_witness_access %.Self.as_wit.loc36_17, element0 [symbolic = constants.%impl.elem0] +// CHECK:STDOUT: %.Self.ref.loc36_22: %E.type = name_ref .Self, %.Self.4 [symbolic = constants.%.Self.da5] +// CHECK:STDOUT: %G.ref.loc36: %assoc_type = name_ref G, @E.%assoc1 [template = constants.%assoc1] +// CHECK:STDOUT: %.Self.as_wit.loc36_27: = facet_access_witness %.Self.ref.loc36_22 [symbolic = constants.%.Self.as_wit.f42] +// CHECK:STDOUT: %impl.elem1.loc36: type = impl_witness_access %.Self.as_wit.loc36_27, element1 [symbolic = constants.%impl.elem1.91f] +// CHECK:STDOUT: %.loc36_11.2: type = where_expr %.Self.4 [template = constants.%E_where.type.503] { +// CHECK:STDOUT: requirement_rewrite %impl.elem0.loc36, %impl.elem1.loc36 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc36_33: %E_where.type.503 = converted @__global_init.%bool.make_type.loc36, [template = ] +// CHECK:STDOUT: %K: %E_where.type.503 = bind_name K, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @E { @@ -1377,14 +1463,8 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64] // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64] -// CHECK:STDOUT: %.loc18: %E_where.type.366 = converted %float.make_type, [template = ] -// CHECK:STDOUT: %H: %E_where.type.366 = bind_name H, // CHECK:STDOUT: %bool.make_type.loc27: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc27: %E_where.type.bef = converted %bool.make_type.loc27, [template = ] -// CHECK:STDOUT: %J: %E_where.type.bef = bind_name J, // CHECK:STDOUT: %bool.make_type.loc36: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc36: %E_where.type.503 = converted %bool.make_type.loc36, [template = ] -// CHECK:STDOUT: %K: %E_where.type.503 = bind_name K, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/where_expr/fail_not_facet.carbon b/toolchain/check/testdata/where_expr/fail_not_facet.carbon index 7352eda2e23c..e48de8ec2814 100644 --- a/toolchain/check/testdata/where_expr/fail_not_facet.carbon +++ b/toolchain/check/testdata/where_expr/fail_not_facet.carbon @@ -149,6 +149,7 @@ var v: e where .x = 3; // CHECK:STDOUT: --- fail_var.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -164,7 +165,21 @@ var v: e where .x = 3; // CHECK:STDOUT: .v = %v // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %v.patt: = binding_pattern v +// CHECK:STDOUT: %.loc8_1: = var_pattern %v.patt +// CHECK:STDOUT: } // CHECK:STDOUT: %v.var: ref = var v -// CHECK:STDOUT: %v: ref = bind_name v, %v.var +// CHECK:STDOUT: %.loc8_10.1: type = splice_block %.loc8_10.2 [template = ] { +// CHECK:STDOUT: %e.ref: = name_ref e, [template = ] +// CHECK:STDOUT: %.Self: = bind_symbolic_name .Self [template = ] +// CHECK:STDOUT: %.Self.ref: = name_ref .Self, %.Self [template = ] +// CHECK:STDOUT: %x.ref: = name_ref x, [template = ] +// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3] +// CHECK:STDOUT: %.loc8_10.2: type = where_expr %.Self [template = ] { +// CHECK:STDOUT: requirement_rewrite %x.ref, +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: %v: = bind_name v, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index 561350aa111d..412aaf1a85ab 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -299,8 +299,10 @@ CARBON_DIAGNOSTIC_KIND(NameNotFound) CARBON_DIAGNOSTIC_KIND(MemberNameNotFound) CARBON_DIAGNOSTIC_KIND(MemberNameNotFoundInScope) CARBON_DIAGNOSTIC_KIND(NoPeriodSelfForDesignator) +CARBON_DIAGNOSTIC_KIND(UsedBeforeInitialization) CARBON_DIAGNOSTIC_KIND(AbstractTypeInAdaptDecl) +CARBON_DIAGNOSTIC_KIND(AbstractTypeInFieldDecl) CARBON_DIAGNOSTIC_KIND(AbstractTypeInFunctionReturnType) CARBON_DIAGNOSTIC_KIND(AbstractTypeInInit) CARBON_DIAGNOSTIC_KIND(AbstractTypeInVarDecl) @@ -340,8 +342,10 @@ CARBON_DIAGNOSTIC_KIND(NameUseBeforeDecl) CARBON_DIAGNOSTIC_KIND(NameUseBeforeDeclNote) CARBON_DIAGNOSTIC_KIND(RepeatedConst) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInAdaptDecl) +CARBON_DIAGNOSTIC_KIND(IncompleteTypeInAssociatedDecl) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInBaseDecl) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInConversion) +CARBON_DIAGNOSTIC_KIND(IncompleteTypeInFieldDecl) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInFunctionParam) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInFunctionReturnType) CARBON_DIAGNOSTIC_KIND(IncompleteTypeInMonomorphization) diff --git a/toolchain/lex/token_kind.def b/toolchain/lex/token_kind.def index 6177fbeb6605..a67b3a755a92 100644 --- a/toolchain/lex/token_kind.def +++ b/toolchain/lex/token_kind.def @@ -161,7 +161,8 @@ CARBON_DECL_INTRODUCER_TOKEN(Let, "let") CARBON_DECL_INTRODUCER_TOKEN(Library, "library") CARBON_DECL_INTRODUCER_TOKEN(Namespace, "namespace") CARBON_DECL_INTRODUCER_TOKEN(Package, "package") -CARBON_DECL_INTRODUCER_TOKEN(Var, "var") +CARBON_TOKEN_WITH_VIRTUAL_NODE( + CARBON_DECL_INTRODUCER_TOKEN(Var, "var")) CARBON_KEYWORD_TOKEN(Abstract, "abstract") CARBON_KEYWORD_TOKEN(Addr, "addr") diff --git a/toolchain/lower/file_context.cpp b/toolchain/lower/file_context.cpp index dcc0930e41b2..c7b42fb36c92 100644 --- a/toolchain/lower/file_context.cpp +++ b/toolchain/lower/file_context.cpp @@ -607,7 +607,7 @@ auto FileContext::BuildGlobalVariableDecl(SemIR::VarStorage var_storage) -> llvm::GlobalVariable* { // TODO: Mangle name. auto mangled_name = - *sem_ir().names().GetAsStringIfIdentifier(var_storage.name_id); + *sem_ir().names().GetAsStringIfIdentifier(var_storage.pretty_name_id); auto* type = GetType(var_storage.type_id); return new llvm::GlobalVariable( llvm_module(), type, diff --git a/toolchain/lower/handle.cpp b/toolchain/lower/handle.cpp index 5a22f570903e..593a717d0e81 100644 --- a/toolchain/lower/handle.cpp +++ b/toolchain/lower/handle.cpp @@ -183,6 +183,11 @@ auto HandleInst(FunctionContext& context, SemIR::InstId /*inst_id*/, context.FinishInit(storage_type_id, inst.dest_id, inst.src_id); } +auto HandleInst(FunctionContext& /*context*/, SemIR::InstId /*inst_id*/, + SemIR::NameBindingDecl /*inst*/) -> void { + // A NameBindingDecl is lowered by pattern matching. +} + auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, SemIR::NameRef inst) -> void { auto type_inst_id = context.sem_ir().types().GetInstId(inst.type_id); diff --git a/toolchain/lower/testdata/alias/local.carbon b/toolchain/lower/testdata/alias/local.carbon index 665a745679dd..fa9a8607fb72 100644 --- a/toolchain/lower/testdata/alias/local.carbon +++ b/toolchain/lower/testdata/alias/local.carbon @@ -21,9 +21,9 @@ fn F() -> i32 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %a.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %a.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %a.var, align 4, !dbg !8 -// CHECK:STDOUT: %.loc14 = load i32, ptr %a.var, align 4, !dbg !9 -// CHECK:STDOUT: ret i32 %.loc14, !dbg !10 +// CHECK:STDOUT: store i32 0, ptr %a.var, align 4, !dbg !7 +// CHECK:STDOUT: %.loc14 = load i32, ptr %a.var, align 4, !dbg !8 +// CHECK:STDOUT: ret i32 %.loc14, !dbg !9 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -41,7 +41,6 @@ fn F() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 10, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 14, column: 10, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/array/array_in_place.carbon b/toolchain/lower/testdata/array/array_in_place.carbon index 06f3a748d390..bacdc4704b19 100644 --- a/toolchain/lower/testdata/array/array_in_place.carbon +++ b/toolchain/lower/testdata/array/array_in_place.carbon @@ -45,7 +45,7 @@ fn G() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 33, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 14, column: 34, scope: !4) // CHECK:STDOUT: !10 = !DILocation(line: 14, column: 39, scope: !4) diff --git a/toolchain/lower/testdata/array/assign_return_value.carbon b/toolchain/lower/testdata/array/assign_return_value.carbon index d821bf737a44..bf21707f04a1 100644 --- a/toolchain/lower/testdata/array/assign_return_value.carbon +++ b/toolchain/lower/testdata/array/assign_return_value.carbon @@ -66,6 +66,6 @@ fn Run() { // CHECK:STDOUT: !7 = !DILocation(line: 11, column: 31, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 11, column: 24, scope: !4) // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 7, scope: !9) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !9) // CHECK:STDOUT: !11 = !DILocation(line: 14, column: 21, scope: !9) // CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !9) diff --git a/toolchain/lower/testdata/array/base.carbon b/toolchain/lower/testdata/array/base.carbon index 39c2ebfe8116..c51b2d671b3a 100644 --- a/toolchain/lower/testdata/array/base.carbon +++ b/toolchain/lower/testdata/array/base.carbon @@ -19,10 +19,10 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'base.carbon' // CHECK:STDOUT: source_filename = "base.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @array.237.loc12_25 = internal constant [1 x i32] [i32 1] -// CHECK:STDOUT: @array.6a2.loc13_33 = internal constant [2 x double] [double 0x4026333333333334, double 2.200000e+00] -// CHECK:STDOUT: @array.1cb.loc14_41 = internal constant [5 x {}] zeroinitializer -// CHECK:STDOUT: @tuple.loc15_37 = internal constant { i32, i32, i32 } { i32 1, i32 2, i32 3 } +// CHECK:STDOUT: @array.237.loc12_3.2 = internal constant [1 x i32] [i32 1] +// CHECK:STDOUT: @array.6a2.loc13_3.2 = internal constant [2 x double] [double 0x4026333333333334, double 2.200000e+00] +// CHECK:STDOUT: @array.1cb.loc14_3.2 = internal constant [5 x {}] zeroinitializer +// CHECK:STDOUT: @tuple.loc15_3.2 = internal constant { i32, i32, i32 } { i32 1, i32 2, i32 3 } // CHECK:STDOUT: // CHECK:STDOUT: define void @main() !dbg !4 { // CHECK:STDOUT: entry: @@ -33,37 +33,37 @@ fn Run() { // CHECK:STDOUT: %e.var = alloca [3 x i32], align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %a.var), !dbg !7 // CHECK:STDOUT: %.loc12_24.3.array.index = getelementptr inbounds [1 x i32], ptr %a.var, i32 0, i64 0, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @array.237.loc12_25, i64 4, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @array.237.loc12_3.2, i64 4, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 16, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %.loc13_32.2.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 0, !dbg !10 -// CHECK:STDOUT: %.loc13_32.4.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 1, !dbg !10 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.6a2.loc13_33, i64 16, i1 false), !dbg !11 +// CHECK:STDOUT: %.loc13_32.2.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 0, !dbg !9 +// CHECK:STDOUT: %.loc13_32.4.array.index = getelementptr inbounds [2 x double], ptr %b.var, i32 0, i64 1, !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %b.var, ptr align 8 @array.6a2.loc13_3.2, i64 16, i1 false), !dbg !10 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %c.var), !dbg !7 -// CHECK:STDOUT: %.loc14_40.2.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 0, !dbg !12 -// CHECK:STDOUT: %.loc14_40.4.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 1, !dbg !12 -// CHECK:STDOUT: %.loc14_40.6.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 2, !dbg !12 -// CHECK:STDOUT: %.loc14_40.8.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 3, !dbg !12 -// CHECK:STDOUT: %.loc14_40.10.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 4, !dbg !12 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @array.1cb.loc14_41, i64 0, i1 false), !dbg !13 +// CHECK:STDOUT: %.loc14_40.2.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 0, !dbg !11 +// CHECK:STDOUT: %.loc14_40.4.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 1, !dbg !11 +// CHECK:STDOUT: %.loc14_40.6.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 2, !dbg !11 +// CHECK:STDOUT: %.loc14_40.8.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 3, !dbg !11 +// CHECK:STDOUT: %.loc14_40.10.array.index = getelementptr inbounds [5 x {}], ptr %c.var, i32 0, i64 4, !dbg !11 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @array.1cb.loc14_3.2, i64 0, i1 false), !dbg !12 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 12, ptr %d.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !14 -// CHECK:STDOUT: %tuple.elem1.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !14 -// CHECK:STDOUT: %tuple.elem2.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !14 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d.var, ptr align 4 @tuple.loc15_37, i64 12, i1 false), !dbg !15 +// CHECK:STDOUT: %tuple.elem0.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !13 +// CHECK:STDOUT: %tuple.elem1.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !13 +// CHECK:STDOUT: %tuple.elem2.loc15.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !13 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d.var, ptr align 4 @tuple.loc15_3.2, i64 12, i1 false), !dbg !14 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 12, ptr %e.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !16 -// CHECK:STDOUT: %.loc16_21.1 = load i32, ptr %tuple.elem0.loc16.tuple.elem, align 4, !dbg !16 -// CHECK:STDOUT: %.loc16_21.2.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 0, !dbg !16 -// CHECK:STDOUT: store i32 %.loc16_21.1, ptr %.loc16_21.2.array.index, align 4, !dbg !16 -// CHECK:STDOUT: %tuple.elem1.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !16 -// CHECK:STDOUT: %.loc16_21.4 = load i32, ptr %tuple.elem1.loc16.tuple.elem, align 4, !dbg !16 -// CHECK:STDOUT: %.loc16_21.5.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 1, !dbg !16 -// CHECK:STDOUT: store i32 %.loc16_21.4, ptr %.loc16_21.5.array.index, align 4, !dbg !16 -// CHECK:STDOUT: %tuple.elem2.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !16 -// CHECK:STDOUT: %.loc16_21.7 = load i32, ptr %tuple.elem2.loc16.tuple.elem, align 4, !dbg !16 -// CHECK:STDOUT: %.loc16_21.8.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 2, !dbg !16 -// CHECK:STDOUT: store i32 %.loc16_21.7, ptr %.loc16_21.8.array.index, align 4, !dbg !16 -// CHECK:STDOUT: ret void, !dbg !17 +// CHECK:STDOUT: %tuple.elem0.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 0, !dbg !15 +// CHECK:STDOUT: %.loc16_21.1 = load i32, ptr %tuple.elem0.loc16.tuple.elem, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_21.2.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 0, !dbg !15 +// CHECK:STDOUT: store i32 %.loc16_21.1, ptr %.loc16_21.2.array.index, align 4, !dbg !15 +// CHECK:STDOUT: %tuple.elem1.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 1, !dbg !15 +// CHECK:STDOUT: %.loc16_21.4 = load i32, ptr %tuple.elem1.loc16.tuple.elem, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_21.5.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 1, !dbg !15 +// CHECK:STDOUT: store i32 %.loc16_21.4, ptr %.loc16_21.5.array.index, align 4, !dbg !15 +// CHECK:STDOUT: %tuple.elem2.loc16.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %d.var, i32 0, i32 2, !dbg !15 +// CHECK:STDOUT: %.loc16_21.7 = load i32, ptr %tuple.elem2.loc16.tuple.elem, align 4, !dbg !15 +// CHECK:STDOUT: %.loc16_21.8.array.index = getelementptr inbounds [3 x i32], ptr %e.var, i32 0, i64 2, !dbg !15 +// CHECK:STDOUT: store i32 %.loc16_21.7, ptr %.loc16_21.8.array.index, align 4, !dbg !15 +// CHECK:STDOUT: ret void, !dbg !16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -90,14 +90,13 @@ fn Run() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 21, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 21, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 20, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 28, scope: !4) -// CHECK:STDOUT: !15 = !DILocation(line: 15, column: 3, scope: !4) -// CHECK:STDOUT: !16 = !DILocation(line: 16, column: 21, scope: !4) -// CHECK:STDOUT: !17 = !DILocation(line: 11, column: 1, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 21, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 20, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 28, scope: !4) +// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !15 = !DILocation(line: 16, column: 21, scope: !4) +// CHECK:STDOUT: !16 = !DILocation(line: 11, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/basics/numeric_literals.carbon b/toolchain/lower/testdata/basics/numeric_literals.carbon index 37a0165efa32..9f241a089ec2 100644 --- a/toolchain/lower/testdata/basics/numeric_literals.carbon +++ b/toolchain/lower/testdata/basics/numeric_literals.carbon @@ -30,8 +30,8 @@ fn F() { // CHECK:STDOUT: ; ModuleID = 'numeric_literals.carbon' // CHECK:STDOUT: source_filename = "numeric_literals.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @array.712.loc19_4 = internal constant [4 x i32] [i32 8, i32 9, i32 8, i32 8] -// CHECK:STDOUT: @array.a2f.loc27_4 = internal constant [6 x double] [double 9.000000e-01, double 8.000000e+00, double 8.000000e+01, double 1.000000e+07, double 1.000000e+08, double 1.000000e-08] +// CHECK:STDOUT: @array.712.loc14_3.2 = internal constant [4 x i32] [i32 8, i32 9, i32 8, i32 8] +// CHECK:STDOUT: @array.a2f.loc20_3.2 = internal constant [6 x double] [double 9.000000e-01, double 8.000000e+00, double 8.000000e+01, double 1.000000e+07, double 1.000000e+08, double 1.000000e-08] // CHECK:STDOUT: // CHECK:STDOUT: define void @_CF.Main() !dbg !4 { // CHECK:STDOUT: entry: @@ -42,16 +42,16 @@ fn F() { // CHECK:STDOUT: %.loc19_3.6.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i64 1, !dbg !8 // CHECK:STDOUT: %.loc19_3.9.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i64 2, !dbg !8 // CHECK:STDOUT: %.loc19_3.12.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i64 3, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ints.var, ptr align 4 @array.712.loc19_4, i64 16, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ints.var, ptr align 4 @array.712.loc14_3.2, i64 16, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 48, ptr %floats.var), !dbg !7 -// CHECK:STDOUT: %.loc27_3.2.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 0, !dbg !10 -// CHECK:STDOUT: %.loc27_3.4.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 1, !dbg !10 -// CHECK:STDOUT: %.loc27_3.6.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 2, !dbg !10 -// CHECK:STDOUT: %.loc27_3.8.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 3, !dbg !10 -// CHECK:STDOUT: %.loc27_3.10.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 4, !dbg !10 -// CHECK:STDOUT: %.loc27_3.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 5, !dbg !10 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.a2f.loc27_4, i64 48, i1 false), !dbg !11 -// CHECK:STDOUT: ret void, !dbg !12 +// CHECK:STDOUT: %.loc27_3.2.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 0, !dbg !9 +// CHECK:STDOUT: %.loc27_3.4.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 1, !dbg !9 +// CHECK:STDOUT: %.loc27_3.6.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 2, !dbg !9 +// CHECK:STDOUT: %.loc27_3.8.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 3, !dbg !9 +// CHECK:STDOUT: %.loc27_3.10.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 4, !dbg !9 +// CHECK:STDOUT: %.loc27_3.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i64 5, !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.a2f.loc20_3.2, i64 48, i1 false), !dbg !10 +// CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -77,9 +77,8 @@ fn F() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 24, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 26, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 20, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 11, column: 1, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 26, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 11, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/builtins/no_prelude/types.carbon b/toolchain/lower/testdata/builtins/no_prelude/types.carbon index 4c1f2d5f4d9c..693bde656918 100644 --- a/toolchain/lower/testdata/builtins/no_prelude/types.carbon +++ b/toolchain/lower/testdata/builtins/no_prelude/types.carbon @@ -29,12 +29,12 @@ fn F() { // CHECK:STDOUT: %f.var = alloca double, align 8, !dbg !7 // CHECK:STDOUT: %b.var = alloca i1, align 1, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %i.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %i.var, align 4, !dbg !8 +// CHECK:STDOUT: store i32 0, ptr %i.var, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %f.var), !dbg !7 -// CHECK:STDOUT: store double 0.000000e+00, ptr %f.var, align 8, !dbg !9 +// CHECK:STDOUT: store double 0.000000e+00, ptr %f.var, align 8, !dbg !8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 1, ptr %b.var), !dbg !7 -// CHECK:STDOUT: store i1 false, ptr %b.var, align 1, !dbg !10 -// CHECK:STDOUT: ret void, !dbg !11 +// CHECK:STDOUT: store i1 false, ptr %b.var, align 1, !dbg !9 +// CHECK:STDOUT: ret void, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -55,8 +55,7 @@ fn F() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 18, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 19, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 3, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 17, column: 1, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 19, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 3, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 17, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/class/adapt.carbon b/toolchain/lower/testdata/class/adapt.carbon index 14b616e3efbb..d141c9bf3c8d 100644 --- a/toolchain/lower/testdata/class/adapt.carbon +++ b/toolchain/lower/testdata/class/adapt.carbon @@ -114,7 +114,7 @@ fn DoStuff(a: Int) -> Int { // CHECK:STDOUT: !13 = !DILocation(line: 22, column: 12, scope: !12) // CHECK:STDOUT: !14 = !DILocation(line: 22, column: 5, scope: !12) // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "Use", linkageName: "_CUse.Main", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !16 = !DILocation(line: 27, column: 7, scope: !15) +// CHECK:STDOUT: !16 = !DILocation(line: 27, column: 3, scope: !15) // CHECK:STDOUT: !17 = !DILocation(line: 27, column: 25, scope: !15) // CHECK:STDOUT: !18 = !DILocation(line: 28, column: 10, scope: !15) // CHECK:STDOUT: !19 = !DILocation(line: 28, column: 3, scope: !15) diff --git a/toolchain/lower/testdata/class/basic.carbon b/toolchain/lower/testdata/class/basic.carbon index cbd22bcad30b..1095ef16ee35 100644 --- a/toolchain/lower/testdata/class/basic.carbon +++ b/toolchain/lower/testdata/class/basic.carbon @@ -53,6 +53,6 @@ fn Run() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 18, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 19, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 19, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 20, column: 14, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 18, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/class/convert.carbon b/toolchain/lower/testdata/class/convert.carbon index 61d2b4046bd0..93443673d556 100644 --- a/toolchain/lower/testdata/class/convert.carbon +++ b/toolchain/lower/testdata/class/convert.carbon @@ -26,7 +26,7 @@ fn DoIt() { // CHECK:STDOUT: ; ModuleID = 'convert.carbon' // CHECK:STDOUT: source_filename = "convert.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @IntWrapper.val.loc22_32 = internal constant { i32 } { i32 42 } +// CHECK:STDOUT: @IntWrapper.val.loc22_3.2 = internal constant { i32 } { i32 42 } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @"_CConvert.IntWrapper.Main:ImplicitAs.Core"(ptr %self) !dbg !4 { // CHECK:STDOUT: entry: @@ -45,10 +45,10 @@ fn DoIt() { // CHECK:STDOUT: %w.var = alloca { i32 }, align 8, !dbg !12 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %w.var), !dbg !12 // CHECK:STDOUT: %.loc22_31.3.n = getelementptr inbounds nuw { i32 }, ptr %w.var, i32 0, i32 0, !dbg !13 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %w.var, ptr align 4 @IntWrapper.val.loc22_32, i64 4, i1 false), !dbg !14 -// CHECK:STDOUT: %Convert.call = call i32 @"_CConvert.IntWrapper.Main:ImplicitAs.Core"(ptr %w.var), !dbg !15 -// CHECK:STDOUT: call void @_CConsume.Main(i32 %Convert.call), !dbg !16 -// CHECK:STDOUT: ret void, !dbg !17 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %w.var, ptr align 4 @IntWrapper.val.loc22_3.2, i64 4, i1 false), !dbg !12 +// CHECK:STDOUT: %Convert.call = call i32 @"_CConvert.IntWrapper.Main:ImplicitAs.Core"(ptr %w.var), !dbg !14 +// CHECK:STDOUT: call void @_CConsume.Main(i32 %Convert.call), !dbg !15 +// CHECK:STDOUT: ret void, !dbg !16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -75,9 +75,8 @@ fn DoIt() { // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Consume", linkageName: "_CConsume.Main", scope: null, file: !3, line: 19, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !10 = !DILocation(line: 19, column: 1, scope: !9) // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "DoIt", linkageName: "_CDoIt.Main", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !12 = !DILocation(line: 22, column: 7, scope: !11) +// CHECK:STDOUT: !12 = !DILocation(line: 22, column: 3, scope: !11) // CHECK:STDOUT: !13 = !DILocation(line: 22, column: 23, scope: !11) -// CHECK:STDOUT: !14 = !DILocation(line: 22, column: 3, scope: !11) -// CHECK:STDOUT: !15 = !DILocation(line: 23, column: 11, scope: !11) -// CHECK:STDOUT: !16 = !DILocation(line: 23, column: 3, scope: !11) -// CHECK:STDOUT: !17 = !DILocation(line: 21, column: 1, scope: !11) +// CHECK:STDOUT: !14 = !DILocation(line: 23, column: 11, scope: !11) +// CHECK:STDOUT: !15 = !DILocation(line: 23, column: 3, scope: !11) +// CHECK:STDOUT: !16 = !DILocation(line: 21, column: 1, scope: !11) diff --git a/toolchain/lower/testdata/class/field.carbon b/toolchain/lower/testdata/class/field.carbon index 741b13c64af5..43b4af453adc 100644 --- a/toolchain/lower/testdata/class/field.carbon +++ b/toolchain/lower/testdata/class/field.carbon @@ -67,7 +67,7 @@ fn Run() -> i32 { // CHECK:STDOUT: !8 = !DILocation(line: 17, column: 10, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 17, column: 3, scope: !4) // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !11 = !DILocation(line: 21, column: 7, scope: !10) +// CHECK:STDOUT: !11 = !DILocation(line: 21, column: 3, scope: !10) // CHECK:STDOUT: !12 = !DILocation(line: 22, column: 3, scope: !10) // CHECK:STDOUT: !13 = !DILocation(line: 23, column: 3, scope: !10) // CHECK:STDOUT: !14 = !DILocation(line: 24, column: 10, scope: !10) diff --git a/toolchain/lower/testdata/class/method.carbon b/toolchain/lower/testdata/class/method.carbon index c70b6c06938b..3faaca82ab24 100644 --- a/toolchain/lower/testdata/class/method.carbon +++ b/toolchain/lower/testdata/class/method.carbon @@ -30,8 +30,11 @@ fn F(p: C*) { // CHECK:STDOUT: define void @_CF.Main(ptr %p) !dbg !4 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %Get.call = call i32 @_CGet.C.Main(ptr %p), !dbg !7 -// CHECK:STDOUT: call void @_CSet.C.Main(ptr %p, i32 %Get.call), !dbg !8 -// CHECK:STDOUT: ret void, !dbg !9 +// CHECK:STDOUT: %.loc19_25.1.temp = alloca i32, align 4, !dbg !7 +// CHECK:STDOUT: store i32 %Get.call, ptr %.loc19_25.1.temp, align 4, !dbg !7 +// CHECK:STDOUT: %.loc20_12 = load i32, ptr %.loc19_25.1.temp, align 4, !dbg !8 +// CHECK:STDOUT: call void @_CSet.C.Main(ptr %p, i32 %.loc20_12), !dbg !9 +// CHECK:STDOUT: ret void, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.module.flags = !{!0, !1} @@ -45,5 +48,6 @@ fn F(p: C*) { // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 19, column: 16, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 20, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 18, column: 1, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 20, column: 12, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 3, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 18, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/class/virtual.carbon b/toolchain/lower/testdata/class/virtual.carbon index 82e37a764c47..a9134dcccff1 100644 --- a/toolchain/lower/testdata/class/virtual.carbon +++ b/toolchain/lower/testdata/class/virtual.carbon @@ -113,7 +113,7 @@ fn Fn() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Create", linkageName: "_CCreate.Create", scope: null, file: !3, line: 6, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 7, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 7, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 6, column: 1, scope: !4) // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Use", linkageName: "_CUse.Create", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !9) @@ -128,16 +128,16 @@ fn Fn() { // CHECK:STDOUT: %i.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: %v.var = alloca { ptr, i32 }, align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %i.var), !dbg !7 -// CHECK:STDOUT: store i32 3, ptr %i.var, align 4, !dbg !8 +// CHECK:STDOUT: store i32 3, ptr %i.var, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 16, ptr %v.var), !dbg !7 -// CHECK:STDOUT: %.loc12_24.2.vptr = getelementptr inbounds nuw { ptr, i32 }, ptr %v.var, i32 0, i32 0, !dbg !9 -// CHECK:STDOUT: store ptr null, ptr %.loc12_24.2.vptr, align 8, !dbg !9 -// CHECK:STDOUT: %.loc12_23 = load i32, ptr %i.var, align 4, !dbg !10 -// CHECK:STDOUT: %.loc12_24.5.m = getelementptr inbounds nuw { ptr, i32 }, ptr %v.var, i32 0, i32 1, !dbg !9 -// CHECK:STDOUT: store i32 %.loc12_23, ptr %.loc12_24.5.m, align 4, !dbg !9 -// CHECK:STDOUT: %.loc15_4.m = getelementptr inbounds nuw { ptr, i32 }, ptr %v.var, i32 0, i32 1, !dbg !11 -// CHECK:STDOUT: store i32 5, ptr %.loc15_4.m, align 4, !dbg !11 -// CHECK:STDOUT: ret void, !dbg !12 +// CHECK:STDOUT: %.loc12_24.2.vptr = getelementptr inbounds nuw { ptr, i32 }, ptr %v.var, i32 0, i32 0, !dbg !8 +// CHECK:STDOUT: store ptr null, ptr %.loc12_24.2.vptr, align 8, !dbg !8 +// CHECK:STDOUT: %.loc12_23 = load i32, ptr %i.var, align 4, !dbg !9 +// CHECK:STDOUT: %.loc12_24.5.m = getelementptr inbounds nuw { ptr, i32 }, ptr %v.var, i32 0, i32 1, !dbg !8 +// CHECK:STDOUT: store i32 %.loc12_23, ptr %.loc12_24.5.m, align 4, !dbg !8 +// CHECK:STDOUT: %.loc15_4.m = getelementptr inbounds nuw { ptr, i32 }, ptr %v.var, i32 0, i32 1, !dbg !10 +// CHECK:STDOUT: store i32 5, ptr %.loc15_4.m, align 4, !dbg !10 +// CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -158,9 +158,8 @@ fn Fn() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Fn", linkageName: "_CFn.MemberInit", scope: null, file: !3, line: 9, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 10, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 10, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 17, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 12, column: 23, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 9, column: 1, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 10, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 17, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 23, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 9, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/function/call/empty_struct.carbon b/toolchain/lower/testdata/function/call/empty_struct.carbon index 99e62bb29767..081ed686d1bf 100644 --- a/toolchain/lower/testdata/function/call/empty_struct.carbon +++ b/toolchain/lower/testdata/function/call/empty_struct.carbon @@ -49,6 +49,6 @@ fn Main() { // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8) +// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !8) // CHECK:STDOUT: !10 = !DILocation(line: 16, column: 15, scope: !8) // CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8) diff --git a/toolchain/lower/testdata/function/call/empty_tuple.carbon b/toolchain/lower/testdata/function/call/empty_tuple.carbon index 4775599234b2..1ccbe54cf93b 100644 --- a/toolchain/lower/testdata/function/call/empty_tuple.carbon +++ b/toolchain/lower/testdata/function/call/empty_tuple.carbon @@ -49,6 +49,6 @@ fn Main() { // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8) +// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !8) // CHECK:STDOUT: !10 = !DILocation(line: 16, column: 15, scope: !8) // CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8) diff --git a/toolchain/lower/testdata/function/call/i32.carbon b/toolchain/lower/testdata/function/call/i32.carbon index 8457c4375463..6d235ba06ec3 100644 --- a/toolchain/lower/testdata/function/call/i32.carbon +++ b/toolchain/lower/testdata/function/call/i32.carbon @@ -29,8 +29,8 @@ fn Main() { // CHECK:STDOUT: %b.var = alloca i32, align 4, !dbg !9 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %b.var), !dbg !9 // CHECK:STDOUT: %Echo.call = call i32 @_CEcho.Main(i32 1), !dbg !10 -// CHECK:STDOUT: store i32 %Echo.call, ptr %b.var, align 4, !dbg !11 -// CHECK:STDOUT: ret void, !dbg !12 +// CHECK:STDOUT: store i32 %Echo.call, ptr %b.var, align 4, !dbg !9 +// CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -50,7 +50,6 @@ fn Main() { // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8) +// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !8) // CHECK:STDOUT: !10 = !DILocation(line: 16, column: 16, scope: !8) -// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 3, scope: !8) -// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 1, scope: !8) +// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8) diff --git a/toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon b/toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon index 18f7ed1931a0..5e2ab0e48ee4 100644 --- a/toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon +++ b/toolchain/lower/testdata/function/call/implicit_empty_tuple_as_arg.carbon @@ -59,7 +59,7 @@ fn Main() { // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Bar", linkageName: "_CBar.Main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !9 = !DILocation(line: 14, column: 23, scope: !8) // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !11 = !DILocation(line: 17, column: 7, scope: !10) +// CHECK:STDOUT: !11 = !DILocation(line: 17, column: 3, scope: !10) // CHECK:STDOUT: !12 = !DILocation(line: 17, column: 19, scope: !10) // CHECK:STDOUT: !13 = !DILocation(line: 17, column: 15, scope: !10) // CHECK:STDOUT: !14 = !DILocation(line: 16, column: 1, scope: !10) diff --git a/toolchain/lower/testdata/function/call/return_implicit.carbon b/toolchain/lower/testdata/function/call/return_implicit.carbon index 2fba16122b3d..d07f87bc6cc6 100644 --- a/toolchain/lower/testdata/function/call/return_implicit.carbon +++ b/toolchain/lower/testdata/function/call/return_implicit.carbon @@ -49,6 +49,6 @@ fn Main() { // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 12, column: 1, scope: !4) // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 7, scope: !8) +// CHECK:STDOUT: !9 = !DILocation(line: 16, column: 3, scope: !8) // CHECK:STDOUT: !10 = !DILocation(line: 16, column: 15, scope: !8) // CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !8) diff --git a/toolchain/lower/testdata/function/call/var_param.carbon b/toolchain/lower/testdata/function/call/var_param.carbon index 1790ca4befc3..49e56352bd00 100644 --- a/toolchain/lower/testdata/function/call/var_param.carbon +++ b/toolchain/lower/testdata/function/call/var_param.carbon @@ -27,10 +27,10 @@ fn Main() { // CHECK:STDOUT: entry: // CHECK:STDOUT: %a.var = alloca i32, align 4, !dbg !9 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %a.var), !dbg !9 -// CHECK:STDOUT: store i32 0, ptr %a.var, align 4, !dbg !10 -// CHECK:STDOUT: %.loc15 = load i32, ptr %a.var, align 4, !dbg !11 -// CHECK:STDOUT: call void @_CDoNothing.Main(i32 %.loc15), !dbg !12 -// CHECK:STDOUT: ret void, !dbg !13 +// CHECK:STDOUT: store i32 0, ptr %a.var, align 4, !dbg !9 +// CHECK:STDOUT: %.loc15 = load i32, ptr %a.var, align 4, !dbg !10 +// CHECK:STDOUT: call void @_CDoNothing.Main(i32 %.loc15), !dbg !11 +// CHECK:STDOUT: ret void, !dbg !12 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -50,8 +50,7 @@ fn Main() { // CHECK:STDOUT: !6 = !{} // CHECK:STDOUT: !7 = !DILocation(line: 11, column: 1, scope: !4) // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 7, scope: !8) -// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !8) -// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 13, scope: !8) -// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 3, scope: !8) -// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 1, scope: !8) +// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !8) +// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 13, scope: !8) +// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 3, scope: !8) +// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !8) diff --git a/toolchain/lower/testdata/function/generic/call.carbon b/toolchain/lower/testdata/function/generic/call.carbon index 41daffda9f11..9d746e7f06eb 100644 --- a/toolchain/lower/testdata/function/generic/call.carbon +++ b/toolchain/lower/testdata/function/generic/call.carbon @@ -30,8 +30,8 @@ fn G() { // CHECK:STDOUT: // CHECK:STDOUT: %type = type {} // CHECK:STDOUT: -// CHECK:STDOUT: @C.val.loc18_16 = internal constant {} zeroinitializer -// CHECK:STDOUT: @D.val.loc19_16 = internal constant {} zeroinitializer +// CHECK:STDOUT: @C.val.loc18_3.2 = internal constant {} zeroinitializer +// CHECK:STDOUT: @D.val.loc19_3.2 = internal constant {} zeroinitializer // CHECK:STDOUT: // CHECK:STDOUT: define void @_CG.Main() !dbg !4 { // CHECK:STDOUT: entry: @@ -39,17 +39,17 @@ fn G() { // CHECK:STDOUT: %d.var = alloca {}, align 8, !dbg !7 // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %c.var), !dbg !7 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc18_16, i64 0, i1 false), !dbg !8 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc18_3.2, i64 0, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %d.var), !dbg !7 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %d.var, ptr align 1 @D.val.loc19_16, i64 0, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %d.var, ptr align 1 @D.val.loc19_3.2, i64 0, i1 false), !dbg !8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %n.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !10 -// CHECK:STDOUT: call void @_CF.Main.15b1f98bd9cc0c5b(ptr %c.var), !dbg !11 -// CHECK:STDOUT: call void @_CF.Main.2cc450fc05045897(ptr %d.var), !dbg !12 -// CHECK:STDOUT: %.loc24 = load i32, ptr %n.var, align 4, !dbg !13 -// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %.loc24), !dbg !14 -// CHECK:STDOUT: call void @_CF.Main.5754c7a55c7cbe4a(%type zeroinitializer), !dbg !15 -// CHECK:STDOUT: ret void, !dbg !16 +// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !9 +// CHECK:STDOUT: call void @_CF.Main.15b1f98bd9cc0c5b(ptr %c.var), !dbg !10 +// CHECK:STDOUT: call void @_CF.Main.2cc450fc05045897(ptr %d.var), !dbg !11 +// CHECK:STDOUT: %.loc24 = load i32, ptr %n.var, align 4, !dbg !12 +// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %.loc24), !dbg !13 +// CHECK:STDOUT: call void @_CF.Main.5754c7a55c7cbe4a(%type zeroinitializer), !dbg !14 +// CHECK:STDOUT: ret void, !dbg !15 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -83,13 +83,12 @@ fn G() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 18, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 19, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 3, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 22, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 23, column: 3, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 24, column: 5, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 24, column: 3, scope: !4) -// CHECK:STDOUT: !15 = !DILocation(line: 25, column: 3, scope: !4) -// CHECK:STDOUT: !16 = !DILocation(line: 17, column: 1, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 19, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 3, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 22, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 23, column: 3, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 24, column: 5, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 24, column: 3, scope: !4) +// CHECK:STDOUT: !14 = !DILocation(line: 25, column: 3, scope: !4) +// CHECK:STDOUT: !15 = !DILocation(line: 17, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/function/generic/call_method.carbon b/toolchain/lower/testdata/function/generic/call_method.carbon index bfa7c92d59f0..0e54ac32ab94 100644 --- a/toolchain/lower/testdata/function/generic/call_method.carbon +++ b/toolchain/lower/testdata/function/generic/call_method.carbon @@ -23,19 +23,19 @@ fn CallF() -> i32 { // CHECK:STDOUT: ; ModuleID = 'call_method.carbon' // CHECK:STDOUT: source_filename = "call_method.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @C.val.loc18_16 = internal constant {} zeroinitializer +// CHECK:STDOUT: @C.val.loc18_3.2 = internal constant {} zeroinitializer // CHECK:STDOUT: // CHECK:STDOUT: define i32 @_CCallF.Main() !dbg !4 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !7 // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 0, ptr %c.var), !dbg !7 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc18_16, i64 0, i1 false), !dbg !8 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc18_3.2, i64 0, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %n.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !9 -// CHECK:STDOUT: %.loc20_14 = load i32, ptr %n.var, align 4, !dbg !10 -// CHECK:STDOUT: %F.call = call i32 @_CF.C.Main.b88d1103f417c6d4(ptr %c.var, i32 %.loc20_14), !dbg !11 -// CHECK:STDOUT: ret i32 %F.call, !dbg !12 +// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !8 +// CHECK:STDOUT: %.loc20_14 = load i32, ptr %n.var, align 4, !dbg !9 +// CHECK:STDOUT: %F.call = call i32 @_CF.C.Main.b88d1103f417c6d4(ptr %c.var, i32 %.loc20_14), !dbg !10 +// CHECK:STDOUT: ret i32 %F.call, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -62,9 +62,8 @@ fn CallF() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "CallF", linkageName: "_CCallF.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 18, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 19, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 14, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 20, column: 10, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 20, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 18, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 19, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 20, column: 14, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 20, column: 10, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 20, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/global/class_obj.carbon b/toolchain/lower/testdata/global/class_obj.carbon index aac5deb70481..450d31e182fb 100644 --- a/toolchain/lower/testdata/global/class_obj.carbon +++ b/toolchain/lower/testdata/global/class_obj.carbon @@ -15,12 +15,12 @@ var a: A = {}; // CHECK:STDOUT: source_filename = "class_obj.carbon" // CHECK:STDOUT: // CHECK:STDOUT: @a = internal global {} zeroinitializer -// CHECK:STDOUT: @A.val.loc12_14 = internal constant {} zeroinitializer +// CHECK:STDOUT: @A.val.loc12_1 = internal constant {} zeroinitializer // CHECK:STDOUT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @_C__global_init.Main, ptr null }] // CHECK:STDOUT: // CHECK:STDOUT: define void @_C__global_init.Main() !dbg !4 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @A.val.loc12_14, i64 0, i1 false), !dbg !7 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @A.val.loc12_1, i64 0, i1 false), !dbg !7 // CHECK:STDOUT: ret void, !dbg !8 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/lower/testdata/global/class_with_fun.carbon b/toolchain/lower/testdata/global/class_with_fun.carbon index 065f983ed6ef..6172cd2ca047 100644 --- a/toolchain/lower/testdata/global/class_with_fun.carbon +++ b/toolchain/lower/testdata/global/class_with_fun.carbon @@ -20,7 +20,7 @@ var a: A = {}; // CHECK:STDOUT: // CHECK:STDOUT: @a = internal global {} zeroinitializer // CHECK:STDOUT: @A.val.loc13_12 = internal constant {} zeroinitializer -// CHECK:STDOUT: @A.val.loc16_14 = internal constant {} zeroinitializer +// CHECK:STDOUT: @A.val.loc16_1 = internal constant {} zeroinitializer // CHECK:STDOUT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @_C__global_init.Main, ptr null }] // CHECK:STDOUT: // CHECK:STDOUT: define void @_Cret_a.Main(ptr sret({}) %return) !dbg !4 { @@ -31,7 +31,7 @@ var a: A = {}; // CHECK:STDOUT: // CHECK:STDOUT: define void @_C__global_init.Main() !dbg !8 { // CHECK:STDOUT: entry: -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @A.val.loc16_14, i64 0, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 @a, ptr align 1 @A.val.loc16_1, i64 0, i1 false), !dbg !9 // CHECK:STDOUT: ret void, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/lower/testdata/index/array_element_access.carbon b/toolchain/lower/testdata/index/array_element_access.carbon index 7f05b2a1b7ef..6283c86a8a8f 100644 --- a/toolchain/lower/testdata/index/array_element_access.carbon +++ b/toolchain/lower/testdata/index/array_element_access.carbon @@ -103,7 +103,7 @@ fn Run() { // CHECK:STDOUT: !10 = !DILocation(line: 12, column: 29, scope: !9) // CHECK:STDOUT: !11 = !DILocation(line: 12, column: 22, scope: !9) // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 7, scope: !12) +// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !12) // CHECK:STDOUT: !14 = !DILocation(line: 15, column: 21, scope: !12) // CHECK:STDOUT: !15 = !DILocation(line: 16, column: 3, scope: !12) // CHECK:STDOUT: !16 = !DILocation(line: 17, column: 18, scope: !12) diff --git a/toolchain/lower/testdata/let/tuple.carbon b/toolchain/lower/testdata/let/tuple.carbon index 2e43ed668668..895418af261a 100644 --- a/toolchain/lower/testdata/let/tuple.carbon +++ b/toolchain/lower/testdata/let/tuple.carbon @@ -18,8 +18,8 @@ fn F() -> i32 { // CHECK:STDOUT: ; ModuleID = 'tuple.carbon' // CHECK:STDOUT: source_filename = "tuple.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @tuple.ee6.loc12_37 = internal constant { i32, i32, i32 } { i32 1, i32 2, i32 3 } -// CHECK:STDOUT: @tuple.0a0.loc13_29 = internal constant { i32, i32 } { i32 4, i32 5 } +// CHECK:STDOUT: @tuple.ee6.loc12_3.2 = internal constant { i32, i32, i32 } { i32 1, i32 2, i32 3 } +// CHECK:STDOUT: @tuple.0a0.loc13_3.2 = internal constant { i32, i32 } { i32 4, i32 5 } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @_CF.Main() !dbg !4 { // CHECK:STDOUT: entry: @@ -29,43 +29,43 @@ fn F() -> i32 { // CHECK:STDOUT: %tuple.elem0.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !8 // CHECK:STDOUT: %tuple.elem1.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !8 // CHECK:STDOUT: %tuple.elem2.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.ee6.loc12_37, i64 12, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.ee6.loc12_3.2, i64 12, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.loc13.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: %tuple.elem1.loc13.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.0a0.loc13_29, i64 8, i1 false), !dbg !11 -// CHECK:STDOUT: %tuple.elem0.loc14_43.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !12 -// CHECK:STDOUT: %.loc14_43.1 = load i32, ptr %tuple.elem0.loc14_43.tuple.elem, align 4, !dbg !12 -// CHECK:STDOUT: %tuple.elem1.loc14_43.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !12 -// CHECK:STDOUT: %.loc14_43.2 = load i32, ptr %tuple.elem1.loc14_43.tuple.elem, align 4, !dbg !12 -// CHECK:STDOUT: %tuple.elem2.loc14.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !12 -// CHECK:STDOUT: %.loc14_43.3 = load i32, ptr %tuple.elem2.loc14.tuple.elem, align 4, !dbg !12 -// CHECK:STDOUT: %tuple.loc14_43 = alloca { i32, i32, i32 }, align 8, !dbg !12 -// CHECK:STDOUT: %tuple.loc14_431 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 0, !dbg !12 -// CHECK:STDOUT: store i32 %.loc14_43.1, ptr %tuple.loc14_431, align 4, !dbg !12 -// CHECK:STDOUT: %tuple.loc14_432 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 1, !dbg !12 -// CHECK:STDOUT: store i32 %.loc14_43.2, ptr %tuple.loc14_432, align 4, !dbg !12 -// CHECK:STDOUT: %tuple.loc14_433 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 2, !dbg !12 -// CHECK:STDOUT: store i32 %.loc14_43.3, ptr %tuple.loc14_433, align 4, !dbg !12 -// CHECK:STDOUT: %tuple.elem0.loc14_46.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !13 -// CHECK:STDOUT: %.loc14_46.1 = load i32, ptr %tuple.elem0.loc14_46.tuple.elem, align 4, !dbg !13 -// CHECK:STDOUT: %tuple.elem1.loc14_46.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !13 -// CHECK:STDOUT: %.loc14_46.2 = load i32, ptr %tuple.elem1.loc14_46.tuple.elem, align 4, !dbg !13 -// CHECK:STDOUT: %tuple.loc14_46 = alloca { i32, i32 }, align 8, !dbg !13 -// CHECK:STDOUT: %tuple.loc14_464 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 0, !dbg !13 -// CHECK:STDOUT: store i32 %.loc14_46.1, ptr %tuple.loc14_464, align 4, !dbg !13 -// CHECK:STDOUT: %tuple.loc14_465 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 1, !dbg !13 -// CHECK:STDOUT: store i32 %.loc14_46.2, ptr %tuple.loc14_465, align 4, !dbg !13 -// CHECK:STDOUT: %tuple.loc14_47 = alloca { ptr, ptr }, align 8, !dbg !14 -// CHECK:STDOUT: %tuple.loc14_476 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 0, !dbg !14 -// CHECK:STDOUT: store ptr %tuple.loc14_43, ptr %tuple.loc14_476, align 8, !dbg !14 -// CHECK:STDOUT: %tuple.loc14_477 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1, !dbg !14 -// CHECK:STDOUT: store ptr %tuple.loc14_46, ptr %tuple.loc14_477, align 8, !dbg !14 -// CHECK:STDOUT: %tuple.elem1.loc15_11.tuple.elem = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1, !dbg !15 -// CHECK:STDOUT: %tuple.elem1.loc15_11.tuple.elem.load = load ptr, ptr %tuple.elem1.loc15_11.tuple.elem, align 8, !dbg !15 -// CHECK:STDOUT: %tuple.elem1.loc15_13.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.elem1.loc15_11.tuple.elem.load, i32 0, i32 1, !dbg !15 -// CHECK:STDOUT: %tuple.elem1.loc15_13.tuple.elem.load = load i32, ptr %tuple.elem1.loc15_13.tuple.elem, align 4, !dbg !15 -// CHECK:STDOUT: ret i32 %tuple.elem1.loc15_13.tuple.elem.load, !dbg !16 +// CHECK:STDOUT: %tuple.elem0.loc13.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: %tuple.elem1.loc13.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.0a0.loc13_3.2, i64 8, i1 false), !dbg !10 +// CHECK:STDOUT: %tuple.elem0.loc14_43.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !11 +// CHECK:STDOUT: %.loc14_43.1 = load i32, ptr %tuple.elem0.loc14_43.tuple.elem, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.elem1.loc14_43.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !11 +// CHECK:STDOUT: %.loc14_43.2 = load i32, ptr %tuple.elem1.loc14_43.tuple.elem, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.elem2.loc14.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !11 +// CHECK:STDOUT: %.loc14_43.3 = load i32, ptr %tuple.elem2.loc14.tuple.elem, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.loc14_43 = alloca { i32, i32, i32 }, align 8, !dbg !11 +// CHECK:STDOUT: %tuple.loc14_431 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 0, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_43.1, ptr %tuple.loc14_431, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.loc14_432 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 1, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_43.2, ptr %tuple.loc14_432, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.loc14_433 = getelementptr inbounds nuw { i32, i32, i32 }, ptr %tuple.loc14_43, i32 0, i32 2, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_43.3, ptr %tuple.loc14_433, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.elem0.loc14_46.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !12 +// CHECK:STDOUT: %.loc14_46.1 = load i32, ptr %tuple.elem0.loc14_46.tuple.elem, align 4, !dbg !12 +// CHECK:STDOUT: %tuple.elem1.loc14_46.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !12 +// CHECK:STDOUT: %.loc14_46.2 = load i32, ptr %tuple.elem1.loc14_46.tuple.elem, align 4, !dbg !12 +// CHECK:STDOUT: %tuple.loc14_46 = alloca { i32, i32 }, align 8, !dbg !12 +// CHECK:STDOUT: %tuple.loc14_464 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 0, !dbg !12 +// CHECK:STDOUT: store i32 %.loc14_46.1, ptr %tuple.loc14_464, align 4, !dbg !12 +// CHECK:STDOUT: %tuple.loc14_465 = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.loc14_46, i32 0, i32 1, !dbg !12 +// CHECK:STDOUT: store i32 %.loc14_46.2, ptr %tuple.loc14_465, align 4, !dbg !12 +// CHECK:STDOUT: %tuple.loc14_47 = alloca { ptr, ptr }, align 8, !dbg !13 +// CHECK:STDOUT: %tuple.loc14_476 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 0, !dbg !13 +// CHECK:STDOUT: store ptr %tuple.loc14_43, ptr %tuple.loc14_476, align 8, !dbg !13 +// CHECK:STDOUT: %tuple.loc14_477 = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1, !dbg !13 +// CHECK:STDOUT: store ptr %tuple.loc14_46, ptr %tuple.loc14_477, align 8, !dbg !13 +// CHECK:STDOUT: %tuple.elem1.loc15_11.tuple.elem = getelementptr inbounds nuw { ptr, ptr }, ptr %tuple.loc14_47, i32 0, i32 1, !dbg !14 +// CHECK:STDOUT: %tuple.elem1.loc15_11.tuple.elem.load = load ptr, ptr %tuple.elem1.loc15_11.tuple.elem, align 8, !dbg !14 +// CHECK:STDOUT: %tuple.elem1.loc15_13.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %tuple.elem1.loc15_11.tuple.elem.load, i32 0, i32 1, !dbg !14 +// CHECK:STDOUT: %tuple.elem1.loc15_13.tuple.elem.load = load i32, ptr %tuple.elem1.loc15_13.tuple.elem, align 4, !dbg !14 +// CHECK:STDOUT: ret i32 %tuple.elem1.loc15_13.tuple.elem.load, !dbg !15 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -92,13 +92,12 @@ fn F() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 28, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 23, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 43, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 46, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 14, column: 42, scope: !4) -// CHECK:STDOUT: !15 = !DILocation(line: 15, column: 10, scope: !4) -// CHECK:STDOUT: !16 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 23, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 43, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 46, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 42, scope: !4) +// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 10, scope: !4) +// CHECK:STDOUT: !15 = !DILocation(line: 15, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/operators/assignment.carbon b/toolchain/lower/testdata/operators/assignment.carbon index c2939c144318..7419cc362e78 100644 --- a/toolchain/lower/testdata/operators/assignment.carbon +++ b/toolchain/lower/testdata/operators/assignment.carbon @@ -25,13 +25,13 @@ fn Main() { // CHECK:STDOUT: %a.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: %b.var = alloca { i32, i32 }, align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %a.var), !dbg !7 -// CHECK:STDOUT: store i32 12, ptr %a.var, align 4, !dbg !8 -// CHECK:STDOUT: store i32 9, ptr %a.var, align 4, !dbg !9 +// CHECK:STDOUT: store i32 12, ptr %a.var, align 4, !dbg !7 +// CHECK:STDOUT: store i32 9, ptr %a.var, align 4, !dbg !8 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.loc15_5, i64 8, i1 false), !dbg !11 -// CHECK:STDOUT: ret void, !dbg !12 +// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %b.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %b.var, ptr align 4 @tuple.loc15_5, i64 8, i1 false), !dbg !10 +// CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -56,9 +56,8 @@ fn Main() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 7, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 11, column: 1, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 15, column: 7, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 11, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/pointer/address_of_field.carbon b/toolchain/lower/testdata/pointer/address_of_field.carbon index 9867c7bb6319..5f46a7964aa5 100644 --- a/toolchain/lower/testdata/pointer/address_of_field.carbon +++ b/toolchain/lower/testdata/pointer/address_of_field.carbon @@ -18,7 +18,7 @@ fn F() { // CHECK:STDOUT: ; ModuleID = 'address_of_field.carbon' // CHECK:STDOUT: source_filename = "address_of_field.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @struct.loc14_47 = internal constant { i32, i32 } { i32 1, i32 2 } +// CHECK:STDOUT: @struct.loc14_3.2 = internal constant { i32, i32 } { i32 1, i32 2 } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CG.Main(ptr) // CHECK:STDOUT: @@ -28,10 +28,10 @@ fn F() { // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %s.var), !dbg !7 // CHECK:STDOUT: %.loc14_46.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 0, !dbg !8 // CHECK:STDOUT: %.loc14_46.6.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s.var, ptr align 4 @struct.loc14_47, i64 8, i1 false), !dbg !9 -// CHECK:STDOUT: %.loc15.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: call void @_CG.Main(ptr %.loc15.b), !dbg !11 -// CHECK:STDOUT: ret void, !dbg !12 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s.var, ptr align 4 @struct.loc14_3.2, i64 8, i1 false), !dbg !7 +// CHECK:STDOUT: %.loc15.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: call void @_CG.Main(ptr %.loc15.b), !dbg !10 +// CHECK:STDOUT: ret void, !dbg !11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -53,9 +53,8 @@ fn F() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 31, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 6, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 15, column: 6, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/pointer/address_of_unused.carbon b/toolchain/lower/testdata/pointer/address_of_unused.carbon index 11ac24b16adc..108ae094c332 100644 --- a/toolchain/lower/testdata/pointer/address_of_unused.carbon +++ b/toolchain/lower/testdata/pointer/address_of_unused.carbon @@ -20,8 +20,8 @@ fn F() { // CHECK:STDOUT: entry: // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %n.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !8 -// CHECK:STDOUT: ret void, !dbg !9 +// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !7 +// CHECK:STDOUT: ret void, !dbg !8 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -39,6 +39,5 @@ fn F() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 11, column: 1, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 11, column: 1, scope: !4) diff --git a/toolchain/lower/testdata/pointer/basic.carbon b/toolchain/lower/testdata/pointer/basic.carbon index e4b4048ace4a..51efd950a2ca 100644 --- a/toolchain/lower/testdata/pointer/basic.carbon +++ b/toolchain/lower/testdata/pointer/basic.carbon @@ -30,9 +30,9 @@ fn F() -> i32 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !10 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %n.var), !dbg !10 -// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !11 -// CHECK:STDOUT: %G.call = call i32 @_CG.Main(ptr %n.var), !dbg !12 -// CHECK:STDOUT: ret i32 %G.call, !dbg !13 +// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !10 +// CHECK:STDOUT: %G.call = call i32 @_CG.Main(ptr %n.var), !dbg !11 +// CHECK:STDOUT: ret i32 %G.call, !dbg !12 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -53,7 +53,6 @@ fn F() -> i32 { // CHECK:STDOUT: !7 = !DILocation(line: 12, column: 10, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 15, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 7, scope: !9) -// CHECK:STDOUT: !11 = !DILocation(line: 16, column: 3, scope: !9) -// CHECK:STDOUT: !12 = !DILocation(line: 17, column: 10, scope: !9) -// CHECK:STDOUT: !13 = !DILocation(line: 17, column: 3, scope: !9) +// CHECK:STDOUT: !10 = !DILocation(line: 16, column: 3, scope: !9) +// CHECK:STDOUT: !11 = !DILocation(line: 17, column: 10, scope: !9) +// CHECK:STDOUT: !12 = !DILocation(line: 17, column: 3, scope: !9) diff --git a/toolchain/lower/testdata/pointer/pointer_to_pointer.carbon b/toolchain/lower/testdata/pointer/pointer_to_pointer.carbon index 436b6775b4ce..cdad50763f9c 100644 --- a/toolchain/lower/testdata/pointer/pointer_to_pointer.carbon +++ b/toolchain/lower/testdata/pointer/pointer_to_pointer.carbon @@ -24,16 +24,16 @@ fn F(p: i32**) -> i32 { // CHECK:STDOUT: %b.var = alloca ptr, align 8, !dbg !7 // CHECK:STDOUT: %c.var = alloca ptr, align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %a.var), !dbg !7 -// CHECK:STDOUT: store ptr %p, ptr %a.var, align 8, !dbg !8 +// CHECK:STDOUT: store ptr %p, ptr %a.var, align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %.loc13_17.2 = load ptr, ptr %p, align 8, !dbg !9 -// CHECK:STDOUT: store ptr %.loc13_17.2, ptr %b.var, align 8, !dbg !10 +// CHECK:STDOUT: %.loc13_17.2 = load ptr, ptr %p, align 8, !dbg !8 +// CHECK:STDOUT: store ptr %.loc13_17.2, ptr %b.var, align 8, !dbg !9 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %c.var), !dbg !7 -// CHECK:STDOUT: store ptr %b.var, ptr %c.var, align 8, !dbg !11 -// CHECK:STDOUT: %.loc15_12 = load ptr, ptr %c.var, align 8, !dbg !12 -// CHECK:STDOUT: %.loc15_11.2 = load ptr, ptr %.loc15_12, align 8, !dbg !13 -// CHECK:STDOUT: %.loc15_10.2 = load i32, ptr %.loc15_11.2, align 4, !dbg !14 -// CHECK:STDOUT: ret i32 %.loc15_10.2, !dbg !15 +// CHECK:STDOUT: store ptr %b.var, ptr %c.var, align 8, !dbg !10 +// CHECK:STDOUT: %.loc15_12 = load ptr, ptr %c.var, align 8, !dbg !11 +// CHECK:STDOUT: %.loc15_11.2 = load ptr, ptr %.loc15_12, align 8, !dbg !12 +// CHECK:STDOUT: %.loc15_10.2 = load i32, ptr %.loc15_11.2, align 4, !dbg !13 +// CHECK:STDOUT: ret i32 %.loc15_10.2, !dbg !14 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -54,12 +54,11 @@ fn F(p: i32**) -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 17, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 12, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 11, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 10, scope: !4) -// CHECK:STDOUT: !15 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 17, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 12, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 11, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 10, scope: !4) +// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/return/return_var_byval.carbon b/toolchain/lower/testdata/return/return_var_byval.carbon index f869897c2e9b..a3d4155e3273 100644 --- a/toolchain/lower/testdata/return/return_var_byval.carbon +++ b/toolchain/lower/testdata/return/return_var_byval.carbon @@ -20,8 +20,8 @@ fn Main() -> i32 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %x.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %x.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %x.var, align 4, !dbg !8 -// CHECK:STDOUT: %.loc12_16 = load i32, ptr %x.var, align 4, !dbg !7 +// CHECK:STDOUT: store i32 0, ptr %x.var, align 4, !dbg !7 +// CHECK:STDOUT: %.loc12_16 = load i32, ptr %x.var, align 4, !dbg !8 // CHECK:STDOUT: ret i32 %.loc12_16, !dbg !9 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -40,6 +40,6 @@ fn Main() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 16, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 12, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 16, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/return/var.carbon b/toolchain/lower/testdata/return/var.carbon index 5b420fa421c6..6e0f8edded0d 100644 --- a/toolchain/lower/testdata/return/var.carbon +++ b/toolchain/lower/testdata/return/var.carbon @@ -20,9 +20,9 @@ fn Main() -> i32 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %x.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %x.var), !dbg !7 -// CHECK:STDOUT: store i32 0, ptr %x.var, align 4, !dbg !8 -// CHECK:STDOUT: %.loc13 = load i32, ptr %x.var, align 4, !dbg !9 -// CHECK:STDOUT: ret i32 %.loc13, !dbg !10 +// CHECK:STDOUT: store i32 0, ptr %x.var, align 4, !dbg !7 +// CHECK:STDOUT: %.loc13 = load i32, ptr %x.var, align 4, !dbg !8 +// CHECK:STDOUT: ret i32 %.loc13, !dbg !9 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -40,7 +40,6 @@ fn Main() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Main", linkageName: "_CMain.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 10, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 10, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/struct/empty.carbon b/toolchain/lower/testdata/struct/empty.carbon index 0f158717de21..1d2f1b8be912 100644 --- a/toolchain/lower/testdata/struct/empty.carbon +++ b/toolchain/lower/testdata/struct/empty.carbon @@ -44,5 +44,5 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/struct/member_access.carbon b/toolchain/lower/testdata/struct/member_access.carbon index d5e6b9bdc7dd..b890c69d5e26 100644 --- a/toolchain/lower/testdata/struct/member_access.carbon +++ b/toolchain/lower/testdata/struct/member_access.carbon @@ -18,7 +18,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ; ModuleID = 'member_access.carbon' // CHECK:STDOUT: source_filename = "member_access.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @struct.loc12_49 = internal constant { double, i32 } { double 0.000000e+00, i32 1 } +// CHECK:STDOUT: @struct.loc12_3.2 = internal constant { double, i32 } { double 0.000000e+00, i32 1 } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @main() !dbg !4 { // CHECK:STDOUT: entry: @@ -28,15 +28,15 @@ fn Run() -> i32 { // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 16, ptr %x.var), !dbg !7 // CHECK:STDOUT: %.loc12_48.2.a = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 0, !dbg !8 // CHECK:STDOUT: %.loc12_48.5.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x.var, ptr align 8 @struct.loc12_49, i64 16, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %x.var, ptr align 8 @struct.loc12_3.2, i64 16, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %y.var), !dbg !7 -// CHECK:STDOUT: %.loc13_17.1.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: %.loc13_17.2 = load i32, ptr %.loc13_17.1.b, align 4, !dbg !10 -// CHECK:STDOUT: store i32 %.loc13_17.2, ptr %y.var, align 4, !dbg !11 +// CHECK:STDOUT: %.loc13_17.1.b = getelementptr inbounds nuw { double, i32 }, ptr %x.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: %.loc13_17.2 = load i32, ptr %.loc13_17.1.b, align 4, !dbg !9 +// CHECK:STDOUT: store i32 %.loc13_17.2, ptr %y.var, align 4, !dbg !10 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %z.var), !dbg !7 -// CHECK:STDOUT: %.loc14 = load i32, ptr %y.var, align 4, !dbg !12 -// CHECK:STDOUT: store i32 %.loc14, ptr %z.var, align 4, !dbg !13 -// CHECK:STDOUT: ret i32 0, !dbg !14 +// CHECK:STDOUT: %.loc14_16 = load i32, ptr %y.var, align 4, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_16, ptr %z.var, align 4, !dbg !12 +// CHECK:STDOUT: ret i32 0, !dbg !13 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -62,11 +62,10 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 31, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 16, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 16, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 16, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 16, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/struct/nested_struct_in_place.carbon b/toolchain/lower/testdata/struct/nested_struct_in_place.carbon index 3221d60ec410..dbc841de84e2 100644 --- a/toolchain/lower/testdata/struct/nested_struct_in_place.carbon +++ b/toolchain/lower/testdata/struct/nested_struct_in_place.carbon @@ -45,7 +45,7 @@ fn G() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 55, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 14, column: 61, scope: !4) // CHECK:STDOUT: !10 = !DILocation(line: 14, column: 71, scope: !4) diff --git a/toolchain/lower/testdata/struct/one_entry.carbon b/toolchain/lower/testdata/struct/one_entry.carbon index f9c6251eedfa..3e243a740ed6 100644 --- a/toolchain/lower/testdata/struct/one_entry.carbon +++ b/toolchain/lower/testdata/struct/one_entry.carbon @@ -22,13 +22,13 @@ fn Run() -> i32 { // CHECK:STDOUT: %x.var = alloca { i32 }, align 8, !dbg !7 // CHECK:STDOUT: %y.var = alloca { i32 }, align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %x.var), !dbg !7 -// CHECK:STDOUT: store { i32 } { i32 4 }, ptr %x.var, align 4, !dbg !8 +// CHECK:STDOUT: store { i32 } { i32 4 }, ptr %x.var, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %y.var), !dbg !7 -// CHECK:STDOUT: %.loc13_22.1.a = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !9 -// CHECK:STDOUT: %.loc13_22.2 = load i32, ptr %.loc13_22.1.a, align 4, !dbg !9 -// CHECK:STDOUT: %.loc13_22.3.struct.init = insertvalue { i32 } poison, i32 %.loc13_22.2, 0, !dbg !9 -// CHECK:STDOUT: store { i32 } %.loc13_22.3.struct.init, ptr %y.var, align 4, !dbg !10 -// CHECK:STDOUT: ret i32 0, !dbg !11 +// CHECK:STDOUT: %.loc13_22.1.a = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !8 +// CHECK:STDOUT: %.loc13_22.2 = load i32, ptr %.loc13_22.1.a, align 4, !dbg !8 +// CHECK:STDOUT: %.loc13_22.3.struct.init = insertvalue { i32 } poison, i32 %.loc13_22.2, 0, !dbg !8 +// CHECK:STDOUT: store { i32 } %.loc13_22.3.struct.init, ptr %y.var, align 4, !dbg !9 +// CHECK:STDOUT: ret i32 0, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -49,8 +49,7 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 22, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 22, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/struct/two_entries.carbon b/toolchain/lower/testdata/struct/two_entries.carbon index 7de730c09152..165f8d6b1334 100644 --- a/toolchain/lower/testdata/struct/two_entries.carbon +++ b/toolchain/lower/testdata/struct/two_entries.carbon @@ -17,7 +17,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ; ModuleID = 'two_entries.carbon' // CHECK:STDOUT: source_filename = "two_entries.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @struct.loc12_47 = internal constant { i32, i32 } { i32 1, i32 2 } +// CHECK:STDOUT: @struct.loc12_3.2 = internal constant { i32, i32 } { i32 1, i32 2 } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @main() !dbg !4 { // CHECK:STDOUT: entry: @@ -26,17 +26,17 @@ fn Run() -> i32 { // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %x.var), !dbg !7 // CHECK:STDOUT: %.loc12_46.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !8 // CHECK:STDOUT: %.loc12_46.6.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.loc12_47, i64 8, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.loc12_3.2, i64 8, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %y.var), !dbg !7 -// CHECK:STDOUT: %.loc13_31.1.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: %.loc13_31.2 = load i32, ptr %.loc13_31.1.a, align 4, !dbg !10 -// CHECK:STDOUT: %.loc13_31.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: store i32 %.loc13_31.2, ptr %.loc13_31.3.a, align 4, !dbg !10 -// CHECK:STDOUT: %.loc13_31.5.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: %.loc13_31.6 = load i32, ptr %.loc13_31.5.b, align 4, !dbg !10 -// CHECK:STDOUT: %.loc13_31.7.b = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: store i32 %.loc13_31.6, ptr %.loc13_31.7.b, align 4, !dbg !10 -// CHECK:STDOUT: ret i32 0, !dbg !11 +// CHECK:STDOUT: %.loc13_31.1.a = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: %.loc13_31.2 = load i32, ptr %.loc13_31.1.a, align 4, !dbg !9 +// CHECK:STDOUT: %.loc13_31.3.a = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: store i32 %.loc13_31.2, ptr %.loc13_31.3.a, align 4, !dbg !9 +// CHECK:STDOUT: %.loc13_31.5.b = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: %.loc13_31.6 = load i32, ptr %.loc13_31.5.b, align 4, !dbg !9 +// CHECK:STDOUT: %.loc13_31.7.b = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: store i32 %.loc13_31.6, ptr %.loc13_31.7.b, align 4, !dbg !9 +// CHECK:STDOUT: ret i32 0, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -62,8 +62,7 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 31, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 31, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 31, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/tuple/access/element_access.carbon b/toolchain/lower/testdata/tuple/access/element_access.carbon index 0abbe868e86b..1e8aafa0d462 100644 --- a/toolchain/lower/testdata/tuple/access/element_access.carbon +++ b/toolchain/lower/testdata/tuple/access/element_access.carbon @@ -18,7 +18,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ; ModuleID = 'element_access.carbon' // CHECK:STDOUT: source_filename = "element_access.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @tuple.loc12_37 = internal constant { i32, i32, i32 } { i32 0, i32 1, i32 2 } +// CHECK:STDOUT: @tuple.loc12_3.2 = internal constant { i32, i32, i32 } { i32 0, i32 1, i32 2 } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @main() !dbg !4 { // CHECK:STDOUT: entry: @@ -29,16 +29,16 @@ fn Run() -> i32 { // CHECK:STDOUT: %tuple.elem0.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !8 // CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 1, !dbg !8 // CHECK:STDOUT: %tuple.elem2.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.loc12_37, i64 12, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a.var, ptr align 4 @tuple.loc12_3.2, i64 12, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.loc13.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: %.loc13 = load i32, ptr %tuple.elem0.loc13.tuple.elem, align 4, !dbg !10 -// CHECK:STDOUT: store i32 %.loc13, ptr %b.var, align 4, !dbg !11 +// CHECK:STDOUT: %tuple.elem0.loc13.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: %.loc13_17 = load i32, ptr %tuple.elem0.loc13.tuple.elem, align 4, !dbg !9 +// CHECK:STDOUT: store i32 %.loc13_17, ptr %b.var, align 4, !dbg !10 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %c.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem2.loc14.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !12 -// CHECK:STDOUT: %.loc14 = load i32, ptr %tuple.elem2.loc14.tuple.elem, align 4, !dbg !12 -// CHECK:STDOUT: store i32 %.loc14, ptr %c.var, align 4, !dbg !13 -// CHECK:STDOUT: ret i32 0, !dbg !14 +// CHECK:STDOUT: %tuple.elem2.loc14.tuple.elem = getelementptr inbounds nuw { i32, i32, i32 }, ptr %a.var, i32 0, i32 2, !dbg !11 +// CHECK:STDOUT: %.loc14_17 = load i32, ptr %tuple.elem2.loc14.tuple.elem, align 4, !dbg !11 +// CHECK:STDOUT: store i32 %.loc14_17, ptr %c.var, align 4, !dbg !12 +// CHECK:STDOUT: ret i32 0, !dbg !13 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -64,11 +64,10 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 28, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 16, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 16, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 14, column: 3, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 15, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 16, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 16, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/tuple/access/return_value_access.carbon b/toolchain/lower/testdata/tuple/access/return_value_access.carbon index c2b1f7851204..12697e84de40 100644 --- a/toolchain/lower/testdata/tuple/access/return_value_access.carbon +++ b/toolchain/lower/testdata/tuple/access/return_value_access.carbon @@ -35,8 +35,8 @@ fn Run() { // CHECK:STDOUT: call void @_CF.Main(ptr %.loc14_18.1.temp), !dbg !11 // CHECK:STDOUT: %tuple.elem1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %.loc14_18.1.temp, i32 0, i32 1, !dbg !11 // CHECK:STDOUT: %.loc14_19 = load i32, ptr %tuple.elem1.tuple.elem, align 4, !dbg !11 -// CHECK:STDOUT: store i32 %.loc14_19, ptr %t.var, align 4, !dbg !12 -// CHECK:STDOUT: ret void, !dbg !13 +// CHECK:STDOUT: store i32 %.loc14_19, ptr %t.var, align 4, !dbg !10 +// CHECK:STDOUT: ret void, !dbg !12 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite) @@ -61,7 +61,6 @@ fn Run() { // CHECK:STDOUT: !7 = !DILocation(line: 11, column: 31, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 11, column: 24, scope: !4) // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) -// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 7, scope: !9) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !9) // CHECK:STDOUT: !11 = !DILocation(line: 14, column: 16, scope: !9) -// CHECK:STDOUT: !12 = !DILocation(line: 14, column: 3, scope: !9) -// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 1, scope: !9) +// CHECK:STDOUT: !12 = !DILocation(line: 13, column: 1, scope: !9) diff --git a/toolchain/lower/testdata/tuple/empty.carbon b/toolchain/lower/testdata/tuple/empty.carbon index c534e2319106..e70784c75daa 100644 --- a/toolchain/lower/testdata/tuple/empty.carbon +++ b/toolchain/lower/testdata/tuple/empty.carbon @@ -44,5 +44,5 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/tuple/nested_tuple_in_place.carbon b/toolchain/lower/testdata/tuple/nested_tuple_in_place.carbon index 421aeafca671..06d3482cf22b 100644 --- a/toolchain/lower/testdata/tuple/nested_tuple_in_place.carbon +++ b/toolchain/lower/testdata/tuple/nested_tuple_in_place.carbon @@ -45,7 +45,7 @@ fn G() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 47, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 14, column: 48, scope: !4) // CHECK:STDOUT: !10 = !DILocation(line: 14, column: 53, scope: !4) diff --git a/toolchain/lower/testdata/tuple/one_entry.carbon b/toolchain/lower/testdata/tuple/one_entry.carbon index 1bf5b1b525cc..d4981b980b73 100644 --- a/toolchain/lower/testdata/tuple/one_entry.carbon +++ b/toolchain/lower/testdata/tuple/one_entry.carbon @@ -22,13 +22,13 @@ fn Run() -> i32 { // CHECK:STDOUT: %x.var = alloca { i32 }, align 8, !dbg !7 // CHECK:STDOUT: %y.var = alloca { i32 }, align 8, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %x.var), !dbg !7 -// CHECK:STDOUT: store { i32 } { i32 1 }, ptr %x.var, align 4, !dbg !8 +// CHECK:STDOUT: store { i32 } { i32 1 }, ptr %x.var, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %y.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !9 -// CHECK:STDOUT: %.loc13_20.1 = load i32, ptr %tuple.elem0.tuple.elem, align 4, !dbg !9 -// CHECK:STDOUT: %.loc13_20.2.tuple.init = insertvalue { i32 } poison, i32 %.loc13_20.1, 0, !dbg !9 -// CHECK:STDOUT: store { i32 } %.loc13_20.2.tuple.init, ptr %y.var, align 4, !dbg !10 -// CHECK:STDOUT: ret i32 0, !dbg !11 +// CHECK:STDOUT: %tuple.elem0.tuple.elem = getelementptr inbounds nuw { i32 }, ptr %x.var, i32 0, i32 0, !dbg !8 +// CHECK:STDOUT: %.loc13_20.1 = load i32, ptr %tuple.elem0.tuple.elem, align 4, !dbg !8 +// CHECK:STDOUT: %.loc13_20.2.tuple.init = insertvalue { i32 } poison, i32 %.loc13_20.1, 0, !dbg !8 +// CHECK:STDOUT: store { i32 } %.loc13_20.2.tuple.init, ptr %y.var, align 4, !dbg !9 +// CHECK:STDOUT: ret i32 0, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -50,8 +50,7 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 20, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 20, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/tuple/two_entries.carbon b/toolchain/lower/testdata/tuple/two_entries.carbon index d600d4855d3e..add43921fd1d 100644 --- a/toolchain/lower/testdata/tuple/two_entries.carbon +++ b/toolchain/lower/testdata/tuple/two_entries.carbon @@ -17,7 +17,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ; ModuleID = 'two_entries.carbon' // CHECK:STDOUT: source_filename = "two_entries.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: @tuple.loc12_30 = internal constant { i32, i32 } { i32 12, i32 7 } +// CHECK:STDOUT: @tuple.loc12_3.2 = internal constant { i32, i32 } { i32 12, i32 7 } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @main() !dbg !4 { // CHECK:STDOUT: entry: @@ -26,17 +26,17 @@ fn Run() -> i32 { // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %x.var), !dbg !7 // CHECK:STDOUT: %tuple.elem0.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !8 // CHECK:STDOUT: %tuple.elem1.loc12.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !8 -// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @tuple.loc12_30, i64 8, i1 false), !dbg !9 +// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @tuple.loc12_3.2, i64 8, i1 false), !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 8, ptr %y.var), !dbg !7 -// CHECK:STDOUT: %tuple.elem0.loc13_23.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: %.loc13_23.1 = load i32, ptr %tuple.elem0.loc13_23.1.tuple.elem, align 4, !dbg !10 -// CHECK:STDOUT: %tuple.elem0.loc13_23.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0, !dbg !10 -// CHECK:STDOUT: store i32 %.loc13_23.1, ptr %tuple.elem0.loc13_23.2.tuple.elem, align 4, !dbg !10 -// CHECK:STDOUT: %tuple.elem1.loc13_23.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: %.loc13_23.3 = load i32, ptr %tuple.elem1.loc13_23.1.tuple.elem, align 4, !dbg !10 -// CHECK:STDOUT: %tuple.elem1.loc13_23.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1, !dbg !10 -// CHECK:STDOUT: store i32 %.loc13_23.3, ptr %tuple.elem1.loc13_23.2.tuple.elem, align 4, !dbg !10 -// CHECK:STDOUT: ret i32 0, !dbg !11 +// CHECK:STDOUT: %tuple.elem0.loc13_23.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: %.loc13_23.1 = load i32, ptr %tuple.elem0.loc13_23.1.tuple.elem, align 4, !dbg !9 +// CHECK:STDOUT: %tuple.elem0.loc13_23.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 0, !dbg !9 +// CHECK:STDOUT: store i32 %.loc13_23.1, ptr %tuple.elem0.loc13_23.2.tuple.elem, align 4, !dbg !9 +// CHECK:STDOUT: %tuple.elem1.loc13_23.1.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %x.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: %.loc13_23.3 = load i32, ptr %tuple.elem1.loc13_23.1.tuple.elem, align 4, !dbg !9 +// CHECK:STDOUT: %tuple.elem1.loc13_23.2.tuple.elem = getelementptr inbounds nuw { i32, i32 }, ptr %y.var, i32 0, i32 1, !dbg !9 +// CHECK:STDOUT: store i32 %.loc13_23.3, ptr %tuple.elem1.loc13_23.2.tuple.elem, align 4, !dbg !9 +// CHECK:STDOUT: ret i32 0, !dbg !10 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -62,8 +62,7 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 12, column: 23, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 23, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 3, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 23, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/tuple/value_formation.carbon b/toolchain/lower/testdata/tuple/value_formation.carbon index 1779b7573712..62377300aeeb 100644 --- a/toolchain/lower/testdata/tuple/value_formation.carbon +++ b/toolchain/lower/testdata/tuple/value_formation.carbon @@ -80,7 +80,7 @@ fn F() { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 7, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4) // CHECK:STDOUT: !8 = !DILocation(line: 16, column: 6, scope: !4) // CHECK:STDOUT: !9 = !DILocation(line: 16, column: 9, scope: !4) // CHECK:STDOUT: !10 = !DILocation(line: 16, column: 5, scope: !4) diff --git a/toolchain/lower/testdata/var/local.carbon b/toolchain/lower/testdata/var/local.carbon index a8396960bdff..27352b26744e 100644 --- a/toolchain/lower/testdata/var/local.carbon +++ b/toolchain/lower/testdata/var/local.carbon @@ -20,9 +20,9 @@ fn Run() -> i32 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %x.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %x.var), !dbg !7 -// CHECK:STDOUT: store i32 1, ptr %x.var, align 4, !dbg !8 -// CHECK:STDOUT: %.loc13 = load i32, ptr %x.var, align 4, !dbg !9 -// CHECK:STDOUT: ret i32 %.loc13, !dbg !10 +// CHECK:STDOUT: store i32 1, ptr %x.var, align 4, !dbg !7 +// CHECK:STDOUT: %.loc13 = load i32, ptr %x.var, align 4, !dbg !8 +// CHECK:STDOUT: ret i32 %.loc13, !dbg !9 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -40,7 +40,6 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 10, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 10, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 3, scope: !4) diff --git a/toolchain/lower/testdata/var/nested.carbon b/toolchain/lower/testdata/var/nested.carbon index 38d5778089d4..2b652fd4f91f 100644 --- a/toolchain/lower/testdata/var/nested.carbon +++ b/toolchain/lower/testdata/var/nested.carbon @@ -25,23 +25,23 @@ fn Run() -> i32 { // CHECK:STDOUT: %a.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: %b.var = alloca i32, align 4, !dbg !7 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %a.var), !dbg !7 -// CHECK:STDOUT: store i32 1, ptr %a.var, align 4, !dbg !8 -// CHECK:STDOUT: br label %while.cond, !dbg !9 +// CHECK:STDOUT: store i32 1, ptr %a.var, align 4, !dbg !7 +// CHECK:STDOUT: br label %while.cond, !dbg !8 // CHECK:STDOUT: // CHECK:STDOUT: while.cond: ; preds = %while.body, %entry -// CHECK:STDOUT: br i1 true, label %while.body, label %while.done, !dbg !9 +// CHECK:STDOUT: br i1 true, label %while.body, label %while.done, !dbg !8 // CHECK:STDOUT: // CHECK:STDOUT: while.body: ; preds = %while.cond // CHECK:STDOUT: call void @llvm.lifetime.start.p0(i64 4, ptr %b.var), !dbg !7 -// CHECK:STDOUT: %.loc14 = load i32, ptr %a.var, align 4, !dbg !10 -// CHECK:STDOUT: store i32 %.loc14, ptr %b.var, align 4, !dbg !11 -// CHECK:STDOUT: %.loc15 = load i32, ptr %b.var, align 4, !dbg !12 -// CHECK:STDOUT: store i32 %.loc15, ptr %a.var, align 4, !dbg !13 -// CHECK:STDOUT: br label %while.cond, !dbg !14 +// CHECK:STDOUT: %.loc14_18 = load i32, ptr %a.var, align 4, !dbg !9 +// CHECK:STDOUT: store i32 %.loc14_18, ptr %b.var, align 4, !dbg !10 +// CHECK:STDOUT: %.loc15 = load i32, ptr %b.var, align 4, !dbg !11 +// CHECK:STDOUT: store i32 %.loc15, ptr %a.var, align 4, !dbg !12 +// CHECK:STDOUT: br label %while.cond, !dbg !13 // CHECK:STDOUT: // CHECK:STDOUT: while.done: ; preds = %while.cond -// CHECK:STDOUT: %.loc17 = load i32, ptr %a.var, align 4, !dbg !15 -// CHECK:STDOUT: ret i32 %.loc17, !dbg !16 +// CHECK:STDOUT: %.loc17 = load i32, ptr %a.var, align 4, !dbg !14 +// CHECK:STDOUT: ret i32 %.loc17, !dbg !15 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) @@ -63,13 +63,12 @@ fn Run() -> i32 { // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2) // CHECK:STDOUT: !5 = !DISubroutineType(types: !6) // CHECK:STDOUT: !6 = !{} -// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 7, scope: !4) -// CHECK:STDOUT: !8 = !DILocation(line: 12, column: 3, scope: !4) -// CHECK:STDOUT: !9 = !DILocation(line: 13, column: 9, scope: !4) -// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 18, scope: !4) -// CHECK:STDOUT: !11 = !DILocation(line: 14, column: 5, scope: !4) -// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 9, scope: !4) -// CHECK:STDOUT: !13 = !DILocation(line: 15, column: 5, scope: !4) -// CHECK:STDOUT: !14 = !DILocation(line: 13, column: 3, scope: !4) -// CHECK:STDOUT: !15 = !DILocation(line: 17, column: 10, scope: !4) -// CHECK:STDOUT: !16 = !DILocation(line: 17, column: 3, scope: !4) +// CHECK:STDOUT: !7 = !DILocation(line: 12, column: 3, scope: !4) +// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 9, scope: !4) +// CHECK:STDOUT: !9 = !DILocation(line: 14, column: 18, scope: !4) +// CHECK:STDOUT: !10 = !DILocation(line: 14, column: 5, scope: !4) +// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 9, scope: !4) +// CHECK:STDOUT: !12 = !DILocation(line: 15, column: 5, scope: !4) +// CHECK:STDOUT: !13 = !DILocation(line: 13, column: 3, scope: !4) +// CHECK:STDOUT: !14 = !DILocation(line: 17, column: 10, scope: !4) +// CHECK:STDOUT: !15 = !DILocation(line: 17, column: 3, scope: !4) diff --git a/toolchain/parse/handle_var.cpp b/toolchain/parse/handle_var.cpp index fd2a5be9806e..93a44a0751a0 100644 --- a/toolchain/parse/handle_var.cpp +++ b/toolchain/parse/handle_var.cpp @@ -16,6 +16,9 @@ static auto HandleVar(Context& context, State finish_state, // The finished variable declaration will start at the `var` or `returned`. context.PushState(state, finish_state); + // TODO: is there a cleaner way to give VarAfterPattern access to the `var` + // token? + state.token = *(context.position() - 1); context.PushState(state, State::VarAfterPattern); if (returned_token.is_valid()) { @@ -66,6 +69,8 @@ auto HandleVarAfterPattern(Context& context) -> void { } } + context.AddNode(NodeKind::VariablePattern, state.token, state.has_error); + if (context.PositionIs(Lex::TokenKind::Equal)) { context.AddLeafNode(NodeKind::VariableInitializer, context.ConsumeChecked(Lex::TokenKind::Equal)); @@ -91,6 +96,8 @@ auto HandleVarFinishAsDecl(Context& context) -> void { auto HandleVarFinishAsFor(Context& context) -> void { auto state = context.PopState(); + context.AddNode(NodeKind::VariablePattern, state.token, state.has_error); + auto end_token = state.token; if (context.PositionIs(Lex::TokenKind::In)) { end_token = context.Consume(); diff --git a/toolchain/parse/node_kind.def b/toolchain/parse/node_kind.def index cd0886f31f12..c74822611927 100644 --- a/toolchain/parse/node_kind.def +++ b/toolchain/parse/node_kind.def @@ -169,6 +169,7 @@ CARBON_PARSE_NODE_KIND(VariableIntroducer) CARBON_PARSE_NODE_KIND(ReturnedModifier) CARBON_PARSE_NODE_KIND(VariableInitializer) CARBON_PARSE_NODE_KIND(VariableDecl) +CARBON_PARSE_NODE_KIND(VariablePattern) CARBON_PARSE_NODE_KIND(ExprStatement) diff --git a/toolchain/parse/testdata/array/fail_require_close_bracket.carbon b/toolchain/parse/testdata/array/fail_require_close_bracket.carbon index 3399060b7573..0fb3c7446fd3 100644 --- a/toolchain/parse/testdata/array/fail_require_close_bracket.carbon +++ b/toolchain/parse/testdata/array/fail_require_close_bracket.carbon @@ -19,10 +19,11 @@ var x: [i32;; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'EmptyDecl', text: ';'}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/fail_require_semi.carbon b/toolchain/parse/testdata/array/fail_require_semi.carbon index 442a724cf3e1..b0b88435a711 100644 --- a/toolchain/parse/testdata/array/fail_require_semi.carbon +++ b/toolchain/parse/testdata/array/fail_require_semi.carbon @@ -18,12 +18,13 @@ var x: [i32]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/fail_syntax.carbon b/toolchain/parse/testdata/array/fail_syntax.carbon index 66d97e6bcfab..d0eb256ef92e 100644 --- a/toolchain/parse/testdata/array/fail_syntax.carbon +++ b/toolchain/parse/testdata/array/fail_syntax.carbon @@ -72,13 +72,14 @@ var x: [i32]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] // CHECK:STDOUT: - filename: fail_invalid_char.carbon @@ -101,24 +102,26 @@ var x: [i32]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '`', has_error: yes}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: '`', has_error: yes, subtree_size: 3}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '`', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: '`', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '`', has_error: yes}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] // CHECK:STDOUT: - filename: fail_no_close_bracket.carbon // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '[', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'EmptyDecl', text: ';'}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] @@ -126,12 +129,13 @@ var x: [i32]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/with_length.carbon b/toolchain/parse/testdata/array/with_length.carbon index cca2c1287273..cdd57af8a8ea 100644 --- a/toolchain/parse/testdata/array/with_length.carbon +++ b/toolchain/parse/testdata/array/with_length.carbon @@ -14,13 +14,14 @@ var x: [i32; 10]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '10'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '10'}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/array/without_length.carbon b/toolchain/parse/testdata/array/without_length.carbon index 83e9088ac0a6..743d67bf76ec 100644 --- a/toolchain/parse/testdata/array/without_length.carbon +++ b/toolchain/parse/testdata/array/without_length.carbon @@ -14,12 +14,13 @@ var x: [i32;]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/auto/var.carbon b/toolchain/parse/testdata/auto/var.carbon index 1f7259a02f94..a524cff7e717 100644 --- a/toolchain/parse/testdata/auto/var.carbon +++ b/toolchain/parse/testdata/auto/var.carbon @@ -14,11 +14,12 @@ var y: auto = false; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'AutoTypeLiteral', text: 'auto'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'AutoTypeLiteral', text: 'auto'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralFalse', text: 'false'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/builtin_types.carbon b/toolchain/parse/testdata/basics/builtin_types.carbon index a76f41f947ba..3950d44779b9 100644 --- a/toolchain/parse/testdata/basics/builtin_types.carbon +++ b/toolchain/parse/testdata/basics/builtin_types.carbon @@ -16,25 +16,28 @@ var test_str: String = "Test"; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'test_i32'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'test_i32'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'test_f64'}, -// CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'test_f64'}, +// CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'RealLiteral', text: '0.1'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'test_str'}, -// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'test_str'}, +// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StringLiteral', text: '"Test"'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon b/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon index d661c2fd1af1..a48ca89e33d5 100644 --- a/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon +++ b/toolchain/parse/testdata/basics/fail_bracket_recovery.carbon @@ -39,15 +39,16 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, @@ -56,17 +57,18 @@ fn F() { // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '2'}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 20}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, -// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, +// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, @@ -77,7 +79,7 @@ fn F() { // CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 4}, // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 7}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 9}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 21}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 46}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 48}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon b/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon index b80023bf6337..1f1ee511dfda 100644 --- a/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon +++ b/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon @@ -18,7 +18,7 @@ // CHECK:STDERR: var = (foo {}) -// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+17]]:21: error: `var` declarations must end with a `;` [ExpectedDeclSemi] +// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+18]]:21: error: `var` declarations must end with a `;` [ExpectedDeclSemi] // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDERR: @@ -26,13 +26,14 @@ var = (foo {}) // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '=', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: '=', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '=', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: '=', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParenExpr', text: ')', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ')', has_error: yes, subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ')', has_error: yes, subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/numeric_literals.carbon b/toolchain/parse/testdata/basics/numeric_literals.carbon index 5c214168b136..fb0b23d73c00 100644 --- a/toolchain/parse/testdata/basics/numeric_literals.carbon +++ b/toolchain/parse/testdata/basics/numeric_literals.carbon @@ -38,13 +38,14 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'ints'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '5'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'ints'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '5'}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '8'}, @@ -58,15 +59,16 @@ fn F() { // CHECK:STDOUT: {kind: 'IntLiteral', text: '39999999999999999993'}, // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 12}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 23}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'floats'}, -// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, -// CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, -// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '7'}, -// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'floats'}, +// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['}, +// CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, +// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '7'}, +// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'RealLiteral', text: '0.9'}, @@ -84,7 +86,7 @@ fn F() { // CHECK:STDOUT: {kind: 'RealLiteral', text: '39999999999999999993.0e39999999999999999993'}, // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 26}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 54}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 27}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 56}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/class/var.carbon b/toolchain/parse/testdata/class/var.carbon index a2bc404248f4..7ef0c8e73453 100644 --- a/toolchain/parse/testdata/class/var.carbon +++ b/toolchain/parse/testdata/class/var.carbon @@ -19,10 +19,11 @@ class Foo { // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ClassDefinitionStart', text: '{', subtree_size: 3}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'ClassDefinition', text: '}', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'ClassDefinition', text: '}', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon b/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon index 5ddd3f31649b..203417157f0b 100644 --- a/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon +++ b/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon @@ -28,12 +28,13 @@ fn foo() { // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'ForHeaderStart', text: '('}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ForIn', text: ':', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ForIn', text: ':', has_error: yes, subtree_size: 6}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'y'}, -// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 9}, // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Print'}, // CHECK:STDOUT: {kind: 'CallExprStart', text: '(', subtree_size: 2}, @@ -41,7 +42,7 @@ fn foo() { // CHECK:STDOUT: {kind: 'CallExpr', text: ')', subtree_size: 4}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 5}, // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 23}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/for/fail_missing_in.carbon b/toolchain/parse/testdata/for/fail_missing_in.carbon index f7fe27a11625..877052cacb21 100644 --- a/toolchain/parse/testdata/for/fail_missing_in.carbon +++ b/toolchain/parse/testdata/for/fail_missing_in.carbon @@ -28,12 +28,13 @@ fn foo() { // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'ForHeaderStart', text: '('}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ForIn', text: 'var', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ForIn', text: 'var', has_error: yes, subtree_size: 6}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'y'}, -// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 9}, // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Print'}, // CHECK:STDOUT: {kind: 'CallExprStart', text: '(', subtree_size: 2}, @@ -41,7 +42,7 @@ fn foo() { // CHECK:STDOUT: {kind: 'CallExpr', text: ')', subtree_size: 4}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 5}, // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 23}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/for/nested.carbon b/toolchain/parse/testdata/for/nested.carbon index deb6d30bd4a9..04d0322861d8 100644 --- a/toolchain/parse/testdata/for/nested.carbon +++ b/toolchain/parse/testdata/for/nested.carbon @@ -26,21 +26,23 @@ fn foo() { // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'ForHeaderStart', text: '('}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ForIn', text: 'in', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ForIn', text: 'in', subtree_size: 6}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'x'}, -// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 9}, // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, // CHECK:STDOUT: {kind: 'ForHeaderStart', text: '('}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'z'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ForIn', text: 'in', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'z'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ForIn', text: 'in', subtree_size: 6}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'y'}, -// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 9}, // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Print'}, // CHECK:STDOUT: {kind: 'CallExprStart', text: '(', subtree_size: 2}, @@ -48,9 +50,9 @@ fn foo() { // CHECK:STDOUT: {kind: 'CallExpr', text: ')', subtree_size: 4}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 5}, // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 18}, -// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 27}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 33}, +// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 19}, +// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 29}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 35}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/for/simple.carbon b/toolchain/parse/testdata/for/simple.carbon index b9e827c864a7..02892f59c591 100644 --- a/toolchain/parse/testdata/for/simple.carbon +++ b/toolchain/parse/testdata/for/simple.carbon @@ -24,12 +24,13 @@ fn foo() { // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'ForHeaderStart', text: '('}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'ForIn', text: 'in', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'ForIn', text: 'in', subtree_size: 6}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'y'}, -// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'ForHeader', text: ')', subtree_size: 9}, // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'Print'}, // CHECK:STDOUT: {kind: 'CallExprStart', text: '(', subtree_size: 2}, @@ -37,7 +38,7 @@ fn foo() { // CHECK:STDOUT: {kind: 'CallExpr', text: ')', subtree_size: 4}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 5}, // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'ForStatement', text: 'for', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 23}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/function/definition/decl_statement.carbon b/toolchain/parse/testdata/function/definition/decl_statement.carbon index 8d89ebf21f7a..8e503410a93e 100644 --- a/toolchain/parse/testdata/function/definition/decl_statement.carbon +++ b/toolchain/parse/testdata/function/definition/decl_statement.carbon @@ -108,11 +108,12 @@ fn F() { // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'LetDecl', text: ';', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 68}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 69}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] // CHECK:STDOUT: - filename: syntactically_valid.carbon @@ -163,16 +164,18 @@ fn F() { // CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'PrivateModifier', text: 'private'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'ProtectedModifier', text: 'protected'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 56}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 58}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if_expr/fail_condition_missing.carbon b/toolchain/parse/testdata/if_expr/fail_condition_missing.carbon index 2c3d59d64bde..34fa22e1c6de 100644 --- a/toolchain/parse/testdata/if_expr/fail_condition_missing.carbon +++ b/toolchain/parse/testdata/if_expr/fail_condition_missing.carbon @@ -25,16 +25,17 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'IfExprIf', text: 'if', has_error: yes, subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'IfExprElse', text: 'if', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if_expr/fail_else_expr_missing.carbon b/toolchain/parse/testdata/if_expr/fail_else_expr_missing.carbon index 5e03779e7323..b11d81a48bae 100644 --- a/toolchain/parse/testdata/if_expr/fail_else_expr_missing.carbon +++ b/toolchain/parse/testdata/if_expr/fail_else_expr_missing.carbon @@ -25,9 +25,10 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'}, // CHECK:STDOUT: {kind: 'IfExprIf', text: 'if', subtree_size: 2}, @@ -35,7 +36,7 @@ fn F() { // CHECK:STDOUT: {kind: 'IfExprThen', text: 'then', subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'IfExprElse', text: 'else', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 19}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if_expr/fail_else_missing.carbon b/toolchain/parse/testdata/if_expr/fail_else_missing.carbon index cee072dd30b1..454f5e067171 100644 --- a/toolchain/parse/testdata/if_expr/fail_else_missing.carbon +++ b/toolchain/parse/testdata/if_expr/fail_else_missing.carbon @@ -25,9 +25,10 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'}, // CHECK:STDOUT: {kind: 'IfExprIf', text: 'if', subtree_size: 2}, @@ -35,7 +36,7 @@ fn F() { // CHECK:STDOUT: {kind: 'IfExprThen', text: 'then', subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'IfExprElse', text: 'if', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 19}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if_expr/fail_then_expr_missing.carbon b/toolchain/parse/testdata/if_expr/fail_then_expr_missing.carbon index 6c077f77e2ec..522670debd71 100644 --- a/toolchain/parse/testdata/if_expr/fail_then_expr_missing.carbon +++ b/toolchain/parse/testdata/if_expr/fail_then_expr_missing.carbon @@ -25,9 +25,10 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'}, // CHECK:STDOUT: {kind: 'IfExprIf', text: 'if', subtree_size: 2}, @@ -35,7 +36,7 @@ fn F() { // CHECK:STDOUT: {kind: 'IfExprThen', text: 'then', has_error: yes, subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'IfExprElse', text: 'if', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 19}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if_expr/fail_then_missing.carbon b/toolchain/parse/testdata/if_expr/fail_then_missing.carbon index 355e41db3de4..317bab867ba5 100644 --- a/toolchain/parse/testdata/if_expr/fail_then_missing.carbon +++ b/toolchain/parse/testdata/if_expr/fail_then_missing.carbon @@ -25,16 +25,17 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'}, // CHECK:STDOUT: {kind: 'IfExprIf', text: 'if', subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'IfExprElse', text: 'if', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/if_expr/in_type.carbon b/toolchain/parse/testdata/if_expr/in_type.carbon index 09b447059e5e..1d04de25735e 100644 --- a/toolchain/parse/testdata/if_expr/in_type.carbon +++ b/toolchain/parse/testdata/if_expr/in_type.carbon @@ -18,10 +18,11 @@ fn F() -> if true then i32 else i32* { // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'IdentifierNameBeforeParams', text: 'F'}, // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, diff --git a/toolchain/parse/testdata/index/assign_to_var.carbon b/toolchain/parse/testdata/index/assign_to_var.carbon index 86db57a174f4..2819241a88a0 100644 --- a/toolchain/parse/testdata/index/assign_to_var.carbon +++ b/toolchain/parse/testdata/index/assign_to_var.carbon @@ -14,14 +14,15 @@ var v: i32 = t[0]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 't'}, // CHECK:STDOUT: {kind: 'IndexExprStart', text: '[', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'IndexExpr', text: ']', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/index/fail_empty_expr.carbon b/toolchain/parse/testdata/index/fail_empty_expr.carbon index 078aa273076e..b23235453cff 100644 --- a/toolchain/parse/testdata/index/fail_empty_expr.carbon +++ b/toolchain/parse/testdata/index/fail_empty_expr.carbon @@ -18,14 +18,15 @@ var v: i32 = t[]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 't'}, // CHECK:STDOUT: {kind: 'IndexExprStart', text: '[', subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ']', has_error: yes}, // CHECK:STDOUT: {kind: 'IndexExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/index/fail_malformed_expr.carbon b/toolchain/parse/testdata/index/fail_malformed_expr.carbon index 98fd497708bb..e9a6e83a9f0f 100644 --- a/toolchain/parse/testdata/index/fail_malformed_expr.carbon +++ b/toolchain/parse/testdata/index/fail_malformed_expr.carbon @@ -18,14 +18,15 @@ var v: i32 = t[0,]; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 't'}, // CHECK:STDOUT: {kind: 'IndexExprStart', text: '[', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'IndexExpr', text: ']', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/match/fail_cases_after_default.carbon b/toolchain/parse/testdata/match/fail_cases_after_default.carbon index b445bc2822ec..0fd12cef599e 100644 --- a/toolchain/parse/testdata/match/fail_cases_after_default.carbon +++ b/toolchain/parse/testdata/match/fail_cases_after_default.carbon @@ -42,12 +42,13 @@ fn f() -> i32 { // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'MatchIntroducer', text: 'match'}, // CHECK:STDOUT: {kind: 'MatchConditionStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'x'}, @@ -64,6 +65,6 @@ fn f() -> i32 { // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 31}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 32}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/match/fail_unexpected_tokens_in_cases_block.carbon b/toolchain/parse/testdata/match/fail_unexpected_tokens_in_cases_block.carbon index 5a223b88248f..05591f9e5054 100644 --- a/toolchain/parse/testdata/match/fail_unexpected_tokens_in_cases_block.carbon +++ b/toolchain/parse/testdata/match/fail_unexpected_tokens_in_cases_block.carbon @@ -63,12 +63,13 @@ fn f() -> i32 { // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'MatchIntroducer', text: 'match'}, // CHECK:STDOUT: {kind: 'MatchConditionStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'x'}, @@ -117,6 +118,6 @@ fn f() -> i32 { // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 63}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 64}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/match/match.carbon b/toolchain/parse/testdata/match/match.carbon index 591262f9311e..afa038579833 100644 --- a/toolchain/parse/testdata/match/match.carbon +++ b/toolchain/parse/testdata/match/match.carbon @@ -30,12 +30,13 @@ fn f() -> i32 { // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'MatchIntroducer', text: 'match'}, // CHECK:STDOUT: {kind: 'MatchConditionStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'f'}, @@ -105,6 +106,6 @@ fn f() -> i32 { // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 84}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 85}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/assign.carbon b/toolchain/parse/testdata/operators/assign.carbon index 9841a7ee641b..6da8e2eb9b0e 100644 --- a/toolchain/parse/testdata/operators/assign.carbon +++ b/toolchain/parse/testdata/operators/assign.carbon @@ -35,19 +35,21 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'}, // CHECK:STDOUT: {kind: 'InfixOperatorEqual', text: '=', subtree_size: 3}, @@ -98,6 +100,6 @@ fn F() { // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'}, // CHECK:STDOUT: {kind: 'PrefixOperatorMinusMinus', text: '--', subtree_size: 2}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 70}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 72}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_chained_assign.carbon b/toolchain/parse/testdata/operators/fail_chained_assign.carbon index 686610010b1d..8160bf26d913 100644 --- a/toolchain/parse/testdata/operators/fail_chained_assign.carbon +++ b/toolchain/parse/testdata/operators/fail_chained_assign.carbon @@ -29,21 +29,23 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'}, // CHECK:STDOUT: {kind: 'InfixOperatorEqual', text: '=', subtree_size: 3}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, // CHECK:STDOUT: {kind: 'InfixOperatorEqual', text: '=', has_error: yes, subtree_size: 5}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 24}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon b/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon index 598d4baa2cff..3544e5372e98 100644 --- a/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon +++ b/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon @@ -20,12 +20,13 @@ var n: i8 = n* n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', has_error: yes, subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', has_error: yes, subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_infix_uneven_space_before.carbon b/toolchain/parse/testdata/operators/fail_infix_uneven_space_before.carbon index f9f9c47e5209..a7d16fd38ad3 100644 --- a/toolchain/parse/testdata/operators/fail_infix_uneven_space_before.carbon +++ b/toolchain/parse/testdata/operators/fail_infix_uneven_space_before.carbon @@ -18,13 +18,14 @@ var n: i8 = n *n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'InfixOperatorStar', text: '*', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_invalid_infix.carbon b/toolchain/parse/testdata/operators/fail_invalid_infix.carbon index 95dde4372c65..5a7c1ae29a0d 100644 --- a/toolchain/parse/testdata/operators/fail_invalid_infix.carbon +++ b/toolchain/parse/testdata/operators/fail_invalid_infix.carbon @@ -32,31 +32,34 @@ var c: i32 = == ; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'InfixOperatorEqualEqual', text: '==', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '==', has_error: yes}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'InfixOperatorEqualEqual', text: '==', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'c'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'c'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '==', has_error: yes}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'InfixOperatorEqualEqual', text: '==', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_postfix_space.carbon b/toolchain/parse/testdata/operators/fail_postfix_space.carbon index f72e3cd98bed..e52d6d3a7fe9 100644 --- a/toolchain/parse/testdata/operators/fail_postfix_space.carbon +++ b/toolchain/parse/testdata/operators/fail_postfix_space.carbon @@ -18,12 +18,13 @@ var v: type = i8 *; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_postfix_space_before_comma.carbon b/toolchain/parse/testdata/operators/fail_postfix_space_before_comma.carbon index 4f1335dd223c..fe1bfbf66a82 100644 --- a/toolchain/parse/testdata/operators/fail_postfix_space_before_comma.carbon +++ b/toolchain/parse/testdata/operators/fail_postfix_space_before_comma.carbon @@ -18,9 +18,10 @@ var n: i8 = F(i8 *, 0); // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'F'}, // CHECK:STDOUT: {kind: 'CallExprStart', text: '(', subtree_size: 2}, @@ -29,6 +30,6 @@ var n: i8 = F(i8 *, 0); // CHECK:STDOUT: {kind: 'CallExprComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'CallExpr', text: ')', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_postfix_space_in_call.carbon b/toolchain/parse/testdata/operators/fail_postfix_space_in_call.carbon index 55795ed4037a..ad0d31877dcd 100644 --- a/toolchain/parse/testdata/operators/fail_postfix_space_in_call.carbon +++ b/toolchain/parse/testdata/operators/fail_postfix_space_in_call.carbon @@ -18,15 +18,16 @@ var n: i8 = F(i8 *); // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'F'}, // CHECK:STDOUT: {kind: 'CallExprStart', text: '(', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'CallExpr', text: ')', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_postfix_space_surrounding.carbon b/toolchain/parse/testdata/operators/fail_postfix_space_surrounding.carbon index 3aef579cc28b..211310718f41 100644 --- a/toolchain/parse/testdata/operators/fail_postfix_space_surrounding.carbon +++ b/toolchain/parse/testdata/operators/fail_postfix_space_surrounding.carbon @@ -18,12 +18,13 @@ var v: type = i8 * ; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_postincrement.carbon b/toolchain/parse/testdata/operators/fail_postincrement.carbon index 6306cb2e6a2a..08dc9ace7c89 100644 --- a/toolchain/parse/testdata/operators/fail_postincrement.carbon +++ b/toolchain/parse/testdata/operators/fail_postincrement.carbon @@ -32,16 +32,17 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_precedence_assign.carbon b/toolchain/parse/testdata/operators/fail_precedence_assign.carbon index c4bf63f66f86..24a70081df32 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_assign.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_assign.carbon @@ -47,10 +47,11 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, // CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'}, @@ -79,6 +80,6 @@ fn F() { // CHECK:STDOUT: {kind: 'IfExprElse', text: 'else', subtree_size: 6}, // CHECK:STDOUT: {kind: 'PrefixOperatorPlusPlus', text: '++', subtree_size: 7}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 8}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 39}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 40}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_prefix_space.carbon b/toolchain/parse/testdata/operators/fail_prefix_space.carbon index df51e4b3c0c2..701a38d3d08a 100644 --- a/toolchain/parse/testdata/operators/fail_prefix_space.carbon +++ b/toolchain/parse/testdata/operators/fail_prefix_space.carbon @@ -18,12 +18,13 @@ var n: i8 = - n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PrefixOperatorMinus', text: '-', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_prefix_uneven_space_with_assign.carbon b/toolchain/parse/testdata/operators/fail_prefix_uneven_space_with_assign.carbon index c1cbd92c8d95..97d179862083 100644 --- a/toolchain/parse/testdata/operators/fail_prefix_uneven_space_with_assign.carbon +++ b/toolchain/parse/testdata/operators/fail_prefix_uneven_space_with_assign.carbon @@ -18,12 +18,13 @@ var n: i8 =- n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PrefixOperatorMinus', text: '-', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_star_minus.carbon b/toolchain/parse/testdata/operators/fail_star_minus.carbon index 32f9fbe0f3ce..1b257c233adf 100644 --- a/toolchain/parse/testdata/operators/fail_star_minus.carbon +++ b/toolchain/parse/testdata/operators/fail_star_minus.carbon @@ -23,14 +23,15 @@ var n: i8 = n* -n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'InfixOperatorMinus', text: '-', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_star_star.carbon b/toolchain/parse/testdata/operators/fail_star_star.carbon index df3cdf61c0a9..b00c65b9fb74 100644 --- a/toolchain/parse/testdata/operators/fail_star_star.carbon +++ b/toolchain/parse/testdata/operators/fail_star_star.carbon @@ -18,14 +18,15 @@ var n: i8 = n* *p; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'p'}, // CHECK:STDOUT: {kind: 'InfixOperatorStar', text: '*', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon b/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon index 8767552136f2..872f2151e11c 100644 --- a/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon +++ b/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon @@ -22,13 +22,14 @@ var n: i8 = n**p; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', has_error: yes, subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', has_error: yes, subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/fixity_in_var.carbon b/toolchain/parse/testdata/operators/fixity_in_var.carbon index 884149856c40..45cacddcc50d 100644 --- a/toolchain/parse/testdata/operators/fixity_in_var.carbon +++ b/toolchain/parse/testdata/operators/fixity_in_var.carbon @@ -22,21 +22,23 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'q'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'q'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'p'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 't'}, -// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 't'}, +// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 22}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 24}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/infix_no_space.carbon b/toolchain/parse/testdata/operators/infix_no_space.carbon index 91e321e885a9..e0bbf20e77bd 100644 --- a/toolchain/parse/testdata/operators/infix_no_space.carbon +++ b/toolchain/parse/testdata/operators/infix_no_space.carbon @@ -14,13 +14,14 @@ var n: i8 = n*n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'InfixOperatorStar', text: '*', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/infix_with_paren_after.carbon b/toolchain/parse/testdata/operators/infix_with_paren_after.carbon index 1af63aa97c95..cd303c3c3ac5 100644 --- a/toolchain/parse/testdata/operators/infix_with_paren_after.carbon +++ b/toolchain/parse/testdata/operators/infix_with_paren_after.carbon @@ -14,15 +14,16 @@ var n: i8 = 3*(n); // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, // CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 3}, // CHECK:STDOUT: {kind: 'InfixOperatorStar', text: '*', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/infix_with_paren_before.carbon b/toolchain/parse/testdata/operators/infix_with_paren_before.carbon index fbd162552bd4..4b8893a5118a 100644 --- a/toolchain/parse/testdata/operators/infix_with_paren_before.carbon +++ b/toolchain/parse/testdata/operators/infix_with_paren_before.carbon @@ -14,15 +14,16 @@ var n: i8 = (n)*3; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'ParenExprStart', text: '('}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 3}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '3'}, // CHECK:STDOUT: {kind: 'InfixOperatorStar', text: '*', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/postfix.carbon b/toolchain/parse/testdata/operators/postfix.carbon index 25bf2d48d597..3e97008037a7 100644 --- a/toolchain/parse/testdata/operators/postfix.carbon +++ b/toolchain/parse/testdata/operators/postfix.carbon @@ -14,12 +14,13 @@ var v: type = i8*; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/postfix_space_after_op.carbon b/toolchain/parse/testdata/operators/postfix_space_after_op.carbon index a28a9c08d130..0354efa554c1 100644 --- a/toolchain/parse/testdata/operators/postfix_space_after_op.carbon +++ b/toolchain/parse/testdata/operators/postfix_space_after_op.carbon @@ -14,12 +14,13 @@ var v: type = i8* ; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/precedence_assign.carbon b/toolchain/parse/testdata/operators/precedence_assign.carbon index 560dd249cc72..8bf7d2401616 100644 --- a/toolchain/parse/testdata/operators/precedence_assign.carbon +++ b/toolchain/parse/testdata/operators/precedence_assign.carbon @@ -29,21 +29,24 @@ fn F(c: bool) { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 5}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'p'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'p'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'p'}, // CHECK:STDOUT: {kind: 'PrefixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'c'}, @@ -70,6 +73,6 @@ fn F(c: bool) { // CHECK:STDOUT: {kind: 'IfExprElse', text: 'else', subtree_size: 6}, // CHECK:STDOUT: {kind: 'InfixOperatorPlusEqual', text: '+=', subtree_size: 15}, // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 16}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 51}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 54}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/prefix.carbon b/toolchain/parse/testdata/operators/prefix.carbon index 2646d541af8a..919d9bef12b2 100644 --- a/toolchain/parse/testdata/operators/prefix.carbon +++ b/toolchain/parse/testdata/operators/prefix.carbon @@ -15,20 +15,22 @@ var b: bool = not true; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PrefixOperatorMinus', text: '-', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'BoolTypeLiteral', text: 'bool'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, +// CHECK:STDOUT: {kind: 'BoolTypeLiteral', text: 'bool'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'}, // CHECK:STDOUT: {kind: 'PrefixOperatorNot', text: 'not', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/operators/prefix_no_space.carbon b/toolchain/parse/testdata/operators/prefix_no_space.carbon index 989230bb3bbf..9d9b977d0ec9 100644 --- a/toolchain/parse/testdata/operators/prefix_no_space.carbon +++ b/toolchain/parse/testdata/operators/prefix_no_space.carbon @@ -15,12 +15,13 @@ var n: i8 =-n; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i8'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PrefixOperatorMinus', text: '-', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/package_expr/basic.carbon b/toolchain/parse/testdata/package_expr/basic.carbon index 8d3213adc335..588c27fd2d66 100644 --- a/toolchain/parse/testdata/package_expr/basic.carbon +++ b/toolchain/parse/testdata/package_expr/basic.carbon @@ -14,15 +14,16 @@ var x: package.Foo = package.Bar; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'PackageExpr', text: 'package'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'Foo'}, -// CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'PackageExpr', text: 'package'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'Foo'}, +// CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'PackageExpr', text: 'package'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'Bar'}, // CHECK:STDOUT: {kind: 'MemberAccessExpr', text: '.', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/package_expr/fail_in_name.carbon b/toolchain/parse/testdata/package_expr/fail_in_name.carbon index d99b4fee38ff..7b7b8bc263cb 100644 --- a/toolchain/parse/testdata/package_expr/fail_in_name.carbon +++ b/toolchain/parse/testdata/package_expr/fail_in_name.carbon @@ -31,10 +31,11 @@ class package.C { // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'package', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: 'package', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: 'package', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'package', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: 'package', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: 'package', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: 'package', has_error: yes}, // CHECK:STDOUT: {kind: 'Namespace', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/pointer/pointer_type.carbon b/toolchain/parse/testdata/pointer/pointer_type.carbon index 2a470ab9787b..a382784cdc1c 100644 --- a/toolchain/parse/testdata/pointer/pointer_type.carbon +++ b/toolchain/parse/testdata/pointer/pointer_type.carbon @@ -54,9 +54,10 @@ var T: type = if true then i32* else f64*; // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 34}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'T'}, -// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'T'}, +// CHECK:STDOUT: {kind: 'TypeTypeLiteral', text: 'type'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'}, // CHECK:STDOUT: {kind: 'IfExprIf', text: 'if', subtree_size: 2}, @@ -66,6 +67,6 @@ var T: type = if true then i32* else f64*; // CHECK:STDOUT: {kind: 'FloatTypeLiteral', text: 'f64'}, // CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IfExprElse', text: 'else', subtree_size: 8}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 14}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 15}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/pointer/pointer_value.carbon b/toolchain/parse/testdata/pointer/pointer_value.carbon index 3c5ffc3ee987..1747c922d44d 100644 --- a/toolchain/parse/testdata/pointer/pointer_value.carbon +++ b/toolchain/parse/testdata/pointer/pointer_value.carbon @@ -26,36 +26,39 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'p'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'p'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'}, // CHECK:STDOUT: {kind: 'PrefixOperatorAmp', text: '&', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'q'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'q'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'p'}, // CHECK:STDOUT: {kind: 'PrefixOperatorAmp', text: '&', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'}, // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'q'}, // CHECK:STDOUT: {kind: 'PrefixOperatorStar', text: '*', subtree_size: 2}, // CHECK:STDOUT: {kind: 'PrefixOperatorStar', text: '*', subtree_size: 3}, // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 39}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 42}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/return/returned_var.carbon b/toolchain/parse/testdata/return/returned_var.carbon index cd912fc8e495..d8ea5c5b80de 100644 --- a/toolchain/parse/testdata/return/returned_var.carbon +++ b/toolchain/parse/testdata/return/returned_var.carbon @@ -25,15 +25,16 @@ fn F() -> String { // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'ReturnedModifier', text: 'returned'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 's'}, -// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 's'}, +// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StringLiteral', text: '"hello"'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, // CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'}, // CHECK:STDOUT: {kind: 'ReturnVarModifier', text: 'var'}, // CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 19}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 20}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_comma_only.carbon b/toolchain/parse/testdata/struct/fail_comma_only.carbon index c38f094d214c..e9fbe6429fa9 100644 --- a/toolchain/parse/testdata/struct/fail_comma_only.carbon +++ b/toolchain/parse/testdata/struct/fail_comma_only.carbon @@ -18,15 +18,16 @@ var x: {,} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 4}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 7}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon b/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon index 39584d048a1e..4a2dc487d715 100644 --- a/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon +++ b/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon @@ -18,20 +18,21 @@ var x: {.a: i32,,} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 9}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 9}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 12}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 16}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon b/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon index 17bc7a8572d5..2be2426c9614 100644 --- a/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon +++ b/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon @@ -18,20 +18,21 @@ var x: {.a = 0,,} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 9}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, +// CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ',', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 9}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 12}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 16}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon b/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon index 218ae72e632e..fa1fea68dccb 100644 --- a/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon +++ b/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon @@ -18,14 +18,15 @@ var x: {.a: i32 banana} = {.a = 0}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, @@ -33,6 +34,6 @@ var x: {.a: i32 banana} = {.a = 0}; // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon b/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon index bcbd471b51f4..8781119d98c6 100644 --- a/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon +++ b/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon @@ -18,14 +18,15 @@ var x: {.a: i32} = {.a = 0 banana}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, @@ -33,6 +34,6 @@ var x: {.a: i32} = {.a = 0 banana}; // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_identifier_colon.carbon b/toolchain/parse/testdata/struct/fail_identifier_colon.carbon index 838dcde4b43a..9da1066ecd05 100644 --- a/toolchain/parse/testdata/struct/fail_identifier_colon.carbon +++ b/toolchain/parse/testdata/struct/fail_identifier_colon.carbon @@ -18,14 +18,15 @@ var x: {a:} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_identifier_equals.carbon b/toolchain/parse/testdata/struct/fail_identifier_equals.carbon index 387d8692b97c..c2aae27b4cd3 100644 --- a/toolchain/parse/testdata/struct/fail_identifier_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_identifier_equals.carbon @@ -18,14 +18,15 @@ var x: {a=} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_identifier_only.carbon b/toolchain/parse/testdata/struct/fail_identifier_only.carbon index c8f4d1e49ea2..c21a9cb17647 100644 --- a/toolchain/parse/testdata/struct/fail_identifier_only.carbon +++ b/toolchain/parse/testdata/struct/fail_identifier_only.carbon @@ -18,14 +18,15 @@ var x: {a} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: 'a', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_invalid_struct_designator.carbon b/toolchain/parse/testdata/struct/fail_invalid_struct_designator.carbon index c74c1798e712..4ce04cb170d6 100644 --- a/toolchain/parse/testdata/struct/fail_invalid_struct_designator.carbon +++ b/toolchain/parse/testdata/struct/fail_invalid_struct_designator.carbon @@ -18,9 +18,10 @@ var x: i32 = {.7 = 8}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '7', has_error: yes}, @@ -28,6 +29,6 @@ var x: i32 = {.7 = 8}; // CHECK:STDOUT: {kind: 'IntLiteral', text: '8'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_missing_type.carbon b/toolchain/parse/testdata/struct/fail_missing_type.carbon index bca4a9e4707f..1023403cfc53 100644 --- a/toolchain/parse/testdata/struct/fail_missing_type.carbon +++ b/toolchain/parse/testdata/struct/fail_missing_type.carbon @@ -18,17 +18,18 @@ var x: {.a:} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_missing_value.carbon b/toolchain/parse/testdata/struct/fail_missing_value.carbon index bf03b7f1e001..76ca36732a46 100644 --- a/toolchain/parse/testdata/struct/fail_missing_value.carbon +++ b/toolchain/parse/testdata/struct/fail_missing_value.carbon @@ -18,17 +18,18 @@ var x: {.a=} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon b/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon index 9a94c6ecb3a1..c367a7cc876b 100644 --- a/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon +++ b/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon @@ -18,21 +18,22 @@ var x: {.a: i32, .b = 0} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 10}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 10}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 13}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon b/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon index 6865024b4be2..93fd81cefdca 100644 --- a/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon +++ b/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon @@ -18,19 +18,20 @@ var x: {.a = 0, b: i32} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: 'b', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 8}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, +// CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: 'b', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 8}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 11}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 15}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 16}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon b/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon index 2af751c13f42..f11b230a69fc 100644 --- a/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon +++ b/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon @@ -32,9 +32,10 @@ var x: i32 = {.a: i32, .b, .c = 1}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, @@ -50,11 +51,12 @@ var x: i32 = {.a: i32, .b, .c = 1}; // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 14}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 20}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 21}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, @@ -70,6 +72,6 @@ var x: i32 = {.a: i32, .b, .c = 1}; // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, // CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 14}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 20}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 21}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon b/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon index 32a1ff904fe5..06ecfad12ddd 100644 --- a/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon @@ -18,16 +18,17 @@ var x: {.a} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_period_only.carbon b/toolchain/parse/testdata/struct/fail_period_only.carbon index a349b02ef6cf..0d24bc6af7bb 100644 --- a/toolchain/parse/testdata/struct/fail_period_only.carbon +++ b/toolchain/parse/testdata/struct/fail_period_only.carbon @@ -18,16 +18,17 @@ var x: {.} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '}', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '}', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '.', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 13}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_period_paren.carbon b/toolchain/parse/testdata/struct/fail_period_paren.carbon index cf686a58718e..2c76e6ef332c 100644 --- a/toolchain/parse/testdata/struct/fail_period_paren.carbon +++ b/toolchain/parse/testdata/struct/fail_period_paren.carbon @@ -18,14 +18,15 @@ var x: {.(a) = 1}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '(', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '(', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_period_string_colon.carbon b/toolchain/parse/testdata/struct/fail_period_string_colon.carbon index 36b6cc1d6340..2185f93cd1b2 100644 --- a/toolchain/parse/testdata/struct/fail_period_string_colon.carbon +++ b/toolchain/parse/testdata/struct/fail_period_string_colon.carbon @@ -18,22 +18,23 @@ var x: {."hello": i32, .y: i32} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '"hello"', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '"hello"', has_error: yes}, // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 11}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ':', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 11}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 14}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_period_string_equals.carbon b/toolchain/parse/testdata/struct/fail_period_string_equals.carbon index 8593144126f6..d01dfcb92615 100644 --- a/toolchain/parse/testdata/struct/fail_period_string_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_period_string_equals.carbon @@ -18,22 +18,23 @@ var x: {."hello" = 0, .y = 4} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '"hello"', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '"hello"', has_error: yes}, // CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '4'}, -// CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 11}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '4'}, +// CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 11}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 14}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/fail_type_no_designator.carbon b/toolchain/parse/testdata/struct/fail_type_no_designator.carbon index 1d07c17dc80d..4546d6b550db 100644 --- a/toolchain/parse/testdata/struct/fail_type_no_designator.carbon +++ b/toolchain/parse/testdata/struct/fail_type_no_designator.carbon @@ -18,14 +18,15 @@ var x: {i32} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: 'i32', has_error: yes}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: 'i32', has_error: yes}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 6}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 11}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/no_entries.carbon b/toolchain/parse/testdata/struct/no_entries.carbon index d9f42ad10f0b..b1bf876a606c 100644 --- a/toolchain/parse/testdata/struct/no_entries.carbon +++ b/toolchain/parse/testdata/struct/no_entries.carbon @@ -14,13 +14,14 @@ var y: {} = {}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, +// CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 10}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/one_entry_no_comma.carbon b/toolchain/parse/testdata/struct/one_entry_no_comma.carbon index 528d707a1a75..af0be03ae48e 100644 --- a/toolchain/parse/testdata/struct/one_entry_no_comma.carbon +++ b/toolchain/parse/testdata/struct/one_entry_no_comma.carbon @@ -14,14 +14,15 @@ var z: {.n: i32} = {.n = 4}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'z'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'z'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 9}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, @@ -29,6 +30,6 @@ var z: {.n: i32} = {.n = 4}; // CHECK:STDOUT: {kind: 'IntLiteral', text: '4'}, // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/one_entry_with_comma.carbon b/toolchain/parse/testdata/struct/one_entry_with_comma.carbon index 994d7fefcb72..24ad2a67fe5e 100644 --- a/toolchain/parse/testdata/struct/one_entry_with_comma.carbon +++ b/toolchain/parse/testdata/struct/one_entry_with_comma.carbon @@ -14,15 +14,16 @@ var z: {.n: i32,} = {.n = 4,}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'z'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'z'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'n'}, @@ -31,6 +32,6 @@ var z: {.n: i32,} = {.n = 4,}; // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, // CHECK:STDOUT: {kind: 'StructLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 19}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 20}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/struct/two_entries.carbon b/toolchain/parse/testdata/struct/two_entries.carbon index 0d54033a2be1..8bf98268408c 100644 --- a/toolchain/parse/testdata/struct/two_entries.carbon +++ b/toolchain/parse/testdata/struct/two_entries.carbon @@ -14,19 +14,20 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2}; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, -// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, -// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 11}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralStart', text: '{'}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'b'}, +// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'StructTypeLiteralField', text: ':', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 11}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 14}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StructLiteralStart', text: '{'}, // CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'a'}, @@ -39,6 +40,6 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2}; // CHECK:STDOUT: {kind: 'IntLiteral', text: '2'}, // CHECK:STDOUT: {kind: 'StructLiteralField', text: '=', subtree_size: 4}, // CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 11}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 27}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 28}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/tuple/nested.carbon b/toolchain/parse/testdata/tuple/nested.carbon index 0ee0fb52d91e..8d98a66903cf 100644 --- a/toolchain/parse/testdata/tuple/nested.carbon +++ b/toolchain/parse/testdata/tuple/nested.carbon @@ -14,18 +14,19 @@ var y: ((), (), ()); // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, -// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'y'}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, -// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, -// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, -// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, -// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 10}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 12}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 14}, +// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, +// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, +// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, +// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 2}, +// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 10}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 12}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 15}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/tuple/two_entries.carbon b/toolchain/parse/testdata/tuple/two_entries.carbon index 82713df36958..714d2b7f0881 100644 --- a/toolchain/parse/testdata/tuple/two_entries.carbon +++ b/toolchain/parse/testdata/tuple/two_entries.carbon @@ -14,19 +14,20 @@ var x: (i32, i32) = (1, 2); // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '1'}, // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '2'}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 15}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 16}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/var/fail_bad_name.carbon b/toolchain/parse/testdata/var/fail_bad_name.carbon index faaa2ee85e10..7e06528c6a2a 100644 --- a/toolchain/parse/testdata/var/fail_bad_name.carbon +++ b/toolchain/parse/testdata/var/fail_bad_name.carbon @@ -18,9 +18,10 @@ var *; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '*', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '*', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: '*', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '*', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '*', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: '*', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/var/fail_empty.carbon b/toolchain/parse/testdata/var/fail_empty.carbon index c0977bfb2fe6..ce225d7332f1 100644 --- a/toolchain/parse/testdata/var/fail_empty.carbon +++ b/toolchain/parse/testdata/var/fail_empty.carbon @@ -18,9 +18,10 @@ var; // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: ';', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ';', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: ';', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ';', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/var/fail_no_semi.carbon b/toolchain/parse/testdata/var/fail_no_semi.carbon index 1f1ffc049c87..aa7948c866d5 100644 --- a/toolchain/parse/testdata/var/fail_no_semi.carbon +++ b/toolchain/parse/testdata/var/fail_no_semi.carbon @@ -10,11 +10,11 @@ var -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+17]]:21: error: expected name in binding pattern [ExpectedBindingPattern] +// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+18]]:21: error: expected name in binding pattern [ExpectedBindingPattern] // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+13]]:21: error: `var` declarations must end with a `;` [ExpectedDeclSemi] +// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+14]]:21: error: `var` declarations must end with a `;` [ExpectedDeclSemi] // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDERR: @@ -22,9 +22,10 @@ var // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '', has_error: yes}, -// CHECK:STDOUT: {kind: 'InvalidParse', text: '', has_error: yes}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: '', has_error: yes, subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: 'var', has_error: yes, subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: '', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParse', text: '', has_error: yes}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: '', has_error: yes, subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', has_error: yes, subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: 'var', has_error: yes, subtree_size: 6}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/var/var.carbon b/toolchain/parse/testdata/var/var.carbon index 3c78485f9fdc..203e0bcf962e 100644 --- a/toolchain/parse/testdata/var/var.carbon +++ b/toolchain/parse/testdata/var/var.carbon @@ -18,29 +18,32 @@ fn F() { // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'v'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'w'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'w'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'IdentifierNameBeforeParams', text: 'F'}, // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 's'}, -// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 's'}, +// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'StringLiteral', text: '"hello"'}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 13}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/var/var_tuple.carbon b/toolchain/parse/testdata/var/var_tuple.carbon index 1dd569b8ce16..782be6fa5d98 100644 --- a/toolchain/parse/testdata/var/var_tuple.carbon +++ b/toolchain/parse/testdata/var/var_tuple.carbon @@ -21,22 +21,23 @@ fn F() { // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2}, // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 's'}, -// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'PatternListComma', text: ','}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'i'}, -// CHECK:STDOUT: {kind: 'IntLiteral', text: '32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, -// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 's'}, +// CHECK:STDOUT: {kind: 'StringTypeLiteral', text: 'String'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'PatternListComma', text: ','}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'i'}, +// CHECK:STDOUT: {kind: 'IntLiteral', text: '32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 9}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 10}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'TupleLiteralStart', text: '('}, // CHECK:STDOUT: {kind: 'StringLiteral', text: '"hello"'}, // CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','}, // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'}, // CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17}, -// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 23}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 18}, +// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 24}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/where_expr/designators.carbon b/toolchain/parse/testdata/where_expr/designators.carbon index 36996361f1e2..dee19cf4bf44 100644 --- a/toolchain/parse/testdata/where_expr/designators.carbon +++ b/toolchain/parse/testdata/where_expr/designators.carbon @@ -59,11 +59,11 @@ fn FailStar() { var x: i32 = . -// CHECK:STDERR: fail_designator_eof.carbon:[[@LINE+94]]:21: error: expected identifier or `Self` after `.` [ExpectedIdentifierOrSelfAfterPeriod] +// CHECK:STDERR: fail_designator_eof.carbon:[[@LINE+95]]:21: error: expected identifier or `Self` after `.` [ExpectedIdentifierOrSelfAfterPeriod] // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDERR: -// CHECK:STDERR: fail_designator_eof.carbon:[[@LINE+90]]:21: error: `var` declarations must end with a `;` [ExpectedDeclSemi] +// CHECK:STDERR: fail_designator_eof.carbon:[[@LINE+91]]:21: error: `var` declarations must end with a `;` [ExpectedDeclSemi] // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDERR: @@ -145,12 +145,13 @@ var x: i32 = . // CHECK:STDOUT: parse_tree: [ // CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, -// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, -// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, -// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'}, +// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'}, +// CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3}, +// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4}, // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '', has_error: yes}, // CHECK:STDOUT: {kind: 'DesignatorExpr', text: '.', has_error: yes, subtree_size: 2}, -// CHECK:STDOUT: {kind: 'VariableDecl', text: '.', has_error: yes, subtree_size: 8}, +// CHECK:STDOUT: {kind: 'VariableDecl', text: '.', has_error: yes, subtree_size: 9}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/typed_nodes.h b/toolchain/parse/typed_nodes.h index 1708c6817028..fbd7fde4d4c0 100644 --- a/toolchain/parse/typed_nodes.h +++ b/toolchain/parse/typed_nodes.h @@ -488,7 +488,7 @@ struct VariableDecl { VariableIntroducerId introducer; llvm::SmallVector modifiers; std::optional returned; - AnyPatternId pattern; + VariablePatternId pattern; struct Initializer { VariableInitializerId equals; @@ -498,6 +498,15 @@ struct VariableDecl { Lex::SemiTokenIndex token; }; +// A `var` pattern. +struct VariablePattern { + static constexpr auto Kind = NodeKind::VariablePattern.Define( + {.category = NodeCategory::Pattern, .child_count = 1}); + + Lex::VarTokenIndex token; + AnyPatternId inner; +}; + // Statement nodes // --------------- diff --git a/toolchain/parse/typed_nodes_test.cpp b/toolchain/parse/typed_nodes_test.cpp index ce229e3179ad..2ffed9abf468 100644 --- a/toolchain/parse/typed_nodes_test.cpp +++ b/toolchain/parse/typed_nodes_test.cpp @@ -128,7 +128,9 @@ TEST_F(TypedNodeTest, For) { ASSERT_TRUE(for_header.has_value()); auto for_var = tree.Extract(for_header->var); ASSERT_TRUE(for_var.has_value()); - auto for_var_binding = tree.ExtractAs(for_var->pattern); + auto for_var_pattern = tree.ExtractAs(for_var->pattern); + ASSERT_TRUE(for_var_pattern.has_value()); + auto for_var_binding = tree.ExtractAs(for_var_pattern->inner); ASSERT_TRUE(for_var_binding.has_value()); auto for_var_name = tree.ExtractAs(for_var_binding->name); @@ -176,10 +178,10 @@ TEST_F(TypedNodeTest, VerifyExtractTraceVarNoInit) { R"Trace(Aggregate [^:]*: begin Optional [^:]*: begin Aggregate [^:]*: begin -NodeIdInCategory Expr error: kind BindingPattern doesn't match +NodeIdInCategory Expr error: kind VariablePattern doesn't match Aggregate [^:]*: error Optional [^:]*: missing -NodeIdInCategory Pattern: kind BindingPattern consumed +NodeIdForKind: VariablePattern consumed Optional [^:]*: begin NodeIdForKind error: wrong kind VariableIntroducer, expected ReturnedModifier Optional [^:]*: missing @@ -211,7 +213,7 @@ NodeIdInCategory Expr: kind MemberAccessExpr consumed NodeIdForKind: VariableInitializer consumed Aggregate [^:]*: success Optional [^:]*: found -NodeIdInCategory Pattern: kind BindingPattern consumed +NodeIdForKind: VariablePattern consumed Optional [^:]*: begin NodeIdForKind error: wrong kind VariableIntroducer, expected ReturnedModifier Optional [^:]*: missing @@ -292,9 +294,9 @@ TEST_F(TypedNodeTest, Token) { ASSERT_TRUE(n_intro.has_value()); EXPECT_EQ(tokens.GetKind(n_intro->token), Lex::TokenKind::Var); - auto n_patt = tree.ExtractAs(n_var->pattern); + auto n_patt = tree.ExtractAs(n_var->pattern); ASSERT_TRUE(n_patt.has_value()); - EXPECT_EQ(tokens.GetKind(n_patt->token), Lex::TokenKind::Colon); + EXPECT_EQ(tokens.GetKind(n_patt->token), Lex::TokenKind::Var); } TEST_F(TypedNodeTest, VerifyInvalid) { diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index d7fda24fee5b..c129284958db 100644 --- a/toolchain/sem_ir/file.cpp +++ b/toolchain/sem_ir/file.cpp @@ -189,6 +189,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { case FieldDecl::Kind: case FunctionDecl::Kind: case ImplDecl::Kind: + case NameBindingDecl::Kind: case Namespace::Kind: case OutParamPattern::Kind: case RequirementEquivalent::Kind: @@ -198,6 +199,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { case ReturnSlotPattern::Kind: case Vtable::Kind: case ReturnExpr::Kind: + case VarPattern::Kind: return ExprCategory::NotExpr; case ImportRefUnloaded::Kind: diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index 8f846cfea170..71d35aed634c 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -1071,6 +1071,10 @@ class FormatterImpl { FormatImportRefRHS(inst.import_ir_inst_id, inst.entity_name_id, "unloaded"); } + auto FormatInstRHS(NameBindingDecl inst) -> void { + FormatTrailingBlock(inst.pattern_block_id); + } + auto FormatInstRHS(SpliceBlock inst) -> void { FormatArgs(inst.result_id); FormatTrailingBlock(inst.block_id); diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index d9c01d20522b..1b30e3b29a32 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -40,12 +40,17 @@ struct InstId : public IdBase { // An explicitly invalid ID. static const InstId Invalid; + // Represents the result of a name lookup that is temporarily disallowed + // because the name is currently being initialized. + static const InstId InitTombstone; + using IdBase::IdBase; auto Print(llvm::raw_ostream& out) const -> void; }; constexpr InstId InstId::Invalid = InstId(InvalidIndex); +constexpr InstId InstId::InitTombstone = InstId(InvalidIndex - 2); // An ID of an instruction that is referenced absolutely by another instruction. // This should only be used as the type of a field within a typed instruction diff --git a/toolchain/sem_ir/inst_kind.def b/toolchain/sem_ir/inst_kind.def index 30cc84048bdd..b41aa1325ead 100644 --- a/toolchain/sem_ir/inst_kind.def +++ b/toolchain/sem_ir/inst_kind.def @@ -77,6 +77,7 @@ CARBON_SEM_IR_INST_KIND(IntType) CARBON_SEM_IR_INST_KIND(IntValue) CARBON_SEM_IR_INST_KIND(InterfaceDecl) CARBON_SEM_IR_INST_KIND(LegacyFloatType) +CARBON_SEM_IR_INST_KIND(NameBindingDecl) CARBON_SEM_IR_INST_KIND(NameRef) CARBON_SEM_IR_INST_KIND(Namespace) CARBON_SEM_IR_INST_KIND(NamespaceType) @@ -117,6 +118,7 @@ CARBON_SEM_IR_INST_KIND(ValueAsRef) CARBON_SEM_IR_INST_KIND(ValueOfInitializer) CARBON_SEM_IR_INST_KIND(ValueParam) CARBON_SEM_IR_INST_KIND(ValueParamPattern) +CARBON_SEM_IR_INST_KIND(VarPattern) CARBON_SEM_IR_INST_KIND(VarStorage) CARBON_SEM_IR_INST_KIND(VtableType) CARBON_SEM_IR_INST_KIND(VtablePtr) diff --git a/toolchain/sem_ir/inst_namer.cpp b/toolchain/sem_ir/inst_namer.cpp index 76b0b62e3439..2aa6abd2df45 100644 --- a/toolchain/sem_ir/inst_namer.cpp +++ b/toolchain/sem_ir/inst_namer.cpp @@ -309,6 +309,10 @@ auto InstNamer::AddBlockLabel(ScopeId scope_id, InstBlockId block_id, // represents some kind of branch. auto InstNamer::AddBlockLabel(ScopeId scope_id, SemIR::LocId loc_id, AnyBranch branch) -> void { + if (!loc_id.node_id().is_valid()) { + AddBlockLabel(scope_id, branch.target_id, "", loc_id); + return; + } llvm::StringRef name; switch (sem_ir_->parse_tree().node_kind(loc_id.node_id())) { case Parse::NodeKind::IfExprIf: @@ -726,6 +730,10 @@ auto InstNamer::CollectNamesInBlock(ScopeId top_scope_id, add_inst_name(std::move(name)); continue; } + case CARBON_KIND(NameBindingDecl inst): { + queue_block_id(scope_id, inst.pattern_block_id); + continue; + } case CARBON_KIND(NameRef inst): { add_inst_name_id(inst.name_id, ".ref"); continue; @@ -867,7 +875,7 @@ auto InstNamer::CollectNamesInBlock(ScopeId top_scope_id, continue; } case CARBON_KIND(VarStorage inst): { - add_inst_name_id(inst.name_id, ".var"); + add_inst_name_id(inst.pretty_name_id, ".var"); continue; } default: { diff --git a/toolchain/sem_ir/stringify_type.cpp b/toolchain/sem_ir/stringify_type.cpp index 1c1292d1b054..9278fa1a65d2 100644 --- a/toolchain/sem_ir/stringify_type.cpp +++ b/toolchain/sem_ir/stringify_type.cpp @@ -568,6 +568,7 @@ auto StringifyTypeExpr(const SemIR::File& sem_ir, InstId outer_inst_id) case ImportRefLoaded::Kind: case InitializeFrom::Kind: case InterfaceDecl::Kind: + case NameBindingDecl::Kind: case OutParam::Kind: case OutParamPattern::Kind: case RequireCompleteType::Kind: @@ -595,6 +596,7 @@ auto StringifyTypeExpr(const SemIR::File& sem_ir, InstId outer_inst_id) case ValueOfInitializer::Kind: case ValueParam::Kind: case ValueParamPattern::Kind: + case VarPattern::Kind: case VarStorage::Kind: case WhereExpr::Kind: // We don't know how to print this instruction, but it might have a diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index ac100aaee679..206e2202dcc4 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -202,9 +202,9 @@ struct AsCompatible { // `rhs_id`. This finishes initialization of `lhs_id` in the same way as // `InitializeFrom`. struct Assign { - static constexpr auto Kind = InstKind::Assign.Define< - Parse::NodeIdOneOf>( - {.ir_name = "assign"}); + // TODO: Make Parse::NodeId more specific. + static constexpr auto Kind = + InstKind::Assign.Define({.ir_name = "assign"}); // Assignments are statements, and so have no type. InstId lhs_id; @@ -214,8 +214,9 @@ struct Assign { // An associated constant declaration in an interface, such as `let T:! type;`. struct AssociatedConstantDecl { static constexpr auto Kind = - InstKind::AssociatedConstantDecl.Define( - {.ir_name = "assoc_const_decl", .is_lowered = false}); + InstKind::AssociatedConstantDecl + .Define( + {.ir_name = "assoc_const_decl", .is_lowered = false}); TypeId type_id; NameId name_id; @@ -934,6 +935,16 @@ struct IntType { InstId bit_width_id; }; +// A name-binding declaration, i.e. a declaration introduced with `let` or +// `var`. +struct NameBindingDecl { + // TODO: Make Parse::NodeId more specific. + static constexpr auto Kind = InstKind::NameBindingDecl.Define( + {.ir_name = "name_binding_decl"}); + + InstBlockId pattern_block_id; +}; + // A name reference, with the value of the name. This only handles name // resolution; the value may be used for reading or writing. struct NameRef { @@ -1463,14 +1474,27 @@ struct ValueOfInitializer { InstId init_id; }; -// Tracks storage for a `var` declaration. +// A `var` pattern. +struct VarPattern { + static constexpr auto Kind = + InstKind::VarPattern.Define( + {.ir_name = "var_pattern", .is_lowered = false}); + + TypeId type_id; + InstId subpattern_id; +}; + +// Tracks storage for a `var` pattern. struct VarStorage { // TODO: Make Parse::NodeId more specific. static constexpr auto Kind = InstKind::VarStorage.Define({.ir_name = "var"}); TypeId type_id; - NameId name_id; + + // A name to associate with this var in pretty-printed IR. This is not + // necessarily unique, or even valid, and has no semantic significance. + NameId pretty_name_id; }; // The type of virtual function tables. diff --git a/toolchain/sem_ir/yaml_test.cpp b/toolchain/sem_ir/yaml_test.cpp index 1fe4db5fb0ab..7886bb1b6474 100644 --- a/toolchain/sem_ir/yaml_test.cpp +++ b/toolchain/sem_ir/yaml_test.cpp @@ -98,7 +98,8 @@ TEST(SemIRTest, YAML) { Pair("inst_block4", Yaml::Mapping(Each(Pair(_, inst_id)))), Pair("inst_block5", Yaml::Mapping(Each(Pair(_, inst_id)))), Pair("inst_block6", Yaml::Mapping(Each(Pair(_, inst_id)))), - Pair("inst_block7", Yaml::Mapping(Each(Pair(_, inst_id))))))))); + Pair("inst_block7", Yaml::Mapping(Each(Pair(_, inst_id)))), + Pair("inst_block8", Yaml::Mapping(Each(Pair(_, inst_id))))))))); auto root = Yaml::Sequence(ElementsAre(Yaml::Mapping( ElementsAre(Pair("filename", "test.carbon"), Pair("sem_ir", file)))));