1
Vote

Bug in DefaultBinder building comparison rules

description

There appears to be a copy/paste bug in DefaultBinder.Operations.cs in MakeComparisonRule:
 
    private DynamicMetaObject MakeComparisonRule(OperatorInfo info, OverloadResolverFactory resolverFactory, DynamicMetaObject[] args) {
        return
            TryComparisonMethod(info, resolverFactory, args[0], args) ??   // check the first type if it has an applicable method
            TryComparisonMethod(info, resolverFactory, args[0], args) ??   // then check the second type
            TryNumericComparison(info, resolverFactory, args) ??           // try Compare: cmp(x,y) (>, <, >=, <=, ==, !=) 0
            TryInvertedComparison(info, resolverFactory, args[0], args) ?? // try inverting the operator & result (e.g. if looking for Equals try NotEquals, LessThan for GreaterThan)...
            TryInvertedComparison(info, resolverFactory, args[0], args) ?? // inverted binding on the 2nd type
            TryNullComparisonRule(args) ??                // see if we're comparing to null w/ an object ref or a Nullable<T>
            TryPrimitiveCompare(info, args) ??            // see if this is a primitive type where we're comparing the two values.
            MakeOperatorError(info, args);                // no comparisons are possible            
    }
 
The lines that are commented as working on the second type are still using index 0 instead of 1, so it's just duplicating operations on the first arg type.

comments