https://bugzilla.novell.com/show_bug.cgi?id=389281
Summary: Compiler generates false error when code compares enums
with zero
Product: Mono: Compilers
Version: 1.9.0
Platform: x86
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
Depends on: 389280
Found By: Other
Mono.CSharp.Binary
expression ~line 2334
Comparing Enums with 0 is always valid. But the compiler generates false error
message.
Proposed fix is to add explicit check for enum and integer zero
if (oper == Operator.Equality || oper ==
Operator.Inequality ||
oper == Operator.LessThanOrEqual || oper ==
Operator.LessThan ||
oper == Operator.GreaterThanOrEqual || oper
== Operator.GreaterThan){
if (left.Type != right.Type){
if ((left.Type.IsEnum && (right is IntLiteral) &&
((IntLiteral)right).Value == 0)
||
(right.Type.IsEnum && (left is IntLiteral) &&
((IntLiteral)left).Value == 0))
{
// all righty
}
else
{
Error_OperatorCannotBeApplied ();
}
return null;
}
type = TypeManager.bool_type;
return this;
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs