Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConstantFoldingOptimizer fails when optimizing "in" operator over non-literal list #198

Closed
oridag opened this issue Dec 21, 2023 · 0 comments · Fixed by #199
Closed

ConstantFoldingOptimizer fails when optimizing "in" operator over non-literal list #198

oridag opened this issue Dec 21, 2023 · 0 comments · Fixed by #199

Comments

@oridag
Copy link
Contributor

oridag commented Dec 21, 2023

import dev.cel.bundle.CelFactory
import dev.cel.common.types.{ListType, SimpleType}
import dev.cel.optimizer.CelOptimizerFactory
import dev.cel.optimizer.optimizers.ConstantFoldingOptimizer


object Repro extends App {

  val cel = CelFactory
    .standardCelBuilder
    .addVar("arg", ListType.create(SimpleType.STRING))
    .build()

  val optimizer = CelOptimizerFactory.standardCelOptimizerBuilder(cel)
    .addAstOptimizers(ConstantFoldingOptimizer.INSTANCE)
    .build()


  optimizer.optimize(cel.compile("'abc' in arg").getAst)

}
Exception in thread "main" java.lang.ExceptionInInitializerError
	at Repro.main(Repro.scala)
Caused by: dev.cel.optimizer.CelOptimizationException: Optimization failure: IDENT
	at dev.cel.optimizer.CelOptimizerImpl.optimize(CelOptimizerImpl.java:52)
	at Repro$.<clinit>(Repro.scala:19)
	... 1 more
Caused by: java.lang.UnsupportedOperationException: IDENT
	at dev.cel.common.ast.AutoOneOf_CelExpr_ExprKind$Parent_.createList(AutoOneOf_CelExpr_ExprKind.java:96)
	at dev.cel.common.ast.CelExpr.createList(CelExpr.java:106)
	at dev.cel.optimizer.optimizers.ConstantFoldingOptimizer.maybePruneBranches(ConstantFoldingOptimizer.java:302)
	at dev.cel.optimizer.optimizers.ConstantFoldingOptimizer.optimize(ConstantFoldingOptimizer.java:84)
	at dev.cel.optimizer.CelOptimizerImpl.optimize(CelOptimizerImpl.java:45)
	... 2 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant