1
Vote

roslyn error-code -2146232797 / maybe something with changed "Overload resolution"

description

Following C# Code can't be compiled with roslyn - why?
With previews compiler versions, this works fine.

console-program:
class Program
{
    static void Main(string[] args)
    {
        Number n = 5.0m;
        decimal? d = 3.3m;
        d = n + d;
        d = d + n;
        d += n;   // this line crashes roslyn with: "csc.exe" exited with code -2146232797 
    }

    public struct Number
    {
        public decimal Value;

        public Number(decimal x)
        {
            Value = x;
        }


        public static implicit operator decimal (Number x)
        {
            return x.Value;
        }

        public static implicit operator Number(decimal x)
        {
            return new Number(x);
        }

        public static Number operator +(Number x, Number y)
        {
            return new Number(Decimal.Add(x.Value, y.Value));
        }

        public static Number operator +(decimal x, Number y)
        {
            return new Number(Decimal.Add(x, y.Value));
        }

        public static Number operator +(Number x, decimal y)
        {
            return new Number(Decimal.Add(x.Value, y));
        }
    }
}
Maybe the problem comes from the the changed behavior of overload resolution:
http://blog.slaks.net/2014-05-28/exploring-roslyn-part-3-breaking-changes/