use of typeName() in error messages

This commit is contained in:
2024-06-05 05:48:02 +02:00
parent 974835a8ef
commit ab2e3f0528
3 changed files with 13 additions and 19 deletions
+5 -5
View File
@@ -156,15 +156,15 @@ func (self *term) toInt(computedValue any, valueDescription string) (i int, err
if index64, ok := computedValue.(int64); ok {
i = int(index64)
} else {
err = self.Errorf("%s, got %T (%v)", valueDescription, computedValue, computedValue)
err = self.Errorf("%s, got %s (%v)", valueDescription, typeName(computedValue), computedValue)
}
return
}
func (self *term) errIncompatibleTypes(leftValue, rightValue any) error {
leftType := getTypeName(leftValue)
leftType := typeName(leftValue)
leftText := getFormatted(leftValue, Truncate)
rightType := getTypeName(rightValue)
rightType := typeName(rightValue)
rightText := getFormatted(rightValue, Truncate)
return self.tk.Errorf(
"left operand '%s' [%s] and right operand '%s' [%s] are not compatible with operator %q",
@@ -175,8 +175,8 @@ func (self *term) errIncompatibleTypes(leftValue, rightValue any) error {
func (self *term) errIncompatibleType(value any) error {
return self.tk.Errorf(
"prefix/postfix operator %q do not support operand '%v' [%T]",
self.source(), value, value)
"prefix/postfix operator %q do not support operand '%v' [%s]",
self.source(), value, typeName(value))
}
func (self *term) Errorf(template string, args ...any) (err error) {