Skip to content

Why not return false/true when one of the children's expressions returns false/true in AND/OR directly in with the conjunction simplification rule #440

@unconsolable

Description

@unconsolable

Question

if (conjunction_expr->conjunction_type() == ConjunctionExpr::Type::AND) {
if (constant_value == true) {
child_exprs.erase(iter);
} else {
// always be false
std::unique_ptr<Expression> child_expr = std::move(child_exprs.front());
child_exprs.clear();
expr = std::move(child_expr);
return rc;
}
} else {
// conjunction_type == OR
if (constant_value == true) {
// always be true
std::unique_ptr<Expression> child_expr = std::move(child_exprs.front());
child_exprs.clear();
expr = std::move(child_expr);
return rc;
} else {
child_exprs.erase(iter);
}
}
}

I wonder when one of the children in the AND conjunction expression returns false, this code snippet does not return false directly. Instead, it returns the first child expression (L57-L60). A similar case for the OR conjunction expression (L66-L69).

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions