Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision e6cee92975ba3e912a537934e3a775bcddc7a9fa)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision 9a34b5af88e34afea5a43c4d02c330da9e0defc6)
@@ -213,13 +213,19 @@
 	void AlternativeFinder::addAnonConversions( const Alternative & alt ) {
 		// adds anonymous member interpretations whenever an aggregate value type is seen.
-		Expression * expr = alt.expr->clone();
-		std::unique_ptr< Expression > manager( expr ); // RAII for expr
-		alt.env.apply( expr->get_result() );
-		if ( StructInstType *structInst = dynamic_cast< StructInstType* >( expr->get_result() ) ) {
+		// it's okay for the aggregate expression to have reference type -- cast it to the base type to treat the aggregate as the referenced value
+		std::unique_ptr<Expression> aggrExpr( alt.expr->clone() );
+		alt.env.apply( aggrExpr->get_result() );
+		Type * aggrType = aggrExpr->get_result();
+		if ( dynamic_cast< ReferenceType * >( aggrType ) ) {
+			aggrType = aggrType->stripReferences();
+			aggrExpr.reset( new CastExpr( aggrExpr.release(), aggrType->clone() ) );
+		}
+
+		if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
 			NameExpr nameExpr( "" );
-			addAggMembers( structInst, expr, alt.cost+Cost::safe, alt.env, &nameExpr );
-		} else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( expr->get_result() ) ) {
+			addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
+		} else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->get_result() ) ) {
 			NameExpr nameExpr( "" );
-			addAggMembers( unionInst, expr, alt.cost+Cost::safe, alt.env, &nameExpr );
+			addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
 		} // if
 	}
@@ -412,4 +418,5 @@
 			)
 			if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) {
+				// std::cerr << "unify failed" << std::endl;
 				return false;
 			}
@@ -895,5 +902,4 @@
 				aggrExpr.reset( new CastExpr( aggrExpr.release(), aggrType->clone() ) );
 			}
-
 			// find member of the given type
 			if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
