]> Cypherpunks repositories - keks.git/commitdiff
Make slice only after the check is done
authorSergey Matveev <stargrave@stargrave.org>
Thu, 10 Apr 2025 07:15:15 +0000 (10:15 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 10 Apr 2025 07:15:15 +0000 (10:15 +0300)
go/schema/check.go

index 9b2669148a50f4bc96c04a05dcf5c73db42c425f65dd179da9d266196496b0c6..83b79ef882b4fca4af75a6d6b4a492540a3ef149f578b590bf3962f137f451c1 100644 (file)
@@ -273,7 +273,6 @@ func Check(schemaName string, schemas map[string][][]any, data any) error {
                        if vs == nil {
                                continue
                        }
-                       expected := make([]types.Type, 0, len(cmd)-1)
                        if len(cmd) < 2 {
                                return &SchemaErr{BaseErr: BaseErr{
                                        SchemaName: schemaName,
@@ -282,6 +281,7 @@ func Check(schemaName string, schemas map[string][][]any, data any) error {
                                        Msg:        "wrong number of args",
                                }}
                        }
+                       expected := make([]types.Type, 0, len(cmd)-1)
                        for _, tAny := range cmd[1:] {
                                var t string
                                t, ok = tAny.(string)