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 var tocall any
switch x := args[0].(type) { switch x := args[0].(type) {
case Callable: case anymap:
tocall = x if _, ok := x["__call__"]; !ok {
case builtinFunc: return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}
}
tocall = x["__call__"]
case builtinFunc, Callable:
tocall = x tocall = x
default: default:
return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true} 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" return "string"
case []any: case []any:
return "array" return "array"
case anymap:
return "map"
case Callable: case Callable:
return "function" return "function"
case builtinFunc: case builtinFunc: