@@ -742,9 +742,6 @@ auto PerformCompoundMemberAccess(Context& context, SemIR::LocId loc_id,
742742 return GetAssociatedValueImpl (context, loc_id, base_id, assoc_entity,
743743 assoc_type->GetSpecificInterface ());
744744 }
745- } else if (context.insts ().Is <SemIR::TupleType>(
746- context.constant_values ().GetInstId (base_type_const_id))) {
747- return PerformTupleAccess (context, loc_id, base_id, member_expr_id);
748745 }
749746
750747 // Perform instance binding if we found an instance member.
@@ -754,6 +751,13 @@ auto PerformCompoundMemberAccess(Context& context, SemIR::LocId loc_id,
754751 // because the base expression is not used for anything.
755752 if (member_id == member_expr_id &&
756753 member.type_id () != SemIR::ErrorInst::TypeId) {
754+ // As a special case, an integer-valued expression can be used as a member
755+ // name when indexing a tuple.
756+ if (context.insts ().Is <SemIR::TupleType>(
757+ context.constant_values ().GetInstId (base_type_const_id))) {
758+ return PerformTupleAccess (context, loc_id, base_id, member_expr_id);
759+ }
760+
757761 CARBON_DIAGNOSTIC (CompoundMemberAccessDoesNotUseBase, Error,
758762 " member name of type {0} in compound member access is "
759763 " not an instance member or an interface member" ,
0 commit comments