Skip to content

Commit 4e99817

Browse files
l46kokcopybara-github
authored andcommitted
Support cross-type numeric equality in verifier
PiperOrigin-RevId: 949058814
1 parent ff7bccf commit 4e99817

8 files changed

Lines changed: 288 additions & 117 deletions

File tree

verifier/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,6 @@ public class PolicyVerifierExample {
229229

230230
### Limitations
231231

232-
* **Cross-Type Numeric Comparisons:**
233-
* **Equality (`==`, `!=`):** Equality comparisons between different
234-
numeric types (e.g., `int` vs `double` or `uint` vs `double`) are
235-
currently not supported and will evaluate to `false` during
236-
verification, even if they have the same mathematical value (e.g.,
237-
`dyn(1) == dyn(1.0)` is false). Note that `int` vs `uint` equality *is*
238-
supported.
239-
* **Relational Operators (`<`, `>`, `<=`, `>=`):** Cross-type relational
240-
comparisons are fully supported mathematically across all numeric
241-
combinations (`int`, `uint`, and `double`).
242232
* **Unsupported Standard Functions (Uninterpreted Functions):** Not all
243233
CEL standard library functions have SMT axioms defined yet. Unsupported
244234
functions are treated as *uninterpreted functions* by Z3 (the solver

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import dev.cel.common.types.TypeType;
4848
import java.util.ArrayList;
4949
import java.util.Arrays;
50+
import java.util.Collections;
5051
import java.util.HashMap;
5152
import java.util.LinkedHashSet;
5253
import java.util.List;
@@ -564,7 +565,7 @@ private TranslatedValue translateSelect(CelExpr celExpr, CelAbstractSyntaxTree a
564565
typeConstraints.add(createTypeConstraint(fieldAccess, exprId, ast));
565566

566567
return TranslatedValue.propagateStrict(
567-
ctx, typeSystem, fieldAccess, celExpr, Arrays.asList(operandTv));
568+
ctx, typeSystem, fieldAccess, celExpr, Collections.singletonList(operandTv));
568569
}
569570

570571
private TranslatedValue translateBlock(

0 commit comments

Comments
 (0)