Skip to content

Fix constant folding and local variable resolution - #1371

Merged
TristonianJones merged 3 commits into
cel-expr:masterfrom
TristonianJones:folding-shadowing-error
Jul 20, 2026
Merged

Fix constant folding and local variable resolution#1371
TristonianJones merged 3 commits into
cel-expr:masterfrom
TristonianJones:folding-shadowing-error

Conversation

@TristonianJones

@TristonianJones TristonianJones commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Align constant folding and attribute resolution behavior with cel-java, fixing local variable pattern matching during partial evaluation.

  • Updated matchesUnknownPatterns to check whether a variable is locally bound (e.g. comprehension iterator/accumulator variables i, accuVar) so local variables are not incorrectly flagged as unknown global attributes during partial evaluation.
  • Updated folding to skip attempting computations over local variables within a comprehension.
  • Added support for partial evaluation over unknown values to fold properly with Unknown rather than error.
  • Added in optimizations to cover element or identity equality even when the variable is unknown.

Closes #1296

@TristonianJones
TristonianJones requested a review from l46kok July 18, 2026 00:33
@TristonianJones
TristonianJones force-pushed the folding-shadowing-error branch from 6c2a22f to 43856d1 Compare July 18, 2026 00:36
@TristonianJones
TristonianJones force-pushed the folding-shadowing-error branch from 43856d1 to 75ef5c2 Compare July 18, 2026 00:38
Comment thread cel/folding.go
@TristonianJones
TristonianJones merged commit 5933d07 into cel-expr:master Jul 20, 2026
8 checks passed
@TristonianJones
TristonianJones deleted the folding-shadowing-error branch July 20, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constant folding fails for comprehensions containing a shadowed variable

2 participants