From 7164e8816c288a34fcb52e03ae9b6bb275193760 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Wed, 26 Jun 2024 04:28:53 +0200 Subject: [PATCH] operator-bool.go: error messages improved --- operator-bool.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/operator-bool.go b/operator-bool.go index fd37cd4..3a70f5e 100644 --- a/operator-bool.go +++ b/operator-bool.go @@ -37,9 +37,7 @@ func evalNot(ctx ExprContext, self *term) (v any, err error) { func newAndTerm(tk *Token) (inst *term) { return &term{ - tk: *tk, - // class: classOperator, - // kind: kindBool, + tk: *tk, children: make([]*term, 0, 2), position: posInfix, priority: priAnd, @@ -88,7 +86,7 @@ func evalAndWithShortcut(ctx ExprContext, self *term) (v any, err error) { } if leftBool, lok := ToBool(leftValue); !lok { - err = fmt.Errorf("got %T as left operand type of 'and' operator, it must be bool", leftBool) + err = fmt.Errorf("got %s as left operand type of 'AND' operator, it must be bool", TypeName(leftValue)) return } else if !leftBool { v = false @@ -106,9 +104,7 @@ func evalAndWithShortcut(ctx ExprContext, self *term) (v any, err error) { func newOrTerm(tk *Token) (inst *term) { return &term{ - tk: *tk, - // class: classOperator, - // kind: kindBool, + tk: *tk, children: make([]*term, 0, 2), position: posInfix, priority: priOr, @@ -157,7 +153,7 @@ func evalOrWithShortcut(ctx ExprContext, self *term) (v any, err error) { } if leftBool, lok := ToBool(leftValue); !lok { - err = fmt.Errorf("got %T as left operand type of 'or' operator, it must be bool", leftBool) + err = fmt.Errorf("got %s as left operand type of 'OR' operator, it must be bool", TypeName(leftValue)) return } else if leftBool { v = true