Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision c28a038d643e82580facb0e038d69d9bfca11e42)
+++ src/ResolvExpr/Resolver.cc	(revision 60914351ad58d1338a7f0f9215f04d28bdc2c624)
@@ -271,5 +271,15 @@
 		functionDecl->set_type( new_type );
 		GuardValue( functionReturn );
-		functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
+		functionReturn = ResolvExpr::extractResultType( functionDecl->type );
+
+		{
+			// resolve with-exprs with parameters in scope and add any newly generated declarations to the
+			// front of the function body.
+			auto guard = makeFuncGuard( [this]() { indexer.enterScope(); }, [this](){ indexer.leaveScope(); } );
+			indexer.addFunctionType( functionDecl->type );
+			std::list< Statement * > newStmts;
+			resolveWithExprs( functionDecl->withExprs, newStmts );
+			functionDecl->statements->kids.splice( functionDecl->statements->kids.begin(), newStmts );
+		}
 	}
 
