[Mono-bugs] [Bug 389281] New: Compiler generates false error when code compares enums with zero
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon May 12 06:05:44 EDT 2008
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: mono-bugs at lists.ximian.com
ReportedBy: mihailik at gmail.com
QAContact: mono-bugs at lists.ximian.com
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.
More information about the mono-bugs
mailing list