Index: src/ControlStruct/TranslateEnumRange.cpp
===================================================================
--- src/ControlStruct/TranslateEnumRange.cpp	(revision 9739c56f411136a534d22d2b41c343f9a4d7a7b5)
+++ src/ControlStruct/TranslateEnumRange.cpp	(revision 7a0e8c847d322ed60a768012cb7e370a79730488)
@@ -9,30 +9,25 @@
 
 struct TranslateEnumRangeCore {
-	const ast::Stmt * postvisit( const ast::ForStmt * stmt );
+	const ast::Stmt * postvisit( const ast::ForeachStmt * stmt );
 };
 
-const ast::Stmt * TranslateEnumRangeCore::postvisit( const ast::ForStmt * stmt ) {
-	if ( !stmt->range_over ) return stmt;
-	auto mutStmt = ast::mutate( stmt );
-	auto & location = mutStmt->location;
+const ast::Stmt * TranslateEnumRangeCore::postvisit( const ast::ForeachStmt * stmt ) {
+	auto & location = stmt->location;
 
-	if ( auto declStmt = mutStmt->inits.front().as<ast::DeclStmt>() ) {
-		if ( auto objDecl = declStmt->decl.as<ast::ObjectDecl>() ) {
-			if ( !objDecl->init ) {
-				ast::SingleInit * newInit = new ast::SingleInit( location,
-					ast::UntypedExpr::createCall( location,
-						mutStmt->is_inc ? "lowerBound" : "upperBound", {} ),
-					ast::ConstructFlag::MaybeConstruct
-				);
-				auto objDeclWithInit = ast::mutate_field( objDecl, &ast::ObjectDecl::init, newInit );
-				auto declWithInit = ast::mutate_field( declStmt, &ast::DeclStmt::decl, objDeclWithInit );
-				mutStmt->inits[0] = declWithInit;
-			}
-		}
+	assert( stmt->inits.size() == 1 );
+	ast::DeclStmt const * initialize = stmt->inits.front().strict_as<ast::DeclStmt>();
+
+	auto objDecl = initialize->decl.strict_as<ast::ObjectDecl>();
+	if ( !objDecl->init ) {
+		ast::SingleInit * init = new ast::SingleInit( location,
+			ast::UntypedExpr::createCall( location,
+				stmt->isIncreasing ? "lowerBound" : "upperBound", {} ),
+			ast::ConstructFlag::MaybeConstruct
+		);
+		objDecl = ast::mutate_field( objDecl, &ast::ObjectDecl::init, init );
+		initialize = ast::mutate_field( initialize, &ast::DeclStmt::decl, objDecl );
 	}
 
-	auto declStmt = mutStmt->inits.front().strict_as<ast::DeclStmt>();
-	auto initDecl = declStmt->decl.strict_as<ast::ObjectDecl>();
-	auto indexName = initDecl->name;
+	auto indexName = objDecl->name;
 
 	// Both inc and dec check if the current posn less than the number of enumerator
@@ -40,18 +35,25 @@
 	// it wraps around and become unsigned max
 	ast::UntypedExpr * condition = ast::UntypedExpr::createCall( location,
-		mutStmt->is_inc ? "?<=?" : "?>=?",
+		stmt->isIncreasing ? "?<=?" : "?>=?",
 		{
 			new ast::NameExpr( location, indexName ),
 			ast::UntypedExpr::createCall( location,
-				mutStmt->is_inc ? "upperBound" : "lowerBound", {} )
+				stmt->isIncreasing ? "upperBound" : "lowerBound", {} )
 		} );
-	auto increment = ast::UntypedExpr::createCall( location,
-		mutStmt->is_inc ? "succ_unsafe" : "pred_unsafe",
-		{ new ast::NameExpr( location, indexName ) } );
-	auto assig = ast::UntypedExpr::createAssign( location,
-		new ast::NameExpr( location, indexName ), increment );
-	mutStmt->cond = condition;
-	mutStmt->inc = assig;
-	return mutStmt;
+	ast::UntypedExpr * increment = ast::UntypedExpr::createAssign( location,
+		new ast::NameExpr( location, indexName ),
+		ast::UntypedExpr::createCall( location,
+			stmt->isIncreasing ? "succ_unsafe" : "pred_unsafe",
+			{ new ast::NameExpr( location, indexName ) } ) );
+
+	return new ast::ForStmt(
+		stmt->location,
+		{ initialize },
+		condition,
+		increment,
+		stmt->body,
+		stmt->else_,
+		copy( stmt->labels )
+	);
 }
 
