File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,19 @@ type astPruner struct {
68
68
// the overloads accordingly.
69
69
func PruneAst (expr * exprpb.Expr , macroCalls map [int64 ]* exprpb.Expr , state EvalState ) * exprpb.ParsedExpr {
70
70
pruneState := NewEvalState ()
71
+ maxID := int64 (1 )
71
72
for _ , id := range state .IDs () {
72
73
v , _ := state .Value (id )
73
74
pruneState .SetValue (id , v )
75
+ if id > maxID {
76
+ maxID = id + 1
77
+ }
74
78
}
75
79
pruner := & astPruner {
76
80
expr : expr ,
77
81
macroCalls : macroCalls ,
78
82
state : pruneState ,
79
- nextExprID : 1 }
83
+ nextExprID : maxID }
80
84
newExpr , _ := pruner .maybePrune (expr )
81
85
return & exprpb.ParsedExpr {
82
86
Expr : newExpr ,
Original file line number Diff line number Diff line change @@ -152,6 +152,11 @@ var testCases = []testInfo{
152
152
expr : `test in {'a': 1, 'field': [test, 3]}.field` ,
153
153
out : `test in {"a": 1, "field": [test, 3]}.field` ,
154
154
},
155
+ {
156
+ in : partialActivation (map [string ]any {"foo" : "bar" }, "r.attr" ),
157
+ expr : `foo == "bar" && r.attr.loc in ["GB", "US"]` ,
158
+ out : `r.attr.loc in ["GB", "US"]` ,
159
+ },
155
160
// TODO: the output of an expression like this relies on either
156
161
// a) doing replacements on the original macro call, or
157
162
// b) mutating the macro call tracking data rather than the core
You can’t perform that action at this time.
0 commit comments