@@ -731,11 +731,23 @@ public TranslatedExpression ConvertToBoolean(ExpressionBuilder expressionBuilder
731731 . WithRR ( new OperatorResolveResult ( boolType , System . Linq . Expressions . ExpressionType . NotEqual ,
732732 this . ResolveResult , nullRef . ResolveResult ) ) ;
733733 }
734- else
734+ else if ( Type . Kind == TypeKind . Enum && Type . GetDefinition ( ) is { } typeDef &&
735+ typeDef . Fields . Any ( f => f . GetConstantValue ( ) is { } val && ( ulong ) CSharpPrimitiveCast . Cast ( TypeCode . UInt64 , val , false ) == 0L ) )
735736 {
736737 var zero = expressionBuilder
737738 . ConvertConstantValue ( new ConstantResolveResult ( Type , 0 ) , allowImplicitConversion : true ) ;
738739 var op = negate ? BinaryOperatorType . Equality : BinaryOperatorType . InEquality ;
740+ return new BinaryOperatorExpression ( Expression , op , zero . Expression )
741+ . WithoutILInstruction ( )
742+ . WithRR ( new OperatorResolveResult ( boolType , System . Linq . Expressions . ExpressionType . NotEqual ,
743+ this . ResolveResult , zero . ResolveResult ) ) ;
744+ }
745+ else
746+ {
747+ var zero = new PrimitiveExpression ( 0 )
748+ . WithoutILInstruction ( )
749+ . WithRR ( new ConstantResolveResult ( expressionBuilder . compilation . FindType ( KnownTypeCode . Int32 ) , 0 ) ) ;
750+ var op = negate ? BinaryOperatorType . Equality : BinaryOperatorType . InEquality ;
739751 return new BinaryOperatorExpression ( Expression , op , zero . Expression )
740752 . WithoutILInstruction ( )
741753 . WithRR ( new OperatorResolveResult ( boolType , System . Linq . Expressions . ExpressionType . NotEqual ,
0 commit comments