Index: src/CodeGen/FixNames.cc
===================================================================
--- src/CodeGen/FixNames.cc	(revision b58559311ba5a4c624d340976b8e3c2df01ecb30)
+++ src/CodeGen/FixNames.cc	(revision 4c48be0244175628306b8fa1224cf2acb1666dab)
@@ -103,14 +103,10 @@
 
 	const ast::FunctionDecl *postvisit( const ast::FunctionDecl *functionDecl ) {
-		// This store is used to ensure a maximum of one call to mutate.
-		ast::FunctionDecl * mutDecl = nullptr;
+		if ( FixMain::isMain( functionDecl ) ) {
+			auto mutDecl = ast::mutate( functionDecl );
 
-		if ( shouldSetScopeLevel( functionDecl ) ) {
-			mutDecl = ast::mutate( functionDecl );
-			mutDecl->scopeLevel = scopeLevel;
-		}
-
-		if ( FixMain::isMain( functionDecl ) ) {
-			if ( !mutDecl ) { mutDecl = ast::mutate( functionDecl ); }
+			if ( shouldSetScopeLevel( mutDecl ) ) {
+				mutDecl->scopeLevel = scopeLevel;
+			}
 
 			int nargs = mutDecl->params.size();
@@ -124,6 +120,11 @@
 				)
 			);
+
+			return mutDecl;
+		} else if ( shouldSetScopeLevel( functionDecl ) ) {
+			return ast::mutate_field( functionDecl, &ast::FunctionDecl::scopeLevel, scopeLevel );
+		} else {
+			return functionDecl;
 		}
-		return mutDecl ? mutDecl : functionDecl;
 	}
 
