Index: src/Tuples/TupleExpansionNew.cpp
===================================================================
--- src/Tuples/TupleExpansionNew.cpp	(revision d249e0b8f6a9cbbf047dc0d3fb6341c08fc8afbe)
+++ src/Tuples/TupleExpansionNew.cpp	(revision d249e0b8f6a9cbbf047dc0d3fb6341c08fc8afbe)
@@ -0,0 +1,68 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// TupleExpansionNew.cpp --
+//
+// Author           : Henry Xue
+// Created On       : Mon Aug 23 15:36:09 2021
+// Last Modified By : Henry Xue
+// Last Modified On : Mon Aug 23 15:36:09 2021
+// Update Count     : 1
+//
+
+#include "Tuples.h"
+
+namespace Tuples {
+namespace {
+	struct MemberTupleExpander final : public ast::WithShortCircuiting, public ast::WithVisitorRef< MemberTupleExpander > {
+		void previsit( const ast::UntypedMemberExpr * ) { visit_children = false; }
+        const ast::Expr * postvisit( const ast::UntypedMemberExpr * memberExpr );
+	};
+} // namespace
+
+void expandMemberTuples( ast::TranslationUnit & translationUnit ) {
+	ast::Pass< MemberTupleExpander >::run( translationUnit );
+}
+
+namespace {
+	namespace {
+		/// given a expression representing the member and an expression representing the aggregate,
+		/// reconstructs a flattened UntypedMemberExpr with the right precedence
+		const ast::Expr * reconstructMemberExpr( const ast::Expr * member, const ast::Expr * aggr, const CodeLocation & loc ) {
+			if ( auto memberExpr = dynamic_cast< const ast::UntypedMemberExpr * >( member ) ) {
+				// construct a new UntypedMemberExpr with the correct structure , and recursively
+				// expand that member expression.
+				ast::Pass< MemberTupleExpander > expander;
+				auto inner = new ast::UntypedMemberExpr( loc, memberExpr->aggregate, aggr );
+				auto newMemberExpr = new ast::UntypedMemberExpr( loc, memberExpr->member, inner );
+				//delete memberExpr;
+				return newMemberExpr->accept( expander );
+			} else {
+				// not a member expression, so there is nothing to do but attach and return
+				return new ast::UntypedMemberExpr( loc, member, aggr );
+			}
+		}
+	}
+
+	const ast::Expr * MemberTupleExpander::postvisit( const ast::UntypedMemberExpr * memberExpr ) {
+		const CodeLocation loc = memberExpr->location;
+        if ( auto tupleExpr = memberExpr->member.as< ast::UntypedTupleExpr >() ) {
+			auto mutExpr = mutate( tupleExpr );
+			ast::ptr< ast::Expr > aggr = memberExpr->aggregate->accept( *visitor );
+			// aggregate expressions which might be impure must be wrapped in unique expressions
+			if ( Tuples::maybeImpureIgnoreUnique( memberExpr->aggregate ) ) aggr = new ast::UniqueExpr( loc, aggr );
+			for ( auto & expr : mutExpr->exprs ) {
+				expr = reconstructMemberExpr( expr, aggr, loc );
+			}
+			//delete aggr;
+			return mutExpr;
+		} else {
+			// there may be a tuple expr buried in the aggregate
+			return new ast::UntypedMemberExpr( loc, memberExpr->member, memberExpr->aggregate->accept( *visitor ) );
+		}
+	}
+} // namespace
+} // namespace Tuples
Index: src/Tuples/Tuples.h
===================================================================
--- src/Tuples/Tuples.h	(revision 3e5dd91354f39b161547cc1119ecef5890aa765f)
+++ src/Tuples/Tuples.h	(revision d249e0b8f6a9cbbf047dc0d3fb6341c08fc8afbe)
@@ -9,7 +9,7 @@
 // Author           : Rodolfo G. Esteves
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Tue Jun 18 09:36:00 2019
-// Update Count     : 18
+// Last Modified By : Henry Xue
+// Last Modified On : Mon Aug 23 15:36:09 2021
+// Update Count     : 19
 //
 
@@ -39,4 +39,5 @@
 	/// expands z.[a, b.[x, y], c] into [z.a, z.b.x, z.b.y, z.c], inserting UniqueExprs as appropriate
 	void expandMemberTuples( std::list< Declaration * > & translationUnit );
+	void expandMemberTuples( ast::TranslationUnit & translationUnit );
 
 	/// replaces tuple-related elements, such as TupleType, TupleExpr, TupleAssignExpr, etc.
Index: src/Tuples/module.mk
===================================================================
--- src/Tuples/module.mk	(revision 3e5dd91354f39b161547cc1119ecef5890aa765f)
+++ src/Tuples/module.mk	(revision d249e0b8f6a9cbbf047dc0d3fb6341c08fc8afbe)
@@ -10,7 +10,7 @@
 ## Author           : Richard C. Bilson
 ## Created On       : Mon Jun  1 17:49:17 2015
-## Last Modified By : Peter A. Buhr
-## Last Modified On : Mon Jun  1 17:54:33 2015
-## Update Count     : 1
+## Last Modified By : Henry Xue
+## Last Modified On : Mon Aug 23 15:36:09 2021
+## Update Count     : 2
 ###############################################################################
 
@@ -20,4 +20,5 @@
 	Tuples/TupleAssignment.cc \
 	Tuples/TupleExpansion.cc \
+	Tuples/TupleExpansionNew.cpp \
 	Tuples/Tuples.cc \
 	Tuples/Tuples.h
