Skip to content

Commit ae67468

Browse files
l46kokcopybara-github
authored andcommitted
Preserve the original CelExpr from symmbol table for comprehensions in verifier
PiperOrigin-RevId: 951504755
1 parent 077d9a9 commit ae67468

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

verifier/src/main/java/dev/cel/verifier/CelAstToZ3Translator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ private <T> T withScope(String varName, TranslatedValue value, Supplier<T> actio
644644
private TranslatedValue translateComprehension(CelExpr celExpr, CelAbstractSyntaxTree ast) {
645645
CelComprehension comp = celExpr.comprehension();
646646
CelExpr iterRangeExpr = comp.iterRange();
647+
if (iterRangeExpr.exprKind().getKind() == ExprKind.Kind.IDENT) {
648+
TranslatedValue boundTv = symbolTable.get(iterRangeExpr.ident().name());
649+
if (boundTv != null) {
650+
iterRangeExpr = boundTv.celExpr().orElse(iterRangeExpr);
651+
}
652+
}
647653
List<IterationElement> iterationElements = new ArrayList<>();
648654
List<BoolExpr> taints = new ArrayList<>();
649655
List<Expr<?>> allRangeElems = new ArrayList<>();

0 commit comments

Comments
 (0)