@@ -70,12 +70,39 @@ func walkDynamicObjectsInStack[Output any](
70
70
71
71
// If unknown, then process the unknown instance and skip the rest.
72
72
if unknown {
73
- inst := call .UnknownInstance (ctx , phase )
74
- visit (ctx , walk , inst )
73
+ knownInstances := stack .KnownEmbeddedStacks (call .addr .Item , phase )
74
+ if len (knownInstances ) == 0 {
75
+ // with no known instances, we'll just process the constant
76
+ // unknown instance
77
+ inst := call .UnknownInstance (ctx , phase )
78
+ visit (ctx , walk , inst )
75
79
76
- childStack := inst .Stack (ctx , phase )
77
- walkDynamicObjectsInStack (ctx , walk , childStack , phase , visit )
78
- return
80
+ childStack := inst .Stack (ctx , phase )
81
+ walkDynamicObjectsInStack (ctx , walk , childStack , phase , visit )
82
+ return
83
+ }
84
+
85
+ // otherwise we have instances, so we'll process those with
86
+ // dedicated instances
87
+
88
+ for inst := range knownInstances {
89
+ if inst .Key == addrs .WildcardKey {
90
+ inst := call .UnknownInstance (ctx , phase )
91
+ visit (ctx , walk , inst )
92
+
93
+ childStack := inst .Stack (ctx , phase )
94
+ walkDynamicObjectsInStack (ctx , walk , childStack , phase , visit )
95
+ } else {
96
+ inst := newStackCallInstance (call , inst .Key , instances.RepetitionData {
97
+ EachKey : inst .Key .Value (),
98
+ EachValue : cty .UnknownVal (cty .DynamicPseudoType ),
99
+ }, true )
100
+ visit (ctx , walk , inst )
101
+
102
+ childStack := inst .Stack (ctx , phase )
103
+ walkDynamicObjectsInStack (ctx , walk , childStack , phase , visit )
104
+ }
105
+ }
79
106
}
80
107
81
108
// Otherwise, process the instances and their child stacks.
0 commit comments