Bug 323726 (MONO81041) - [GMCS] missing CS0019: reject == operator for object vs. generic type argument
Summary: [GMCS] missing CS0019: reject == operator for object vs. generic type argument
Status: RESOLVED FIXED
Alias: MONO81041
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.0
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-05 22:35 UTC by Atsushi Enomoto
Modified: 2008-03-04 09:46 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:30:14 UTC


---- Reported by atsushi@ximian.com 2007-03-05 15:35:31 MST ----

With gmcs, the example below does not cause CS0019 (no applicable ==
operator) error.

--------
public class Test
{
        public static void Main ()
        {
                KVP<string,int> p = new KVP<string,int> ();
                int i;
                p.TryGet ("", out i);
        }
}

public class KVP<K,V>
{
        V vvv;

        public bool TryGet (K k, out V v)
        {
                object tmp = vvv;
                if (tmp == default (V))
                        v = default (V);
                else
                        v = (V) tmp;
                return true;
        }
}
--------

I read ECMA 334 section 14.9.6 (Reference type equality operators) and I
think the below term should apply here:

"Otherwise, if either A or B is a type parameter that is not known to be a
reference type (ยง25.7), then no reference type equality operator is
applicable."


Actual Results:

no error.

Expected Results:

$ csc test.cs -nologo
test.cs(18,7): error CS0019: Operator '==' cannot be applied to operands of
type 'object' and 'V'

How often does this happen? 

consistently.

Additional Information:

The compiled assembly, when executed, causes invalid IL on mono, and
strangely no error on .net ...


Unknown operating system unknown. Setting to default OS "Other".

Comment 2 Marek Safar 2008-03-04 09:46:14 UTC
Fixed in SVN.