Index: src/GenPoly/Specialize.cc
===================================================================
--- src/GenPoly/Specialize.cc	(revision 64eae5636740bd0793ff27432eb02ade2386bec3)
+++ src/GenPoly/Specialize.cc	(revision 1e3d5b661a71dbe22595492bdc80be8525be1611)
@@ -32,4 +32,5 @@
 #include "Common/utility.h"
 #include "InitTweak/InitTweak.h"
+#include "Tuples/Tuples.h"
 
 namespace GenPoly {
@@ -211,16 +212,13 @@
 	// [begin, end) are the formal parameters.
 	// args is the list of arguments currently given to the actual function, the last of which needs to be restructured.
-	template< typename Iterator >
-	void fixLastArg( std::list< Expression * > & args, Iterator begin, Iterator end ) {
-		assertf( ! args.empty(), "Somehow args to tuple function are empty" ); // xxx - it's quite possible this will trigger for the nullary case...
-		Expression * last = args.back();
+	template< typename Iterator, typename OutIterator >
+	void fixLastArg( Expression * last, Iterator begin, Iterator end, OutIterator out ) {
 		// safe_dynamic_cast for the assertion
 		safe_dynamic_cast< TupleType * >( last->get_result() ); // xxx - it's quite possible this will trigger for the unary case...
-		args.pop_back(); // replace last argument in the call with
 		unsigned idx = 0;
 		for ( ; begin != end; ++begin ) {
 			DeclarationWithType * formal = *begin;
 			Type * formalType = formal->get_type();
-			matchOneFormal( last, idx, formalType, back_inserter( args ) );
+			matchOneFormal( last, idx, formalType, out );
 		}
 		delete last;
@@ -251,18 +249,26 @@
 
 		FunctionType * actualType = getFunctionType( actual->get_result() );
-		std::list< DeclarationWithType * >::iterator begin = actualType->get_parameters().begin();
-		std::list< DeclarationWithType * >::iterator end = actualType->get_parameters().end();
-
+		std::list< DeclarationWithType * >::iterator actualBegin = actualType->get_parameters().begin();
+		std::list< DeclarationWithType * >::iterator actualEnd = actualType->get_parameters().end();
+		std::list< DeclarationWithType * >::iterator formalBegin = funType->get_parameters().begin();
+		std::list< DeclarationWithType * >::iterator formalEnd = funType->get_parameters().end();
+
+		Expression * last = nullptr;
 		for ( DeclarationWithType* param : thunkFunc->get_functionType()->get_parameters() ) {
 			// walk the parameters to the actual function alongside the parameters to the thunk to find the location where the ttype parameter begins to satisfy parameters in the actual function.
-			assert( begin != end );
-			++begin;
-
-			// std::cerr << "thunk param: " << param << std::endl;
-			// last param will always be a tuple type... expand it into the actual type(?)
 			param->set_name( paramNamer.newName() );
+			assertf( formalBegin != formalEnd, "Reached end of formal parameters before finding ttype parameter" );
+			if ( Tuples::isTtype((*formalBegin)->get_type()) ) {
+				last = new VariableExpr( param );
+				break;
+			}
+			assertf( actualBegin != actualEnd, "reached end of actual function's arguments before finding ttype parameter" );
+			++actualBegin;
+			++formalBegin;
+
 			appExpr->get_args().push_back( new VariableExpr( param ) );
 		} // for
-		fixLastArg( appExpr->get_args(), --begin, end );
+		assert( last );
+		fixLastArg( last, actualBegin, actualEnd, back_inserter( appExpr->get_args() ) );
 		appExpr->set_env( maybeClone( env ) );
 		if ( inferParams ) {
