builtin-base: bool() supports lists and dicts, int() supports fractions

This commit is contained in:
2026-04-18 12:20:05 +02:00
parent 7b93c5b4ac
commit 92bd366380
2 changed files with 17 additions and 6 deletions
+6
View File
@@ -72,6 +72,10 @@ func boolFunc(ctx ExprContext, name string, args map[string]any) (result any, er
result = v
case string:
result = len(v) > 0
case *ListType:
result = len(*v) > 0
case *DictType:
result = len(*v) > 0
default:
err = ErrCantConvert(name, v, "bool")
}
@@ -95,6 +99,8 @@ func intFunc(ctx ExprContext, name string, args map[string]any) (result any, err
if i, err = strconv.Atoi(v); err == nil {
result = int64(i)
}
case *FractionType:
result = int64(v.num / v.den)
default:
err = ErrCantConvert(name, v, "int")
}