Index: src/ResolvExpr/Unify.cc
===================================================================
--- src/ResolvExpr/Unify.cc	(revision 4a6048888d2c5b87f57f18dd27293dda6de1a8d8)
+++ src/ResolvExpr/Unify.cc	(revision 90ce35aa119e12338697fb8d71481c558a92bdef)
@@ -933,9 +933,11 @@
 
 	private:
-		template< typename RefType >
-		const RefType * handleRefType( const RefType * inst, const ast::Type * other ) {
+		// Returns: other, cast as XInstType
+		// Assigns this->result: whether types are compatible (up to generic parameters)
+		template< typename XInstType >
+		const XInstType * handleRefType( const XInstType * inst, const ast::Type * other ) {
 			// check that the other type is compatible and named the same
-			auto otherInst = dynamic_cast< const RefType * >( other );
-			result = otherInst && inst->name == otherInst->name;
+			auto otherInst = dynamic_cast< const XInstType * >( other );
+			this->result = otherInst && inst->name == otherInst->name;
 			return otherInst;
 		}
@@ -958,13 +960,13 @@
 		}
 
-		template< typename RefType >
-		void handleGenericRefType( const RefType * inst, const ast::Type * other ) {
+		template< typename XInstType >
+		void handleGenericRefType( const XInstType * inst, const ast::Type * other ) {
 			// check that other type is compatible and named the same
-			const RefType * inst2 = handleRefType( inst, other );
-			if ( ! inst2 ) return;
+			const XInstType * otherInst = handleRefType( inst, other );
+			if ( ! this->result ) return;
 
 			// check that parameters of types unify, if any
 			const std::vector< ast::ptr< ast::Expr > > & params = inst->params;
-			const std::vector< ast::ptr< ast::Expr > > & params2 = inst2->params;
+			const std::vector< ast::ptr< ast::Expr > > & params2 = otherInst->params;
 
 			auto it = params.begin();
