aboutsummaryrefslogtreecommitdiffstats
path: root/prog/expr.go
diff options
context:
space:
mode:
Diffstat (limited to 'prog/expr.go')
-rw-r--r--prog/expr.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/prog/expr.go b/prog/expr.go
index cfe6eb70b..e9446ab2c 100644
--- a/prog/expr.go
+++ b/prog/expr.go
@@ -67,11 +67,14 @@ func makeArgFinder(t *Target, c *Call, unionArg *UnionArg, parents parentStack)
}
func (r *randGen) patchConditionalFields(c *Call, s *state) (extra []*Call, changed bool) {
- if r.inPatchConditional {
- return nil, false
- }
- r.inPatchConditional = true
- defer func() { r.inPatchConditional = false }()
+ if r.patchConditionalDepth > 1 {
+ // Some nested patchConditionalFields() calls are fine as we could trigger a resource
+ // constructor via generateArg(). But since nested createResource() calls are prohibited,
+ // patchConditionalFields() should never be nested more than 2 times.
+ panic("third nested patchConditionalFields call")
+ }
+ r.patchConditionalDepth++
+ defer func() { r.patchConditionalDepth-- }()
var extraCalls []*Call
var anyPatched bool