From 160f76ea821e29048389ecb03e8961c4e9cdf519 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 5 Oct 2023 17:40:16 +0200 Subject: pkg/compiler: support (in) for union fields We had a problem -- using inout ANYUNION leads to syzkaller generating copyout instructions for fmt[X, resource] types. Add a validation rule to detect this during tests. Fix this by supporting (in) for union fields. Previously, all union field direction attributes were banned as they were making things more complicated. The (in) attribute is definitely safe and allows for more flexibility. --- pkg/compiler/check.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/compiler/check.go') diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index 4b2dd1330..5f7bb7108 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -185,7 +185,7 @@ func (comp *compiler) checkStructFields(n *ast.Struct, typ, name string) { hasDirections, hasOutOverlay := false, false for fieldIdx, f := range n.Fields { if n.IsUnion { - comp.parseAttrs(nil, f, f.Attrs) + comp.parseAttrs(unionFieldAttrs, f, f.Attrs) continue } attrs := comp.parseAttrs(structFieldAttrs, f, f.Attrs) -- cgit mrf-deployment