diff --git a/common/src/main/java/dev/cel/common/CelOptions.java b/common/src/main/java/dev/cel/common/CelOptions.java index 29202945..f4082f91 100644 --- a/common/src/main/java/dev/cel/common/CelOptions.java +++ b/common/src/main/java/dev/cel/common/CelOptions.java @@ -89,7 +89,6 @@ public abstract class CelOptions { public abstract boolean enableCelValue(); - public abstract boolean enableComprehensionLazyEval(); public abstract int comprehensionMaxIterations(); @@ -181,7 +180,6 @@ public static Builder newBuilder() { .resolveTypeDependencies(true) .enableUnknownTracking(false) .enableCelValue(false) - .enableComprehensionLazyEval(true) .comprehensionMaxIterations(-1); } @@ -455,12 +453,6 @@ public abstract static class Builder { */ public abstract Builder comprehensionMaxIterations(int value); - /** - * Enables certain comprehension expressions to be lazily evaluated where safe. Currently, this - * only works for cel.bind. - */ - public abstract Builder enableComprehensionLazyEval(boolean value); - public abstract CelOptions build(); } } diff --git a/extensions/src/test/java/dev/cel/extensions/CelBindingsExtensionsTest.java b/extensions/src/test/java/dev/cel/extensions/CelBindingsExtensionsTest.java index 65657fbd..a11a6a93 100644 --- a/extensions/src/test/java/dev/cel/extensions/CelBindingsExtensionsTest.java +++ b/extensions/src/test/java/dev/cel/extensions/CelBindingsExtensionsTest.java @@ -24,7 +24,6 @@ import com.google.testing.junit.testparameterinjector.TestParameters; import dev.cel.common.CelAbstractSyntaxTree; import dev.cel.common.CelFunctionDecl; -import dev.cel.common.CelOptions; import dev.cel.common.CelOverloadDecl; import dev.cel.common.CelValidationException; import dev.cel.common.types.SimpleType; @@ -81,19 +80,6 @@ public void binding_success(@TestParameter BindingTestCase testCase) throws Exce assertThat(evaluatedResult).isTrue(); } - @Test - public void binding_lazyEval_success(@TestParameter BindingTestCase testCase) throws Exception { - CelAbstractSyntaxTree ast = COMPILER.compile(testCase.source).getAst(); - CelRuntime.Program program = - CelRuntimeFactory.standardCelRuntimeBuilder() - .setOptions(CelOptions.current().enableComprehensionLazyEval(true).build()) - .build() - .createProgram(ast); - boolean evaluatedResult = (boolean) program.eval(); - - assertThat(evaluatedResult).isTrue(); - } - @Test @TestParameters("{expr: 'false.bind(false, false, false)'}") public void binding_nonCelNamespace_success(String expr) throws Exception { @@ -152,7 +138,6 @@ public void lazyBinding_bindingVarNeverReferenced() throws Exception { CelRuntime celRuntime = CelRuntimeFactory.standardCelRuntimeBuilder() .addMessageTypes(TestAllTypes.getDescriptor()) - .setOptions(CelOptions.current().enableComprehensionLazyEval(true).build()) .addFunctionBindings( CelFunctionBinding.from( "get_true_overload", @@ -189,7 +174,6 @@ public void lazyBinding_accuInitEvaluatedOnce() throws Exception { AtomicInteger invocation = new AtomicInteger(); CelRuntime celRuntime = CelRuntimeFactory.standardCelRuntimeBuilder() - .setOptions(CelOptions.current().enableComprehensionLazyEval(true).build()) .addFunctionBindings( CelFunctionBinding.from( "get_true_overload", @@ -222,7 +206,6 @@ public void lazyBinding_withNestedBinds() throws Exception { AtomicInteger invocation = new AtomicInteger(); CelRuntime celRuntime = CelRuntimeFactory.standardCelRuntimeBuilder() - .setOptions(CelOptions.current().enableComprehensionLazyEval(true).build()) .addFunctionBindings( CelFunctionBinding.from( "get_true_overload", diff --git a/optimizer/src/test/java/dev/cel/optimizer/optimizers/SubexpressionOptimizerTest.java b/optimizer/src/test/java/dev/cel/optimizer/optimizers/SubexpressionOptimizerTest.java index 3ff4a249..9b516bdd 100644 --- a/optimizer/src/test/java/dev/cel/optimizer/optimizers/SubexpressionOptimizerTest.java +++ b/optimizer/src/test/java/dev/cel/optimizer/optimizers/SubexpressionOptimizerTest.java @@ -86,11 +86,7 @@ private static CelBuilder newCelBuilder() { .setContainer("dev.cel.testing.testdata.proto3") .setStandardMacros(CelStandardMacro.STANDARD_MACROS) .setOptions( - CelOptions.current() - .enableTimestampEpoch(true) - .enableComprehensionLazyEval(true) - .populateMacroCalls(true) - .build()) + CelOptions.current().enableTimestampEpoch(true).populateMacroCalls(true).build()) .addCompilerLibraries(CelOptionalLibrary.INSTANCE, CelExtensions.bindings()) .addRuntimeLibraries(CelOptionalLibrary.INSTANCE) .addFunctionDeclarations( diff --git a/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java b/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java index b0f18d87..f21cd18b 100644 --- a/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java +++ b/runtime/src/main/java/dev/cel/runtime/DefaultInterpreter.java @@ -814,7 +814,7 @@ private IntermediateResult evalComprehension( .build(); } IntermediateResult accuValue; - if (celOptions.enableComprehensionLazyEval() && LazyExpression.isLazilyEvaluable(compre)) { + if (LazyExpression.isLazilyEvaluable(compre)) { accuValue = IntermediateResult.create(new LazyExpression(compre.accuInit())); } else { accuValue = evalNonstrictly(frame, compre.accuInit());