ExprContext.SetVar() no longer requires the explicit specification of the type of number

This commit is contained in:
2024-04-09 07:12:22 +02:00
parent bd323efedf
commit 8f396a35de
8 changed files with 42 additions and 13 deletions
+18
View File
@@ -73,6 +73,8 @@ func anyInteger(v any) (i int64, ok bool) {
i = int64(intval)
case uint16:
i = int64(intval)
case uint64:
i = int64(intval)
case uint32:
i = int64(intval)
case int8:
@@ -89,6 +91,22 @@ func anyInteger(v any) (i int64, ok bool) {
return
}
func fromGenericAny(v any) (exprAny any, ok bool) {
if exprAny, ok = v.(bool); ok {
return
}
if exprAny, ok = v.(string); ok {
return
}
if exprAny, ok = anyInteger(v); ok {
return
}
if exprAny, ok = anyFloat(v); ok {
return
}
return
}
func anyFloat(v any) (float float64, ok bool) {
ok = true
switch floatval := v.(type) {