Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions common/src/main/java/dev/cel/common/CelOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public abstract class CelOptions {

public abstract boolean enableCelValue();

public abstract boolean enableComprehensionLazyEval();

public abstract int comprehensionMaxIterations();

Expand Down Expand Up @@ -181,7 +180,6 @@ public static Builder newBuilder() {
.resolveTypeDependencies(true)
.enableUnknownTracking(false)
.enableCelValue(false)
.enableComprehensionLazyEval(true)
.comprehensionMaxIterations(-1);
}

Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down