diff --git a/toolchain/check/testdata/tuple/import.carbon b/toolchain/check/testdata/tuple/import.carbon index 91ca8ab9db3db..3b9242177e5da 100644 --- a/toolchain/check/testdata/tuple/import.carbon +++ b/toolchain/check/testdata/tuple/import.carbon @@ -45,10 +45,10 @@ var c_bad: C((1, 2, 3)) = F(); impl package Implicit; -// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `C()` to `C()` [ImplicitAsConversionFailure] +// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+6]]: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: fail_bad_value.impl.carbon:[[@LINE+3]]:1: note: type `C()` does not implement interface `Core.ImplicitAs(C())` [MissingImplInMemberAccessNote] +// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+3]]: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: ^~~~~~~~~~~~~~~~~~~~~~~~~~~ var c_bad: C((3, 4)) = F(); diff --git a/toolchain/sem_ir/stringify_type.cpp b/toolchain/sem_ir/stringify_type.cpp index ca13382b65f91..659ee92a968ea 100644 --- a/toolchain/sem_ir/stringify_type.cpp +++ b/toolchain/sem_ir/stringify_type.cpp @@ -454,6 +454,27 @@ auto StringifyTypeExpr(const SemIR::File& sem_ir, InstId outer_inst_id) } break; } + case CARBON_KIND(TupleValue inst): { + auto refs = sem_ir.inst_blocks().Get(inst.elements_id); + if (refs.empty()) { + out << "()"; + break; + } + out << "("; + step_stack.PushString(")"); + // A tuple of one element has a comma to disambiguate from an + // expression. + if (refs.size() == 1) { + step_stack.PushString(","); + } + for (auto i : llvm::reverse(llvm::seq(refs.size()))) { + step_stack.PushInstId(refs[i]); + if (i > 0) { + step_stack.PushString(", "); + } + } + break; + } case CARBON_KIND(UnboundElementType inst): { out << ""); @@ -522,7 +543,6 @@ auto StringifyTypeExpr(const SemIR::File& sem_ir, InstId outer_inst_id) case TupleAccess::Kind: case TupleInit::Kind: case TupleLiteral::Kind: - case TupleValue::Kind: case UnaryOperatorNot::Kind: case ValueAsRef::Kind: case ValueOfInitializer::Kind: