Index: src/CodeTools/ResolvProtoDump.cc
===================================================================
--- src/CodeTools/ResolvProtoDump.cc	(revision b1816398335b62df41235fdacb00551553884eb0)
+++ src/CodeTools/ResolvProtoDump.cc	(revision 40cd873d81d1e7979f1ab87d5c95a9cb89059a09)
@@ -23,4 +23,5 @@
 #include <string>
 #include <unordered_set>
+#include <utility>
 #include <vector>
 
@@ -36,8 +37,8 @@
 	/// Visitor for dumping resolver prototype output
 	class ProtoDump : public WithShortCircuiting, public WithVisitorRef<ProtoDump> {
-		std::set<std::string> decls;               ///< Declarations in this scope
-		std::vector<std::string> exprs;            ///< Expressions in this scope
-		std::vector<PassVisitor<ProtoDump>> subs;  ///< Sub-scopes
-		const ProtoDump* parent;                   ///< Outer lexical scope
+		std::set<std::string> decls;     ///< Declarations in this scope
+		std::vector<std::string> exprs;  ///< Expressions in this scope
+		std::vector<ProtoDump> subs;     ///< Sub-scopes
+		const ProtoDump* parent;         ///< Outer lexical scope
 
 	public:
@@ -46,5 +47,5 @@
 
 		/// Child constructor
-		ProtoDump(const ProtoDump& p) : decls(), exprs(), subs(), parent(&p) {}
+		ProtoDump(const ProtoDump* p) : decls(), exprs(), subs(), parent(p) {}
 
 	private:
@@ -67,7 +68,6 @@
 
 		/// adds a new subscope to this scope, returning a reference
-		PassVisitor<ProtoDump>& addSub() {
-			subs.emplace_back( *this );
-			return subs.back();
+		void addSub( PassVisitor<ProtoDump>&& sub ) {
+			subs.emplace_back( std::move(sub.pass) );
 		}
 	
@@ -517,5 +517,5 @@
 			// add body if available
 			if ( decl->statements ) {
-				PassVisitor<ProtoDump>& body = addSub();
+				PassVisitor<ProtoDump> body{ this };
 				
 				// add named parameters and returns to local scope
@@ -529,4 +529,7 @@
 				// add contents of function to new scope
 				decl->statements->accept( body );
+
+				// store sub-scope
+				addSub( std::move(body) );
 			}
 
