Index: src/Common/PassVisitor.h
===================================================================
--- src/Common/PassVisitor.h	(revision 5013c6217fe0f734f8039e894f6459db7e0d6d38)
+++ src/Common/PassVisitor.h	(revision 3fb9a83871b00e72feca47d02062581a9d40610d)
@@ -218,4 +218,6 @@
 	void call_endScope  () { end_scope_impl  ( pass, 0 ); }
 
+	void set_env( TypeSubstitution * env ) { set_env_impl( pass, env, 0); }
+
 	void mutateStatementList( std::list< Statement* > &statements );
 	Statement * mutateStatement( Statement * stmt );
Index: src/Common/PassVisitor.impl.h
===================================================================
--- src/Common/PassVisitor.impl.h	(revision 5013c6217fe0f734f8039e894f6459db7e0d6d38)
+++ src/Common/PassVisitor.impl.h	(revision 3fb9a83871b00e72feca47d02062581a9d40610d)
@@ -51,4 +51,6 @@
 	ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter );
 	ValueGuard< TypeSubstitution * > oldEnv( env );
+	set_env( env );
+
 	stmtsToAdd.clear();
 	stmtsToAddAfter.clear();
@@ -73,4 +75,5 @@
 	if ( expr->get_env() ) {
 		env = expr->get_env();
+		set_env( env );
 	}
 	// xxx - should env be cloned (or moved) onto the result of the mutate?
@@ -488,4 +491,5 @@
 	ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter );
 	ValueGuard< TypeSubstitution * > oldEnv( env );
+	set_env( env );
 
 	// xxx - not sure if this is needed, along with appropriate reset, but I don't think so...
Index: src/Common/PassVisitor.proto.h
===================================================================
--- src/Common/PassVisitor.proto.h	(revision 5013c6217fe0f734f8039e894f6459db7e0d6d38)
+++ src/Common/PassVisitor.proto.h	(revision 3fb9a83871b00e72feca47d02062581a9d40610d)
@@ -69,2 +69,11 @@
 template<typename pass_type>
 static inline void end_scope_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) long unused ) {}
+
+// Env
+template<typename pass_type>
+static inline auto set_env_impl( pass_type& pass, TypeSubstitution * env, __attribute__((unused)) int unused ) ->decltype( pass.env, void() ) {
+	pass.env = env;
+}
+
+template<typename pass_type>
+static inline void set_env_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) TypeSubstitution * env, __attribute__((unused)) long unused ) {}
