DavidArno / SuccincT

Discriminated unions, pattern matching and partial applications for C#
MIT License
266 stars 15 forks source link

Union<T1, T2> comparisons are broken #1

Closed DavidArno closed 9 years ago

DavidArno commented 9 years ago

Comparing two Union<int, string>, where one is an int and the other is a string can result in equality being incorrectly reported, as exhibited via this code snippet:

var a = new Union<int, string>(0);
var b = new Union<int, string>("1234");
Assert.IsFalse(a.Equals(b));

The problem is that Union<int, string>("1234") will internally store the default value (0) for the int value and so the two match.