From 855c6bd44aab3054d8e94e93cbb5f49172aa33a7 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Thu, 21 Jul 2022 09:41:17 +0200 Subject: [PATCH] ast/builtins: fix 'type_name' type and docs (#4920) Signed-off-by: Stephan Renatus --- ast/builtins.go | 10 +++++----- builtin_metadata.json | 9 +++++++-- capabilities.json | 5 ----- internal/cmd/genbuiltinmetadata/main.go | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ast/builtins.go b/ast/builtins.go index 61b1c81982..d03c99c585 100644 --- a/ast/builtins.go +++ b/ast/builtins.go @@ -2422,15 +2422,15 @@ var IsNull = &Builtin{ // TypeNameBuiltin returns the type of the input. var TypeNameBuiltin = &Builtin{ - Name: "type_name", + Name: "type_name", + Description: "Returns the type of its input value.", Decl: types.NewFunction( types.Args( - types.NewAny( - types.A, - ), + types.Named("x", types.A), ), - types.S, + types.Named("type", types.S).Description(`one of "null", "boolean", "number", "string", "array", "object", "set"`), ), + Categories: typesCat, } /** diff --git a/builtin_metadata.json b/builtin_metadata.json index ef4463cd23..11bd60f52e 100644 --- a/builtin_metadata.json +++ b/builtin_metadata.json @@ -214,7 +214,8 @@ "is_number", "is_object", "is_set", - "is_string" + "is_string", + "type_name" ], "units": [ "units.parse", @@ -12531,7 +12532,8 @@ "type_name": { "args": [ { - "type": "any\u003cany\u003e" + "name": "x", + "type": "any" } ], "available": [ @@ -12600,8 +12602,11 @@ "v0.42.2", "edge" ], + "description": "Returns the type of its input value.", "introduced": "v0.17.0", "result": { + "description": "one of \"null\", \"boolean\", \"number\", \"string\", \"array\", \"object\", \"set\"", + "name": "type", "type": "string" }, "wasm": true diff --git a/capabilities.json b/capabilities.json index 2a57613fb0..9269d89a53 100644 --- a/capabilities.json +++ b/capabilities.json @@ -3803,11 +3803,6 @@ "decl": { "args": [ { - "of": [ - { - "type": "any" - } - ], "type": "any" } ], diff --git a/internal/cmd/genbuiltinmetadata/main.go b/internal/cmd/genbuiltinmetadata/main.go index 2f81840eb7..2043d4c28b 100644 --- a/internal/cmd/genbuiltinmetadata/main.go +++ b/internal/cmd/genbuiltinmetadata/main.go @@ -157,7 +157,7 @@ func builtinCategories(b *ast.Builtin) []string { if !b.IsDeprecated() { switch b.Name { case "assign", "cast_array", "cast_boolean", "cast_null", "cast_object", "cast_set", "cast_string", - "eq", "print", "re_match", "set_diff", "type_name": + "eq", "print", "re_match", "set_diff": // Do nothing. default: log.Printf("WARN: not categorized: %s", b.Name)