add anymap to allow map with __call__ in thread

This commit is contained in:
2023-03-25 01:20:23 +00:00
parent 07c8a7898c
commit fa32f7b824
2 changed files with 8 additions and 3 deletions

View File

@@ -11,9 +11,12 @@ func ArThread(args ...any) (any, ArErr) {
}
var tocall any
switch x := args[0].(type) {
case Callable:
tocall = x
case builtinFunc:
case anymap:
if _, ok := x["__call__"]; !ok {
return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}
}
tocall = x["__call__"]
case builtinFunc, Callable:
tocall = x
default:
return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}

View File

@@ -12,6 +12,8 @@ func typeof(val any) string {
return "string"
case []any:
return "array"
case anymap:
return "map"
case Callable:
return "function"
case builtinFunc: