Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision 5a4b403b947569895beb89ab24ba0dbbe2bb77ff)
+++ src/GenPoly/Box.cc	(revision 474a170607306d8a8de9d85a373aa6a5efa1554f)
@@ -95,5 +95,5 @@
 			/// Pass the extra type parameters from polymorphic generic arguments or return types into a function application
 			/// Will insert 0, 2 or 3 more arguments.
-			void passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes );
+			std::list< Expression *>::iterator passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes );
 			/// passes extra type parameters into a polymorphic function application
 			/// Returns an iterator to the first argument after the added
@@ -531,9 +531,9 @@
 		}
 
-		void Pass1::passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes ) {
+		std::list< Expression *>::iterator Pass1::passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes ) {
 			Type *polyType = isPolyType( parmType, exprTyVars );
 			if ( polyType && ! dynamic_cast< TypeInstType* >( polyType ) ) {
 				std::string typeName = mangleType( polyType );
-				if ( seenTypes.count( typeName ) ) return;
+				if ( seenTypes.count( typeName ) ) return arg;
 
 				arg = appExpr->get_args().insert( arg, new SizeofExpr( argBaseType->clone() ) );
@@ -555,4 +555,5 @@
 				seenTypes.insert( typeName );
 			}
+			return arg;
 		}
 
@@ -593,5 +594,5 @@
 			if ( polyRetType ) {
 				Type *concRetType = replaceWithConcrete( polyRetType, env );
-				passArgTypeVars( appExpr, polyRetType, concRetType, arg, exprTyVars, seenTypes );
+				arg = passArgTypeVars( appExpr, polyRetType, concRetType, arg, exprTyVars, seenTypes );
 				// Skip the return parameter in the argument list.
 				fnArg = arg + 1;
@@ -605,5 +606,5 @@
 				Type * argType = (*fnArg)->get_result();
 				if ( ! argType ) continue;
-				passArgTypeVars( appExpr, (*fnParm)->get_type(), argType, arg, exprTyVars, seenTypes );
+				arg = passArgTypeVars( appExpr, (*fnParm)->get_type(), argType, arg, exprTyVars, seenTypes );
 			}
 			return arg;
