@@ -2172,21 +2172,27 @@ void LogicalCondVisitor::PostVisitArg(int arg_num, const cel::Expr* expr) {
21722172 return ;
21732173 }
21742174 const int last_arg_index = expr->call_expr ().args ().size () - 1 ;
2175- if (arg_num > 0 ) {
2175+ const size_t num_args = expr->call_expr ().args ().size ();
2176+ if (arg_num == last_arg_index) {
21762177 if (is_or_) {
2177- visitor_->AddStep (CreateOrStep (expr->id ()));
2178+ visitor_->AddStep (CreateOrStep (num_args, expr->id ()));
21782179 } else {
2179- visitor_->AddStep (CreateAndStep (expr->id ()));
2180+ visitor_->AddStep (CreateAndStep (num_args, expr->id ()));
21802181 }
21812182 if (short_circuiting_ && !jump_steps_.empty ()) {
2182- visitor_->SetProgressStatusIfError (
2183- jump_steps_.back ().set_target (visitor_->GetCurrentIndex ()));
2183+ for (auto & jump : jump_steps_) {
2184+ visitor_->SetProgressStatusIfError (
2185+ jump.set_target (visitor_->GetCurrentIndex ()));
2186+ }
21842187 }
21852188 }
21862189 if (short_circuiting_ && arg_num < last_arg_index) {
21872190 std::unique_ptr<JumpStepBase> jump_step =
2188- is_or_ ? CreateCondJumpStep (true , {}, expr->id ())
2189- : CreateCondJumpStep (false , {}, expr->id ());
2191+ is_or_
2192+ ? CreateCondJumpStep (true , {}, /* expected_stack_size=*/ arg_num + 1 ,
2193+ expr->id ())
2194+ : CreateCondJumpStep (false , {}, /* expected_stack_size=*/ arg_num + 1 ,
2195+ expr->id ());
21902196 ProgramStepIndex index = visitor_->GetCurrentIndex ();
21912197 if (JumpStepBase* jump_step_ptr = visitor_->AddStep (std::move (jump_step));
21922198 jump_step_ptr) {
0 commit comments