aboutsummaryrefslogtreecommitdiffstats
path: root/prog/expr.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <wp32pw@gmail.com>2024-03-08 17:24:27 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2024-03-08 16:36:20 +0000
commit052b897ff963e84cb5f7d41649b6e5f2a74b3268 (patch)
tree7d2382b675a5b5cd36a1b86a075488113d7f06b6 /prog/expr.go
parent666fe1b4b5e1245111f06d056e691585b1d4d672 (diff)
Revert "prog: auto-set proper conditional fields in Deserialize()"
This reverts commit 8e75c913b6f9b09cab2ad31fd7d66ea0d1703de8.
Diffstat (limited to 'prog/expr.go')
-rw-r--r--prog/expr.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/prog/expr.go b/prog/expr.go
index 38358b214..5ecbef8eb 100644
--- a/prog/expr.go
+++ b/prog/expr.go
@@ -174,7 +174,7 @@ func matchingUnionArgs(typ *UnionType, finder ArgFinder) []int {
func (p *Prog) checkConditions() error {
for _, c := range p.Calls {
- err := c.checkConditions(p.Target, false)
+ err := c.checkConditions(p.Target)
if err != nil {
return err
}
@@ -184,15 +184,12 @@ func (p *Prog) checkConditions() error {
var ErrViolatedConditions = errors.New("conditional fields rules violation")
-func (c *Call) checkConditions(target *Target, ignoreTransient bool) error {
+func (c *Call) checkConditions(target *Target) error {
var ret error
makeArgFinder := argFinderConstructor(target, c)
forEachStaleUnion(target, c, makeArgFinder,
func(a *UnionArg, t *UnionType, okIndices []int) {
- if ignoreTransient && a.transient {
- return
- }
ret = fmt.Errorf("%w union %s field is #%d(%s), but %v satisfy conditions",
ErrViolatedConditions, t.Name(), a.Index, t.Fields[a.Index].Name,
okIndices)
@@ -200,7 +197,7 @@ func (c *Call) checkConditions(target *Target, ignoreTransient bool) error {
return ret
}
-func (c *Call) setDefaultConditions(target *Target, transientOnly bool) bool {
+func (c *Call) setDefaultConditions(target *Target) bool {
var anyReplaced bool
// Replace stale conditions with the default values of their correct types.
for {
@@ -208,9 +205,6 @@ func (c *Call) setDefaultConditions(target *Target, transientOnly bool) bool {
makeArgFinder := argFinderConstructor(target, c)
forEachStaleUnion(target, c, makeArgFinder,
func(unionArg *UnionArg, unionType *UnionType, okIndices []int) {
- if transientOnly && !unionArg.transient {
- return
- }
// If several union options match, take the first one.
idx := okIndices[0]
field := unionType.Fields[idx]