Skip to content

Commit 7aa5c66

Browse files
l46kokcopybara-github
authored andcommitted
Fix notStrictlyFalse semantics in verifier
PiperOrigin-RevId: 950241075
1 parent 4cd8411 commit 7aa5c66

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,8 @@ private TranslatedValue translateConditional(
848848
private TranslatedValue translateNotStrictlyFalse(List<TranslatedValue> args) {
849849
TranslatedValue arg = args.get(0);
850850
BoolExpr isFalse = ctx.mkAnd(arg.isZ3Bool(), ctx.mkNot((BoolExpr) arg.unwrapZ3Bool()));
851-
return TranslatedValue.propagateStrict(
852-
ctx, typeSystem, typeSystem.wrapBool(ctx.mkNot(isFalse)), arg);
851+
return TranslatedValue.create(
852+
typeSystem.wrapBool(ctx.mkNot(isFalse)), typeSystem, arg.isApproximate());
853853
}
854854

855855
private static CelType extractAstTypeOrDefault(TranslatedValue val, CelAbstractSyntaxTree ast) {

verifier/src/test/java/dev/cel/verifier/CelVerifierZ3ImplTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ private enum IsAlwaysTrueTestCase {
303303
UINT_ARITHMETIC_ZERO("0u + 0u == 0u"),
304304
MAP_COMPREHENSION("{1: 2, 3: 4}.all(k, k > 0)"),
305305
NESTED_COMPREHENSIONS("[1, 2].all(x, [3, 4].all(y, x < y || y <= x))"),
306+
COMPREHENSION_EXISTS_UNKNOWN_INITIAL_STEP("[1, 2].exists(x, x == 1 ? unknown_var > 0 : true)"),
306307
CYCLIC_BIND_DOES_NOT_HANG("cel.bind(x, x, x) == x"),
307308
CEL_BIND_SHADOWING("cel.bind(x, 1, cel.bind(x, 2, x) + x) == 3"),
308309
CEL_BIND_TO_TRUE("cel.bind(x, true, !x) == false"),

0 commit comments

Comments
 (0)