operator-{sum,prod}.go: Fixed sum and prod operation with a fraction and a float
This commit is contained in:
+3
-3
@@ -86,9 +86,11 @@ func evalMinus(ctx ExprContext, self *term) (v any, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
if isNumber(leftValue) && isNumber(rightValue) {
|
||||
if isNumOrFract(leftValue) && isNumOrFract(rightValue) {
|
||||
if isFloat(leftValue) || isFloat(rightValue) {
|
||||
v = numAsFloat(leftValue) - numAsFloat(rightValue)
|
||||
} else if isFraction(leftValue) || isFraction(rightValue) {
|
||||
v, err = subAnyFract(leftValue, rightValue)
|
||||
} else {
|
||||
leftInt, _ := leftValue.(int64)
|
||||
rightInt, _ := rightValue.(int64)
|
||||
@@ -104,8 +106,6 @@ func evalMinus(ctx ExprContext, self *term) (v any, err error) {
|
||||
}
|
||||
}
|
||||
v = &diffList
|
||||
} else if isFraction(leftValue) || isFraction(rightValue) {
|
||||
v, err = subAnyFract(leftValue, rightValue)
|
||||
} else {
|
||||
err = self.errIncompatibleTypes(leftValue, rightValue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user