diff options
| author | Igor Chervatyuk <igor.chervatyuk@intel.com> | 2024-06-24 23:51:35 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-08 07:03:03 +0000 |
| commit | 66d0bd91ad07c0e9deb6ed8a312760c4418aa4c3 (patch) | |
| tree | 612bf4c7630347592882c4a6bbf9d86c8c47e2ed | |
| parent | b0d6aa6df955f9a20d9ef61bc3e781d9ce135c6c (diff) | |
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.
| -rw-r--r-- | CONTRIBUTORS | 1 | ||||
| -rw-r--r-- | pkg/compiler/check.go | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3eb1319e8..f83b508b2 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -72,6 +72,7 @@ Mark Johnston Intel Corporation Pengfei Xu Yanting Jiang + Igor Chervatyuk NVIDIA Corporation & Affiliates Noa Osherovich Jason Gunthorpe 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) } } } |
