From 66d0bd91ad07c0e9deb6ed8a312760c4418aa4c3 Mon Sep 17 00:00:00 2001 From: Igor Chervatyuk Date: Mon, 24 Jun 2024 23:51:35 +0100 Subject: pkg/compiler: recurseField() fails with baseless argument Fix for recurseField() pass that fails due to 'fmt' argument not having a type specifier, if used inside a structure. --- pkg/compiler/check.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 103b69eb5..5345e2e3f 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -959,25 +959,29 @@ func (comp *compiler) checkStructRecursion(checked map[string]bool, n *ast.Struc Struct: name, Field: f.Name.Name, }) - comp.recurseField(checked, f.Type, path) + comp.recurseField(checked, f.Type, path, false) path = path[:len(path)-1] } checked[name] = true } -func (comp *compiler) recurseField(checked map[string]bool, t *ast.Type, path []pathElem) { +func (comp *compiler) recurseField(checked map[string]bool, t *ast.Type, path []pathElem, isArg bool) { desc := comp.getTypeDesc(t) if desc == typeStruct { comp.checkStructRecursion(checked, comp.structs[t.Ident], path) return } - _, args, base := comp.getArgsBase(t, false) + _, args, base := comp.getArgsBase(t, isArg) if desc == typePtr && base.IsOptional { return // optional pointers prune recursion } for i, arg := range args { if desc.Args[i].Type == typeArgType { - comp.recurseField(checked, arg, path) + isArg := false + if t.Ident == "fmt" { + isArg = true + } + comp.recurseField(checked, arg, path, isArg) } } } -- cgit mrf-deployment