Bugzilla – Bug 323726
[GMCS] missing CS0019: reject == operator for object vs. generic type argument
Last modified: 2008-03-04 09:46: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".
Fixed in SVN.