Index: src/AST/SymbolTable.cpp
===================================================================
--- src/AST/SymbolTable.cpp	(revision 76b507d24aba8184d760ef5fb795294bcdca3103)
+++ src/AST/SymbolTable.cpp	(revision a1a1f37d7d17459fbc460ce2bf20161d668d4835)
@@ -419,14 +419,32 @@
 void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt ) {
 	for ( const Expr * expr : withExprs ) {
-		if ( ! expr->result ) continue;
-		const Type * resTy = expr->result->stripReferences();
-		auto aggrType = dynamic_cast< const BaseInstType * >( resTy );
-		assertf( aggrType, "WithStmt expr has non-aggregate type: %s",
-			toString( expr->result ).c_str() );
-		const AggregateDecl * aggr = aggrType->aggr();
-		assertf( aggr, "WithStmt has null aggregate from type: %s",
-			toString( expr->result ).c_str() );
-
-		addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
+		if ( expr->result ) {
+			const Type * resTy = expr->result->stripReferences();
+			auto aggrType = dynamic_cast< const BaseInstType * >( resTy );
+			assertf( aggrType, "WithStmt expr has non-aggregate type: %s",
+				toString( expr->result ).c_str() );
+			const AggregateDecl * aggr = aggrType->aggr();
+			assertf( aggr, "WithStmt has null aggregate from type: %s",
+				toString( expr->result ).c_str() );
+
+			addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
+		} else {
+			auto typeExpr = dynamic_cast< const ast::TypeExpr *>( expr );
+			if ( !typeExpr ) continue;
+			auto declEnumInst = typeExpr->type.as<ast::EnumInstType>();
+			// assertf( declEnumInst,  "WithStmt expr unsupprot type expression: %s",
+			// 	toString( typeExpr->type ).c_str());
+			if ( !declEnumInst ) continue;
+			
+			const EnumDecl * aggr = declEnumInst->aggr();
+			// assertf( aggr, "WithStmt has null aggregate from type: %s",
+			// 	toString( typeExpr ).c_str() );
+			// addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
+			if ( !aggr ) {
+				aggr = lookupEnum( declEnumInst->name );
+				assert( aggr );
+			}
+			addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) );
+		}
 	}
 }
@@ -800,5 +818,6 @@
 		if ( auto rty = dynamic_cast<const BaseInstType *>( t ) ) {
 			if ( ! dynamic_cast<const StructInstType *>(rty)
-				&& ! dynamic_cast<const UnionInstType *>(rty) ) continue;
+				&& ! dynamic_cast<const UnionInstType *>(rty)
+				&& ! dynamic_cast<const EnumInstType *>(rty) ) continue;
 			ResolvExpr::Cost cost = ResolvExpr::Cost::zero;
 			ast::ptr<ast::TypeSubstitution> tmp = expr->env;
Index: src/ResolvExpr/Resolver.cpp
===================================================================
--- src/ResolvExpr/Resolver.cpp	(revision 76b507d24aba8184d760ef5fb795294bcdca3103)
+++ src/ResolvExpr/Resolver.cpp	(revision a1a1f37d7d17459fbc460ce2bf20161d668d4835)
@@ -322,7 +322,7 @@
 
 namespace {
-	bool structOrUnion( const Candidate & i ) {
+	bool structOrUnionOrEnum( const Candidate & i ) {
 		const ast::Type * t = i.expr->result->stripReferences();
-		return dynamic_cast< const ast::StructInstType * >( t ) || dynamic_cast< const ast::UnionInstType * >( t );
+		return dynamic_cast< const ast::StructInstType * >( t ) || dynamic_cast< const ast::UnionInstType * >( t ) || dynamic_cast< const ast::EnumInstType * >( t );
 	}
 	/// Predicate for "Candidate has integral type"
@@ -1140,5 +1140,5 @@
 	for (auto & expr : exprs) {
 		// only struct- and union-typed expressions are viable candidates
-		expr = findKindExpression( expr, context, structOrUnion, "with expression" );
+		expr = findKindExpression( expr, context, structOrUnionOrEnum, "with expression" );
 
 		// if with expression might be impure, create a temporary so that it is evaluated once
Index: src/Validate/GenericParameter.cpp
===================================================================
--- src/Validate/GenericParameter.cpp	(revision 76b507d24aba8184d760ef5fb795294bcdca3103)
+++ src/Validate/GenericParameter.cpp	(revision a1a1f37d7d17459fbc460ce2bf20161d668d4835)
@@ -301,8 +301,8 @@
 const ast::Expr * TranslateDimensionCore::postvisit(
 		const ast::TypeExpr * expr ) {
-	if ( auto instType = dynamic_cast<const ast::EnumInstType *>( expr->type.get() ) ) {
-		const ast::EnumDecl * baseEnum = instType->base.get();
-		return ast::ConstantExpr::from_int( expr->location, baseEnum->members.size() );
-	}
+	// if ( auto instType = dynamic_cast<const ast::EnumInstType *>( expr->type.get() ) ) {
+	// 	const ast::EnumDecl * baseEnum = instType->base.get();
+	// 	return ast::ConstantExpr::from_int( expr->location, baseEnum->members.size() );
+	// }
 	return expr;
 }
