utils.go: toInt() -> ToInt(); toBool() -> ToBool()

This commit is contained in:
2024-06-10 19:03:39 +02:00
parent 0bb4c96481
commit 9745a5d909
8 changed files with 24 additions and 24 deletions
+9 -9
View File
@@ -25,7 +25,7 @@ func evalNot(ctx ExprContext, self *term) (v any, err error) {
return
}
if b, ok := toBool(rightValue); ok {
if b, ok := ToBool(rightValue); ok {
v = !b
} else {
err = self.errIncompatibleType(rightValue)
@@ -65,8 +65,8 @@ func evalAndWithoutShortcut(ctx ExprContext, self *term) (v any, err error) {
return
}
leftBool, lok = toBool(leftValue)
rightBool, rok = toBool(rightValue)
leftBool, lok = ToBool(leftValue)
rightBool, rok = ToBool(rightValue)
if lok && rok {
v = leftBool && rightBool
@@ -87,13 +87,13 @@ func evalAndWithShortcut(ctx ExprContext, self *term) (v any, err error) {
return
}
if leftBool, lok := toBool(leftValue); !lok {
if leftBool, lok := ToBool(leftValue); !lok {
err = fmt.Errorf("got %T as left operand type of 'and' operator, it must be bool", leftBool)
return
} else if !leftBool {
v = false
} else if rightValue, err = self.children[1].compute(ctx); err == nil {
if rightBool, rok := toBool(rightValue); rok {
if rightBool, rok := ToBool(rightValue); rok {
v = rightBool
} else {
err = self.errIncompatibleTypes(leftValue, rightValue)
@@ -134,8 +134,8 @@ func evalOrWithoutShortcut(ctx ExprContext, self *term) (v any, err error) {
return
}
leftBool, lok = toBool(leftValue)
rightBool, rok = toBool(rightValue)
leftBool, lok = ToBool(leftValue)
rightBool, rok = ToBool(rightValue)
if lok && rok {
v = leftBool || rightBool
@@ -156,13 +156,13 @@ func evalOrWithShortcut(ctx ExprContext, self *term) (v any, err error) {
return
}
if leftBool, lok := toBool(leftValue); !lok {
if leftBool, lok := ToBool(leftValue); !lok {
err = fmt.Errorf("got %T as left operand type of 'or' operator, it must be bool", leftBool)
return
} else if leftBool {
v = true
} else if rightValue, err = self.children[1].compute(ctx); err == nil {
if rightBool, rok := toBool(rightValue); rok {
if rightBool, rok := ToBool(rightValue); rok {
v = rightBool
} else {
err = self.errIncompatibleTypes(leftValue, rightValue)