File tree Expand file tree Collapse file tree
main/java/dev/cel/verifier/axioms
test/java/dev/cel/verifier Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,9 +234,12 @@ private static CelZ3OverloadTranslator createUninterpretedConversion(Conversions
234234 break ;
235235 case DOUBLE :
236236 sink .accept (ctx .mkOr (typeSystem .isDouble (res ), typeSystem .isError (res )));
237- sink .accept (
238- ctx .mkImplies (
239- typeSystem .isDouble (res ), ctx .mkNot (ctx .mkFPIsNaN (typeSystem .getDouble (res )))));
237+ // Numeric conversions never yield NaN, but parsing does (double('NaN')).
238+ if (conversion != Conversions .STRING_TO_DOUBLE ) {
239+ sink .accept (
240+ ctx .mkImplies (
241+ typeSystem .isDouble (res ), ctx .mkNot (ctx .mkFPIsNaN (typeSystem .getDouble (res )))));
242+ }
240243 break ;
241244 case STRING :
242245 sink .accept (ctx .mkOr (typeSystem .isString (res ), typeSystem .isError (res )));
Original file line number Diff line number Diff line change @@ -365,6 +365,7 @@ private enum IsSatisfiableInconclusiveTestCase {
365365 APPROXIMATED_RANGE ("int('123') > 100 && int('123') < 200" ),
366366 APPROXIMATED_BRANCHING ("int('123') == 123 ? x > 5 : false" ),
367367 APPROXIMATED_STRING_TO_INT_CONSTRAINED ("string_var == 'abc' && int(string_var) == 5" ),
368+ APPROXIMATED_STRING_TO_DOUBLE_NAN ("double('NaN') != double('NaN')" ),
368369 // int('x') errors at runtime, so type() of an approximate argument is approximate too.
369370 APPROXIMATED_TYPE_OF_CONVERSION ("type(int('1')) == int" ),
370371 APPROXIMATED_TYPE_OF_CONSTRAINED_CONVERSION (
@@ -473,6 +474,7 @@ private enum IsUnsatisfiableTestCase {
473474 CONTRADICTORY_TYPES_FOR_DYNAMIC_VARIABLE ("unknown_var + 1 == 2 && unknown_var[0] == 1" ),
474475 TYPE_CONVERSION_UNSATISFIABLE_STRING_TO_INT ("type(int('1')) == string" ),
475476 TYPE_CONVERSION_UNSATISFIABLE_DOUBLE_TO_STRING ("type(string(1.5)) == int" ),
477+ TYPE_CONVERSION_UNSATISFIABLE_INT_TO_DOUBLE_NAN ("double(x) != double(x)" ),
476478 EMPTY_MAP_SIZE_NOT_ZERO ("size({}) != 0" ),
477479 TIMESTAMP_INEQUALITY_CONTRADICTION (
478480 "timestamp('2023-01-01T00:00:00Z') != timestamp('2023-01-01T00:00:00Z')" ),
You can’t perform that action at this time.
0 commit comments