[Mono-bugs] [Bug 389282] New: False error message for 'conditional operator' when the immediate type of true_statement is enum and immediate type of false_statement is integer .
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon May 12 06:07:55 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=389282
Summary: False error message for 'conditional operator' when the
immediate type of true_statement is enum and immediate
type of false_statement is integer.
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: 389281
Found By: Other
Mono.CSharp.Conditional
expression ~3587ln
DoResolve method incorrectly treats case when true part of conditional
expression is enum and false part is integer (or vice versa). The compiler
generates error 'Can not compute type of conditional expression' which is
incorrect, it should go on and use enum type.
Proposed fix:
//
// First, if an implicit conversion exists from
true_expr
// to false_expr, then the result type is of
type false_expr.Type
//
conv = Convert.ImplicitConversion (ec,
true_expr, false_type,
loc);
if (conv != null){
//
// Check if both can convert implicitl
to each other's
type
//
if (Convert.ImplicitConversion(ec, false_expr, true_type,
loc) != null)
{
if (false_type.IsEnum)
{
type = false_type;
false_expr = conv;
}
else if (true_type.IsEnum)
{
type = true_type;
true_expr = Convert.ImplicitConversion(ec,
false_expr, true_type, loc);
}
else
{
Error(172,
"Can not compute type of conditional
expression " +
"as `" +
TypeManager.CSharpName(true_expr.Type) +
"' and `" +
TypeManager.CSharpName(false_expr.Type) +
"' convert implicitly to each other");
return null;
}
}
else
{
type = false_type;
true_expr = conv;
}
--
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