aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-06-23 15:45:14 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-06-24 15:02:59 +0000
commit80dc82961e63dcbee9fc31bcce5b74ab8a9f0b2e (patch)
tree60bcda9eaf52921c9f03a51f7d7836ad889b92cc /prog
parente2f27c3515f1d25672dedf92071bf6d40f623969 (diff)
prog: validate transient unions
Ensure that there are no more transient unions in the fully constructed programs.
Diffstat (limited to 'prog')
-rw-r--r--prog/validation.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/prog/validation.go b/prog/validation.go
index ccaa4b990..48a6efade 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -261,6 +261,10 @@ func (arg *UnionArg) validate(ctx *validCtx, dir Dir) error {
if arg.Index < 0 || arg.Index >= len(typ.Fields) {
return fmt.Errorf("union arg %v has bad index %v/%v", arg, arg.Index, len(typ.Fields))
}
+ if arg.transient && !ctx.opts.ignoreTransient {
+ // The union must have been patched via Call.setDefaultConditions.
+ return fmt.Errorf("union arg %v is transient (incomplete)", arg)
+ }
opt := typ.Fields[arg.Index]
return ctx.validateArg(arg.Option, opt.Type, opt.Dir(dir))
}